Ejemplo n.º 1
0
        /// <summary>
        /// Scans the specified directories for composite components.
        /// </summary>
        /// <param name="componentsDirectoryPath">Directories to be scanned.</param>
        /// <param name="cachedFiles">Paths of files already stored in the cache.</param>
        private void ScanForCompositeComponents(IEnumerable <string> componentsDirectoryPath, ISet <string> cachedFiles)
        {
            var pathSet    = new HashSet <string>(componentsDirectoryPath);
            var serializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(CompositeComponentMetadataDefinition), null);

            foreach (var dir in pathSet)
            {
                string[] filePaths = GetCompositeComponentFiles(dir);

                if (filePaths == null)
                {
                    continue;
                }

                foreach (var filename in filePaths)
                {
                    string fullPath = Path.GetFullPath(filename);

                    if (cachedFiles.Contains(fullPath))
                    {
                        FilesToGetFromCache.Add(fullPath);
                    }
                    else
                    {
                        CompositeComponentFileDescriptor compFile = ReadCompositeComponentFile(serializer, filename);
                        if (compFile != null)
                        {
                            NewFilesLoaded.Add(compFile);
                            FilesToGetFromCache.Add(fullPath);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Scans the specified directories for primitive components.
        /// </summary>
        /// <param name="componentsDirectoryPath">Directories to be scanned.</param>
        /// <param name="cachedFiles">Paths of files already stored in the cache.</param>
        private void ScanForPrimitiveComponents(IEnumerable <string> componentsDirectoryPath, ISet <string> cachedFiles)
        {
            var pathSet = new HashSet <string>(componentsDirectoryPath);

            foreach (string dir in pathSet)
            {
                string[] filePaths = GetAssemblyFiles(dir);

                if (filePaths == null)
                {
                    continue;
                }

                foreach (string comp in filePaths)
                {
                    string fullPath = Path.GetFullPath(comp);

                    if (cachedFiles.Contains(fullPath))
                    {
                        FilesToGetFromCache.Add(fullPath);
                    }
                    else
                    {
                        AssemblyFileDescriptor assembly = ScanAssembly(fullPath);
                        if (assembly != null)
                        {
                            NewFilesLoaded.Add(assembly);
                            FilesToGetFromCache.Add(fullPath);
                        }
                    }
                }
            }
        }