示例#1
0
        public FileTokenList CompareToDirectory(string strDirectory, bool blnFindDifferent, bool blnFindSame)
        {
            bool          blnIncludeRecord   = false;
            FileTokenList objIncludedRecords = new FileTokenList();

            foreach (FileToken objChildRecord in this)
            {
                blnIncludeRecord = true;

                string strFilePath = Path.Combine(strDirectory, objChildRecord.RelativePath);
                if (File.Exists(strFilePath) == true)
                {
                    FileToken objFileToken = FileToken.Load(strFilePath);
                    if (objFileToken != null)
                    {
                        if (objFileToken.Equals(objChildRecord) == true)
                        {
                            blnIncludeRecord = false;
                        }
                    }
                }

                if (blnIncludeRecord == true)
                {
                    objIncludedRecords.Add(objChildRecord);
                }
            }

            return(objIncludedRecords);
        }
示例#2
0
        public void Merge(FileTokenList objFileTokenList)
        {
            foreach (FileToken objFileToken in objFileTokenList)
            {
                string strKey = objFileToken.RelativePath;
                if (LookupDictionary.ContainsKey(strKey) == true)
                {
                    this.Remove(strKey);
                }

                this.Add(objFileToken);
            }
        }
示例#3
0
        private static FileTokenList Load(string strBaseDirectory, string strCurrentDirectory, bool blnIncludeSubDirectories)
        {
            FileTokenList objFileTokenList = new FileTokenList();

            if (Directory.Exists(strCurrentDirectory) == true)
            {
                DirectoryInfo objDirectoryInfo = new DirectoryInfo(strCurrentDirectory);

                if (blnIncludeSubDirectories == true)
                {
                    foreach (DirectoryInfo objChildDirectoryInfo in objDirectoryInfo.GetDirectories())
                    {
                        FileTokenList objChildFileTokenList = FileTokenList.Load(strBaseDirectory, objChildDirectoryInfo.FullName, blnIncludeSubDirectories);
                        objFileTokenList.AddRange(objChildFileTokenList);
                    }
                }

                foreach (FileInfo objFileInfo in objDirectoryInfo.GetFiles())
                {
                    string strDirectory    = Path.GetDirectoryName(objFileInfo.FullName);
                    string strRelativePath = strDirectory.Replace(strBaseDirectory, "");
                    if (strRelativePath.StartsWith("\\") == true)
                    {
                        strRelativePath = strRelativePath.Substring(1);
                    }

                    FileToken objFileToken = FileToken.Load(objFileInfo.FullName, strRelativePath);
                    if (objFileToken != null)
                    {
                        objFileTokenList.Add(objFileToken);
                    }
                }
            }

            return(objFileTokenList);
        }