public function resolve($name, $params = [])
    {
        // Allow hot resolving. eg; pass a closure to the resolve() method.
        if (isset($params['resolver']) && $params['resolver'] instanceof \Closure) {
            return $params['resolver']();
        }

        // Allow custom reflection resolutions.
        if (isset($params['reflector']) && $params['reflector'] instanceof \Closure) {
            $reflection = new \ReflectionClass($name);
            if ($reflection->isInstantiable()) {
                return $params['reflector']($reflection, $name);
            }
        }

        // Assets are simple.
        if (isset($this->assets[$name])) {
            if ($this->assets[$name] instanceof Asset || $this->assets[$name] instanceof \Closure) {
                return $this->assets[$name]($params, $this);
            }
        }

        // Singletons are more complex if they haven't been instantiated as yet.
        if (isset($this->instances[$name])) {
            // If we have a resolver (closure or asset) that hasn't been
            // instantiated into an actual instance of our asset yet, do so.
            if ($this->instances[$name] instanceof Asset || $this->instances[$name] instanceof \Closure) {
                $object = $this->instances[$name]($params, $this);
                $this->setParam('instances', $name, $object, true);

            // If we have an instance, return it.
            } else if (is_object($this->instances[$name])) {
                return $this->instances[$name];

            // Do what ever we can to resolve this asset.
            } else {
                try {
                    // Attempt to resolve by name.
                    $object = $this->autoResolve($name, $params);
                    $this->setParam('instances', $name, $object, true);
                    return $this->resolve($name);
                } catch (\LogicException $e) {
                    try {
                        $object = $this->autoResolve($this->instances[$name], $params);
                        $this->setParam('instances', $name, $object, true);
                        return $this->resolve($name);
                    } catch (\LogicException $e) {
                        throw $e;
                    }
                }
            }
        }

        // Recurse back through resolve().
        // This allows complex alias mappings.
        if (isset($this->aliases[$name])) {
            return $this->resolve($this->aliases[$name]);
        }

        // At this point, we still haven't resolved anything.
        // Try resolving by name alone.
        return $this->autoResolve($name, $params);
    }