-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSymLinkElement.cs
42 lines (35 loc) · 1.14 KB
/
SymLinkElement.cs
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
using System;
using System.Collections.Generic;
using ProtoBuf;
namespace GitImporter
{
[Serializable]
[ProtoContract]
public class SymLinkElement : Element
{
public const string SYMLINK = "symlink:";
public Element Directory { get; private set; }
[ProtoMember(1, AsReference = true)] private string _directoryOid;
[ProtoMember(2, AsReference = true)]
public string Target { get; private set; }
public SymLinkElement(Element directory, string name)
: base(directory + "\\" + name.Substring(SYMLINK.Length), false)
{
Oid = SYMLINK + Name;
Directory = directory;
Target = name.Substring(SYMLINK.Length);
}
// for Protobuf deserialization
public SymLinkElement()
{}
[ProtoBeforeSerialization]
private void BeforeProtobufSerialization()
{
_directoryOid = Directory.Oid;
}
public void Fixup(Dictionary<string, Element> elementsByOid)
{
Directory = elementsByOid[_directoryOid];
}
}
}