예제 #1
0
파일: Repository.cs 프로젝트: Kuzq/gitter
        /// <summary>Create <see cref="Repository"/>.</summary>
        /// <param name="gitAccessor">Git repository access provider.</param>
        /// <param name="workingDirectory">Repository working directory.</param>
        /// <param name="load"><c>true</c> to load repository; <c>false</c> otherwise.</param>
        private Repository(IGitAccessor gitAccessor, string workingDirectory, bool load)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");
            Verify.Argument.IsNotNull(workingDirectory, "workingDirectory");

            _workingDirectory     = GetWorkingDirectory(workingDirectory);
            _gitDirectory         = GetGitDirectory(_workingDirectory);
            _configurationManager = GetConfigurationManager(_gitDirectory);

            _accessor      = gitAccessor.CreateRepositoryAccessor(this);
            _revisionCache = new RevisionCache(this);
            _configuration = new ConfigParametersCollection(this);
            _status        = new Status(this);
            _stash         = new StashedStatesCollection(this);
            _refs          = new RefsCollection(this);
            _notes         = new NotesCollection(this);
            _remotes       = new RemotesCollection(this);
            _submodules    = new SubmodulesCollection(this);
            _users         = new UsersCollection(this);
            _hooks         = new HooksCollection(this);

            if(load)
            {
                try
                {
                    LoadCore(this, null, CancellationToken.None);
                }
                catch
                {
                    Dispose();
                    throw;
                }
            }
        }
예제 #2
0
        public static List <ActionValueViewModel> BuildPublishedReferentialFile(RefsCollection refs)
        {
            var values = new List <ActionValueViewModel>();

            if (refs == null)
            {
                return(values);
            }

            foreach (var referential in refs.Values)
            {
                // Referential is only text
                if (referential.PublishedReferential.File == null)
                {
                    values.Add(new ActionValueViewModel
                    {
                        Type          = "Text",
                        Value         = referential.PublishedReferential.Label,
                        Quantity      = referential.Quantity,
                        ReferentialId = referential.PublishedReferentialId
                    });
                }
                // Published file is an image
                else if (ImageExtensions.Contains(referential.PublishedReferential.File.Extension))
                {
                    values.Add(new ActionValueViewModel
                    {
                        Type          = "Image",
                        Description   = referential.PublishedReferential.Label,
                        Value         = referential.PublishedReferential.File.Hash,
                        FileHash      = referential.PublishedReferential.File.Hash,
                        FileExt       = referential.PublishedReferential.File.Extension,
                        Quantity      = referential.Quantity,
                        ReferentialId = referential.PublishedReferentialId
                    });
                }
                // Other type of file
                else
                {
                    values.Add(new ActionValueViewModel
                    {
                        Type          = "File",
                        Description   = referential.PublishedReferential.Label,
                        Value         = referential.PublishedReferential.Label,
                        FileHash      = referential.PublishedReferential.File.Hash,
                        FileExt       = referential.PublishedReferential.File.Extension,
                        ReferentialId = referential.PublishedReferentialId
                    });
                }
            }
            return(values);
        }