Ejemplo n.º 1
0
        static List <Type> GetDependencies(
            DiContainer container, Type type)
        {
            var dependencies = new List <Type>();

            foreach (var contractType in container.GetDependencyContracts(type))
            {
                List <Type> dependTypes;

                if (contractType.FullName.StartsWith("System.Collections.Generic.List"))
                {
                    var subTypes = contractType.GetGenericArguments();
                    Assert.IsEqual(subTypes.Length, 1);

                    var subType = subTypes[0];
                    dependTypes = container.ResolveTypeMany(subType);
                }
                else
                {
                    dependTypes = container.ResolveTypeMany(contractType);
                    Assert.That(dependTypes.Count <= 1);
                }

                foreach (var dependType in dependTypes)
                {
                    dependencies.Add(dependType);
                }
            }

            return(dependencies);
        }