-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIFunction.cs
98 lines (75 loc) · 2.46 KB
/
IFunction.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
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
94
95
96
97
98
using System;
using System.Collections.Generic;
namespace AdSecCore.Functions {
public interface IFunction {
FuncAttribute Metadata { get; set; }
Organisation Organisation { get; set; }
Attribute[] GetAllInputAttributes();
Attribute[] GetAllOutputAttributes();
void Compute();
}
public abstract class Function : IFunction {
public List<string> ErrorMessages { get; set; } = new List<string>();
public List<string> WarningMessages { get; set; } = new List<string>();
public List<string> RemarkMessages { get; set; } = new List<string>();
public abstract FuncAttribute Metadata { get; set; }
public abstract Organisation Organisation { get; set; }
public virtual Attribute[] GetAllInputAttributes() { return Array.Empty<Attribute>(); }
public virtual Attribute[] GetAllOutputAttributes() { return Array.Empty<Attribute>(); }
public abstract void Compute();
}
public class FuncAttribute {
public string Name { get; set; }
public string NickName { get; set; }
public string Description { get; set; }
}
public class Organisation {
public string Category { get; set; }
public string SubCategory { get; set; }
public bool Hidden { get; set; }
}
public class Attribute {
public string Name { get; set; }
public string NickName { get; set; }
public string Description { get; set; }
public bool Optional { get; set; } = true;
public void Update(ref Attribute update) {
update.Name = Name;
update.NickName = NickName;
update.Description = Description;
update.Optional = Optional;
if (this is IAccessible accessible && update is IAccessible AdSecSection) {
AdSecSection.Access = accessible.Access;
}
}
}
public enum Access {
Item,
List,
}
public interface IDefault {
void SetDefault();
}
public interface IAccessible {
Access Access { get; set; }
}
public class ParameterAttribute<T> : Attribute, IDefault, IAccessible {
private T _value;
public T Value {
get => _value;
set {
_value = value;
OnValueChanged?.Invoke(value);
}
}
public virtual Access Access { get; set; } = Access.Item;
public T Default { get; set; }
public void SetDefault() {
Value = Default;
}
public event Action<T> OnValueChanged;
}
public class BaseArrayParameter<T> : ParameterAttribute<T[]> {
public override Access Access { get; set; } = Access.List;
}
}