示例#1
0
        public void AddResolver(Type resolverType, List <string> connectionTypes)
        {
            string resolverTypeFullName = resolverType.FullName;

            if (!CreatedResolvers.ContainsKey(resolverTypeFullName))
            {
                IDependencyResolver dependencyResolver = NodeDependencyLookupUtility.InstantiateClass <IDependencyResolver>(resolverType);
                CreatedResolver     resolver           = new CreatedResolver(dependencyResolver);
                CreatedResolvers.Add(resolverTypeFullName, resolver);
            }

            CreatedResolver createdResolver = CreatedResolvers[resolverTypeFullName];

            string[] collection = connectionTypes != null?connectionTypes.ToArray() : createdResolver.Resolver.GetConnectionTypes();

            createdResolver.ConnectionTypes = new HashSet <string>(collection);

            ResolverUsages.Add(createdResolver);
            ResolverUsagesLookup.Add(createdResolver.Resolver.GetId(), createdResolver);

            createdResolver.IsActive = true;
        }
示例#2
0
        public List <Dependency> GetDependenciesForResolverUsages(Dictionary <string, CreatedResolver> resolverUsages)
        {
            List <Dependency> result = new List <Dependency>();

            foreach (ResolverData data in ResolverDatas)
            {
                if (!resolverUsages.ContainsKey(data.ResolverId))
                {
                    continue;
                }

                CreatedResolver dependencyCache = resolverUsages[data.ResolverId];

                foreach (Dependency dependency in data.Dependencies)
                {
                    if (dependencyCache.ConnectionTypes.Contains(dependency.ConnectionType))
                    {
                        result.Add(dependency);
                    }
                }
            }

            return(result);
        }