blob: bda154caf5daffc1596891414ebb928b796b2ebb (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Microsoft.Boogie.ModelViewer
{
[Flags]
public enum NodeState
{
Normal = 0,
Changed = 1
}
public interface IDisplayNode
{
string Name { get; }
IEnumerable<string> Values { get; }
bool Expandable { get; }
IEnumerable<IDisplayNode> Expand();
object ViewSync { get; set; }
NodeState State { get; }
}
public interface ILanguageProvider
{
bool IsMyModel(Model m);
IEnumerable<IDisplayNode> GetStates(Model m);
}
public abstract class DisplayNode : IDisplayNode
{
protected string name;
public DisplayNode(string n) { name = n; }
public virtual string Name
{
get { return name; }
}
public virtual IEnumerable<string> Values
{
get { yield break; }
}
public virtual bool Expandable
{
get { return false; }
}
public virtual IEnumerable<IDisplayNode> Expand()
{
yield break;
}
public virtual NodeState State { get { return NodeState.Normal; } }
public object ViewSync { get; set; }
}
public static class SeqExtensions
{
public static IEnumerable<T> Map<S, T>(this IEnumerable<S> inp, Func<S, T> conv)
{
foreach (var s in inp) yield return conv(s);
}
}
public class ContainerNode<T> : DisplayNode
{
protected Func<T, IDisplayNode> convert;
protected IEnumerable<T> data;
public ContainerNode(string name, Func<T, IDisplayNode> convert, IEnumerable<T> data) : base(name)
{
this.convert = convert;
this.data = data;
}
public override bool Expandable { get { return true; } }
public override IEnumerable<IDisplayNode> Expand()
{
foreach (var f in data) {
var res = convert(f);
if (res != null)
yield return res;
}
}
}
}
|