forked from git-tfs/git-tfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.cs
More file actions
58 lines (50 loc) · 1.71 KB
/
Copy pathScript.cs
File metadata and controls
58 lines (50 loc) · 1.71 KB
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
55
56
57
58
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Core.TfsInterop;
namespace Sep.Git.Tfs.VsFake
{
public class Script
{
public const string EnvVar = "GIT_TFS_VSFAKE_SCRIPT";
public static Script Load(string path)
{
return new Script().Tap(script => Load(path, script));
}
private static void Load(string path, Script script)
{
var formatter = new BinaryFormatter();
using (var stream = File.OpenRead(path))
script.Changesets.AddRange((List<ScriptedChangeset>)formatter.Deserialize(stream));
}
public void Save(string path)
{
var formatter = new BinaryFormatter();
using (var stream = File.Create(path))
formatter.Serialize(stream, Changesets);
}
List<ScriptedChangeset> _changesets = new List<ScriptedChangeset>();
public List<ScriptedChangeset> Changesets { get { return _changesets; } }
}
[Serializable]
public class ScriptedChangeset
{
public int Id { get; set; }
public string Comment { get; set; }
public DateTime CheckinDate { get; set; }
public List<ScriptedChange> Changes { get { return _changes; } }
List<ScriptedChange> _changes = new List<ScriptedChange>();
}
[Serializable]
public class ScriptedChange
{
public TfsChangeType ChangeType { get; set; }
public TfsItemType ItemType { get; set; }
public string RepositoryPath { get; set; }
public string Content { get; set; }
}
}