internal object Resolve(Type type, Stack <Type> dependancyStack)
        {
            if (dependancyStack.Contains(type))
            {
                dependancyStack.Push(type);
                throw new CircularDependancyException($"Circular dependancy encountered for {type}\nStack:\n{StackToMessage(dependancyStack)}");
            }

            dependancyStack.Push(type);

            if (!dependencyResolvers.TryGetValue(type, out var resolver))
            {
                if (type.IsClass && !type.IsAbstract)
                {
                    resolver = new TypeDependencyResolver(type);
                    dependencyResolvers[type] = resolver;
                }
                else
                {
                    throw new UnableToResolveTypeException(type, "Type is not registered");
                }
            }

            var obj = resolver.Resolve(this, dependancyStack);

            dependancyStack.Pop();

            return(obj);
        }
 private void Register(Type interfaceType, Type resolvedType)
 {
     dependencyResolvers[interfaceType] = new TypeDependencyResolver(resolvedType);
 }
 public void Register <TType, TResolved>()
 {
     dependencyResolvers[typeof(TType)] = new TypeDependencyResolver(typeof(TResolved));
 }