Esempio n. 1
0
        /// <summary>
        /// Registers dependencies with the specified provider.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="dependencies"></param>
        /// <param name="paths"></param>
        /// <param name="currProviders"></param>
        /// <remarks>
        /// This is the top most overloaded method
        /// </remarks>
        public void RegisterClientDependencies(BaseFileRegistrationProvider provider, IEnumerable<IClientDependencyFile> dependencies, IEnumerable<IClientDependencyPath> paths, ProviderCollection currProviders)
        {
            var asList = dependencies.ToList();

            //find or create the ProviderDependencyList for the provider
            ProviderDependencyList currList = Dependencies
                .Where(x => x.ProviderIs(provider))
                .DefaultIfEmpty(new ProviderDependencyList(provider))
                .SingleOrDefault();

            if (currList == null) return;
            
            //add the dependencies that don't have a provider specified
            currList.AddDependencies(asList
                .Where(x => string.IsNullOrEmpty(x.ForceProvider)));
            
            //add the list if it is new
            if (!Dependencies.Contains(currList) && currList.Dependencies.Count > 0)
                Dependencies.Add(currList); 

            //we need to look up all of the dependencies that have forced providers, 
            //check if we've got a provider list for it, create one if not and add the dependencies
            //to it.
            var allProviderNamesInList = asList
                .Select(x => x.ForceProvider)
                .Where(x => !string.IsNullOrEmpty(x))
                .Distinct();
            var forceProviders = (from provName in allProviderNamesInList
                                  where currProviders[provName] != null
                                  select (BaseFileRegistrationProvider) currProviders[provName]).ToList();
            foreach (var prov in forceProviders)
            {
                //find or create the ProviderDependencyList for the prov
                var p = prov;
                var forceList = Dependencies
                    .Where(x => x.ProviderIs(prov))
                    .DefaultIfEmpty(new ProviderDependencyList(prov))
                    .SingleOrDefault();

                if (forceList == null) continue;

                //add the dependencies that don't have a force provider specified
                forceList.AddDependencies(asList
                    .Where(x => x.ForceProvider == p.Name));
                //add the list if it is new
                if (!Dependencies.Contains(forceList))
                    Dependencies.Add(forceList);
            }

            //add the paths, ensure no dups
            Paths.UnionWith(paths);
        }
		internal bool ProviderIs(BaseFileRegistrationProvider provider)
		{
			return Provider.Name == provider.Name;
		}
		internal ProviderDependencyList(BaseFileRegistrationProvider provider)
		{
			Provider = provider;
            Dependencies = new List<IClientDependencyFile>();
		}