Esempio n. 1
0
 /// <summary>
 /// Add a repository file if it does not already exist.  If the repository
 ///     file already exists then it is NOT overwritten.
 /// </summary>
 /// <param name="repository">An object that represents the repository
 ///     file on the file system.</param>
 /// <returns>The repository object.</returns>
 public Repository AddRepository (Repository repository) {
     if (!repository.CvsFile.Exists) {
         this.Touch(repository);
         this.WriteToFile(repository);
     }
     return repository;
 }
Esempio n. 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;
        }