Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DirectReference.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 00de258a6bf118048b30468ee22e261b361cf340 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;

namespace LibGit2Sharp
{
    /// <summary>
    /// A DirectReference points directly to a <see cref="GitObject"/>
    /// </summary>
    public class DirectReference : Reference
    {
        private readonly Lazy<GitObject> targetBuilder;

        /// <summary>
        /// Needed for mocking purposes.
        /// </summary>
        protected DirectReference()
        { }

        internal DirectReference(string canonicalName, IRepository repo, ObjectId targetId)
            : base(repo, canonicalName, targetId.Sha)
        {
            targetBuilder = new Lazy<GitObject>(() => repo.Lookup(targetId));
        }

        /// <summary>
        /// Gets the target of this <see cref="DirectReference"/>
        /// </summary>
        public virtual GitObject Target
        {
            get { return targetBuilder.Value; }
        }

        /// <summary>
        /// As a <see cref="DirectReference"/> is already peeled, invoking this will return the same <see cref="DirectReference"/>.
        /// </summary>
        /// <returns>This instance.</returns>
        public override DirectReference ResolveToDirectReference()
        {
            return this;
        }
    }
}