예제 #1
0
        [ResourceConsumption(ResourceScope.Machine)] //For Create method call. But the paths are not created in this method.
        internal static MetadataArtifactLoader CreateCompositeFromFilePaths(
            IEnumerable <string> filePaths, string validExtension, MetadataArtifactAssemblyResolver resolver)
        {
            ExtensionCheck extensionCheck;

            if (string.IsNullOrEmpty(validExtension))
            {
                extensionCheck = ExtensionCheck.All;
            }
            else
            {
                extensionCheck = ExtensionCheck.Specific;
            }

            var loaders = new List <MetadataArtifactLoader>();

            // The following set is used to remove duplicate paths from the incoming array
            var uriRegistry = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in filePaths)
            {
                if (string.IsNullOrEmpty(path))
                {
                    throw new MetadataException(
                              Strings.NotValidInputPath, new ArgumentException(Strings.ADP_CollectionParameterElementIsNullOrEmpty("filePaths")));
                }

                var trimedPath = path.Trim();
                if (trimedPath.Length > 0)
                {
                    loaders.Add(
                        Create(
                            trimedPath,
                            extensionCheck,
                            validExtension,
                            uriRegistry,
                            resolver)
                        );
                }
            }

            return(Create(loaders));
        }
        internal static MetadataArtifactLoader CreateCompositeFromFilePaths(
            IEnumerable <string> filePaths,
            string validExtension,
            MetadataArtifactAssemblyResolver resolver)
        {
            MetadataArtifactLoader.ExtensionCheck extensionCheck = !string.IsNullOrEmpty(validExtension) ? MetadataArtifactLoader.ExtensionCheck.Specific : MetadataArtifactLoader.ExtensionCheck.All;
            List <MetadataArtifactLoader>         allCollections = new List <MetadataArtifactLoader>();
            HashSet <string> stringSet = new HashSet <string>((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase);

            foreach (string filePath in filePaths)
            {
                if (string.IsNullOrEmpty(filePath))
                {
                    throw new MetadataException(Strings.NotValidInputPath, (Exception) new ArgumentException(Strings.ADP_CollectionParameterElementIsNullOrEmpty((object)nameof(filePaths))));
                }
                string path = filePath.Trim();
                if (path.Length > 0)
                {
                    allCollections.Add(MetadataArtifactLoader.Create(path, extensionCheck, validExtension, (ICollection <string>)stringSet, resolver));
                }
            }
            return(MetadataArtifactLoader.Create(allCollections));
        }