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

SymbolicReference.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5bb47531206e5d74ce8cf0424a8ab9e843411ba9 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Diagnostics;
using System.Globalization;

namespace LibGit2Sharp
{
    /// <summary>
    /// A SymbolicReference is a reference that points to another reference
    /// </summary>
    [DebuggerDisplay("{DebuggerDisplay,nq}")]
    public class SymbolicReference : Reference
    {
        private readonly Reference target;

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

        internal SymbolicReference(IRepository repo, string canonicalName, string targetIdentifier, Reference target)
            : base(repo, canonicalName, targetIdentifier)
        {
            this.target = target;
        }

        /// <summary>
        /// Gets the target of this <see cref="SymbolicReference"/>
        /// </summary>
        public virtual Reference Target
        {
            get { return target; }
        }

        /// <summary>
        /// Recursively peels the target of the reference until a direct reference is encountered.
        /// </summary>
        /// <returns>The <see cref="DirectReference"/> this <see cref="SymbolicReference"/> points to.</returns>
        public override DirectReference ResolveToDirectReference()
        {
            return (Target == null) ? null : Target.ResolveToDirectReference();
        }

        private string DebuggerDisplay
        {
            get
            {
                return string.Format(CultureInfo.InvariantCulture,
                    "{0} => {1} => \"{2}\"",
                    CanonicalName, TargetIdentifier,
                    (Target != null) ? Target.TargetIdentifier : "?");
            }
        }
    }
}