-
Notifications
You must be signed in to change notification settings - Fork 1
/
Chain.cs
31 lines (27 loc) · 869 Bytes
/
Chain.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
using System.Collections.Generic;
using System.Linq;
namespace chainer
{
public class Chain : Link
{
protected Dictionary<string, Link> Children = new Dictionary<string, Link>();
public Chain(Dictionary<string, Link> @children)
{
Children = @children;
}
public override IEnumerable<Variable> GetParams()
{
var selfParams = _Params.Values.AsEnumerable();
var childrenParams = Children.Values.SelectMany(child => child.GetParams());
return selfParams.Concat(childrenParams);
}
public override void Serialize(serializers.Serializer serializer)
{
base.Serialize(serializer);
foreach (var kv in Children)
{
kv.Value.Serialize(serializer.Traverse(kv.Key));
}
}
}
}