1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
foreach (var field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.DeclaredOnly | BindingFlags.Instance)) {
if (Attribute.IsDefined(field, typeof(Take))) {
SetCommand(CommandType.TAKE, "local", field.Name, new DataGear<object>(field.FieldType));
} else if (Attribute.IsDefined(field, typeof(Peek))) {
SetCommand(CommandType.PEEK, "local", field.Name, new DataGear<object>(field.FieldType));
} else if (Attribute.IsDefined(field, typeof(TakeFrom))) {
TakeFrom attri = (TakeFrom) field.GetCustomAttribute(typeof(TakeFrom));
SetCommand(CommandType.TAKE, attri.name, field.Name, new DataGear<object>(field.FieldType));
} else if (Attribute.IsDefined(field, typeof(PeekFrom))) {
PeekFrom attri = (PeekFrom) field.GetCustomAttribute(typeof(PeekFrom));
SetCommand(CommandType.PEEK, attri.name, field.Name, new DataGear<object>(field.FieldType));
}
}
|