Exemplo n.º 1
0
        public InMemoryFileSystem()
        {
            var comparer = new FilenameComparer();

            _files       = new Dictionary <string, MemoryStream>(comparer);
            _directories = new HashSet <string>(comparer);
            _syncRoot    = new object();

            var root = "A:\\";

            Mount(root);
            _currentDirectory = root;
        }
        /// <summary>
        /// Get up to the specified number of child entries of the specified type that match the specified criteria.
        /// </summary>
        internal FileSystemEntry[] GetChildEntries(
            string name, FileSystemEntry parentEntry, EntryType entryType, int maxEntries)
        {
            if (parentEntry.FirstChild == null)
            {
                return(new FileSystemEntry[0]);
            }

            FilenameComparer comparer = new FilenameComparer(name);
            ArrayList        entries  = new ArrayList();

            FileSystemEntry currentEntry = parentEntry.FirstChild;

            if (currentEntry.EntryType == entryType)
            {
                if (comparer.Compare(currentEntry.Name))
                {
                    entries.Add(currentEntry);
                    if (entries.Count >= maxEntries)
                    {
                        return(entries.ToArray(typeof(FileSystemEntry)) as FileSystemEntry[]);
                    }
                }
            }

            int siblingCount = 0;

            while ((currentEntry.Sibling != null) && (siblingCount <= MaxSiblingCount))
            {
                currentEntry = currentEntry.Sibling;
                if (currentEntry.EntryType == entryType)
                {
                    if (currentEntry.Name == name)
                    {
                        entries.Add(currentEntry);
                        if (entries.Count >= maxEntries)
                        {
                            return(entries.ToArray(typeof(FileSystemEntry)) as FileSystemEntry[]);
                        }
                    }
                }

                siblingCount++;
            }
            if (siblingCount > MaxSiblingCount)
            {
                throw new MaxSiblingCountExceededException(MaxSiblingCount, BuildPath(parentEntry));
            }

            return(entries.ToArray(typeof(FileSystemEntry)) as FileSystemEntry[]);
        }
Exemplo n.º 3
0
 public ScriptComparerTests()
 {
     _comparer = new FilenameComparer();
 }
Exemplo n.º 4
0
 public void SetUp()
 {
     fileComparerAsc = new FilenameComparer(true);
     fileComparerDesc = new FilenameComparer(false);
 }