Exemplo n.º 1
0
        private void GatherLinkedTypes(Type inType, out Type[] outDependencies, out Type[] outCacheTypes)
        {
            HashSet <Type> dependencies = new HashSet <Type>();
            HashSet <Type> cacheTypes   = new HashSet <Type>();

            foreach (var serviceDep in Reflect.GetAttributes <ServiceDependencyAttribute>(inType, true))
            {
                foreach (var type in serviceDep.Dependencies)
                {
                    dependencies.Add(type);
                }
            }

            foreach (var type in Reflect.GetBaseTypes(inType))
            {
                if (ShouldIgnoreType(type))
                {
                    break;
                }

                if (type != inType)
                {
                    cacheTypes.Add(type);
                }

                foreach (var dependency in m_ServiceInjectionCache.Get(type))
                {
                    Type depType = Reflect.GetValueType(dependency.Info);
                    if (!dependency.Attribute.Optional)
                    {
                        dependencies.Add(depType);
                    }
                }
            }

            foreach (var _interface in inType.GetInterfaces())
            {
                if (ShouldIgnoreType(_interface))
                {
                    continue;
                }

                cacheTypes.Add(_interface);
            }

            outDependencies = ToArray(dependencies);
            outCacheTypes   = ToArray(cacheTypes);
        }