public void WriteChangeSetToXML(string file, CHANGESET_TYPES type)
        {
            using (XmlWriter writer = XmlWriter.Create(file, XMLMgr.xmlWriterSettings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("CacheInfo");

                foreach (ChangeSetC chSet in getAppropriateListForType(type))
                {
                    writer.WriteStartElement("ContentFile");

                    writer.WriteAttributeString("hash", chSet.hash);
                    writer.WriteAttributeString("filename", chSet.filename);
                    writer.WriteAttributeString("filesize", chSet.filesize);
                    writer.WriteAttributeString("mode", chSet.mode);
                    writer.WriteAttributeString("type", chSet.filetype);
                    writer.WriteAttributeString("compType", chSet.compressionType);

                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
        public void AddToChangeSet(CHANGESET_TYPES type, string hash, string filename, string filetype, string filesize, string mode)
        {
            ChangeSetC data = new ChangeSetC();

            data.hash            = hash;
            data.filename        = filename;
            data.filetype        = filetype;
            data.filesize        = filesize;
            data.mode            = mode;
            data.compressionType = Compressor.getCompressionForFileOrDirType(filetype);

            switch (type)
            {
            case CHANGESET_TYPES.CHANGESET_NEW:
                ChangeSetListNew.Add(data);
                break;

            case CHANGESET_TYPES.CHANGESET_INTEGRITY_OLD:
                ChangeSetListIntegrityOld.Add(data);
                break;

            case CHANGESET_TYPES.CHANGESET_INTEGRITY_CURRENT:
                ChangeSetListIntegrity.Add(data);
                break;
            }

            Console.WriteLine("Added {0}:{1}:{2}:{3}.", GetChangeSetName(type), GetChangeSetCount(type), filename, hash);
            return;
        }
        public MatchesResult DoesFileHashMatch(CHANGESET_TYPES type, string file, string hash)
        {
            MatchesResult result = MatchesResult.matches_none;

            foreach (ChangeSetC chSet in getAppropriateListForType(type))
            {
                if (Path.GetFullPath(file.ToLower()) == Path.GetFullPath(chSet.filename.ToLower()))
                {
                    result |= MatchesResult.matches_filename;
                    if (chSet.hash == hash)
                    {
                        result |= MatchesResult.matches_hash;
                        break;
                    }
                }
            }
            return(result);
        }
        public string GetChangeSetName(CHANGESET_TYPES type)
        {
            string name = string.Empty;

            switch (type)
            {
            case CHANGESET_TYPES.CHANGESET_INTEGRITY_OLD:
                name = "CHANGESET_INTEGRITY_OLD";
                break;

            case CHANGESET_TYPES.CHANGESET_NEW:
                name = "CHANGESET_NEW";
                break;

            case CHANGESET_TYPES.CHANGESET_INTEGRITY_CURRENT:
                name = "CHANGESET_INTEGRITY_CURRENT";
                break;
            }
            return(name);
        }
        public int GetChangeSetCount(CHANGESET_TYPES type)
        {
            int count = 0;

            switch (type)
            {
            case CHANGESET_TYPES.CHANGESET_INTEGRITY_OLD:
                count = ChangeSetListIntegrityOld.Count();
                break;

            case CHANGESET_TYPES.CHANGESET_NEW:
                count = ChangeSetListNew.Count();
                break;

            case CHANGESET_TYPES.CHANGESET_INTEGRITY_CURRENT:
                count = ChangeSetListIntegrity.Count();
                break;
            }
            return(count);
        }
        public static List <ChangeSetC> getAppropriateListForType(CHANGESET_TYPES type)
        {
            List <ChangeSetC> curList = ChangeSetListNew; //Return new one by default if the specified one isn't found

            switch (type)
            {
            case CHANGESET_TYPES.CHANGESET_INTEGRITY_OLD:
                curList = ChangeSetListIntegrityOld;
                break;

            case CHANGESET_TYPES.CHANGESET_NEW:
                curList = ChangeSetListNew;
                break;

            case CHANGESET_TYPES.CHANGESET_INTEGRITY_CURRENT:
                curList = ChangeSetListIntegrity;
                break;
            }
            return(curList);
        }
 public bool DoesChangeSetExist(CHANGESET_TYPES type)
 {
     return(GetChangeSetCount(type) > 0);
 }