コード例 #1
0
        public void ConfirmContentsOfDirectoryAreTheSame(DirectoryInfo first, DirectoryInfo other)
        {
            if (first.EnumerateFiles().Count() != other.EnumerateFiles().Count())
            {
                throw new Exception("found different number of files in Globals directory " + first.FullName + " and " + other.FullName);
            }

            var filesInFirst = first.EnumerateFiles().ToArray();
            var filesInOther = other.EnumerateFiles().ToArray();

            for (int i = 0; i < filesInFirst.Length; i++)
            {
                FileInfo file1 = filesInFirst[i];
                FileInfo file2 = filesInOther[i];
                if (!file1.Name.Equals(file2.Name))
                {
                    throw new Exception("Although there were the same number of files in Globals directories " + first.FullName + " and " + other.FullName + ", there were differing file names (" + file1.Name + " and " + file2.Name + ")");
                }

                if (!UsefulStuff.HashFile(file1.FullName).Equals(UsefulStuff.HashFile(file2.FullName)))
                {
                    throw new Exception("File found in Globals directory which has a different MD5 from another Globals file.  Files were \"" + file1.FullName + "\" and \"" + file2.FullName + "\"");
                }
            }
        }
コード例 #2
0
        public static UsefulStuff GetInstance()
        {
            if (_instance == null)
            {
                _instance = new UsefulStuff();
            }

            return(_instance);
        }