Exemple #1
0
 /// <summary>
 /// Add a tag file if it does not already exist.  If the tag
 ///     file already exists then it is NOT overwritten.
 /// </summary>
 /// <param name="tag">An object that represents the tag
 ///     file on the file system.</param>
 /// <returns>The tag object.</returns>
 public Tag AddTag (Tag tag) {
     try {
         // check if the root exists, if so it does not get modified
         return this.FetchTag(tag.ParentDir.FullName);
     } catch (CvsFileNotFoundException) {
         // if the repository does not exist then add it
         this.WriteToFile(tag);
         // TODO: Remove this, just verifying the write operation
         return this.FetchTag(tag.ParentDir.FullName);
     }
 }
Exemple #2
0
        /// <summary>
        /// Create a cvs file object given the full path and line of the file.
        /// </summary>
        /// <param name="file"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        public ICvsFile CreateCvsObject (FileInfo file, string line) {
            ICvsFile entry;

            if (!System.Enum.IsDefined(typeof(FileType), file.Name)) {
                throw new UnsupportedFileTypeException(string.Format("Unknown cvs file type: {0}",
                    file.Name));
            }

            switch ((FileType)Enum.Parse(typeof(FileType), file.Name, true)) {
                case (FileType.Entries): {
                    entry = new Entry(file, line);
                    break;
                }
                case (FileType.Repository):{
                    entry = new Repository (file, line);
                    break;
                }
                case (FileType.Root):{
                    entry = new Root (file, line);
                    break;
                }
                case (FileType.Tag):{
                    entry = new Tag (file, line);
                    break;
                }
                default:{
                    StringBuilder msg = new StringBuilder();
                    msg.Append("Unknown file type specified.");
                    msg.Append("fileType=[").Append(file.Name).Append("]");
                    throw new UnsupportedFileTypeException (msg.ToString());
                }

            }
            return entry;
        }