public static void Add(Grid grid, FieldDefinition field, string label, Binding value, int row, int startColumn) { string labelStyle = field.GetExtra("labelstyle", "NormalLabel"); string inputStyle = field.GetExtra("inputstyle", ""); Add(grid, label, value, row, labelStyle, inputStyle, startColumn); }
public virtual FieldDefinition GetField(FieldDefinition f) { foreach (FieldDefinition field in Fields) { if (field.ClassName == f.ClassName && field.FieldName == f.FieldName) return field; } return null; }
public static void Add(Grid grid, FieldDefinition field, string label, Binding value, int row, int startColumn) { double minimum = Convert.ToDouble(field.GetExtra("min", "0")); double maximum = Convert.ToDouble(field.GetExtra("max", "0")); string labelStyle = field.GetExtra("labelstyle", "NormalLabel"); string inputStyle = field.GetExtra("inputstyle", ""); Add(grid, label, value, row, minimum, maximum, labelStyle, inputStyle, startColumn); }
public DataField(BaseData container, FieldDefinition field, object Object) { this.Container = container; this.ContainerObject = Object; this.Field = field; if (DynamicTypes.Types.ContainsKey(this.ContainerObject.GetType().FullName)) this.InitValue = DynamicTypes.Get(this.ContainerObject, field.FieldName); else this.InitValue = this.ContainerObject.GetType().GetField(field.FieldName).GetValue(this.ContainerObject); this._Value = this.InitValue; if (field.Extra.ContainsKey("max")) this._MaxValue = (double)double.Parse(field.Extra["max"]); if (field.Extra.ContainsKey("min")) this._MinValue = (double)double.Parse(field.Extra["min"]); CheckMinMax(); }
public DataField(FieldDefinition field, object Object) { this.ContainerObject = Object; this.Field = field; if (DynamicTypes.Types.ContainsKey(this.ContainerObject.GetType().FullName)) { this.InitValue = DynamicTypes.Get(this.ContainerObject, field.FieldName); Console.WriteLine(Object.GetType().FullName + "_" + field.FieldName + "_"+InitValue); } else { this.InitValue = this.ContainerObject.GetType().GetField(field.FieldName).GetValue(this.ContainerObject); } this._Value = this.InitValue; if (field.Extra.ContainsKey("max")) this._MaxValue = (double)double.Parse(field.Extra["max"]); if (field.Extra.ContainsKey("min")) this._MinValue = (double)double.Parse(field.Extra["min"]); CheckMinMax(); }
public virtual void SetConfiguration(XDocument document) { Classes = new Dictionary<string, ClassDefinition>(); Fields = new List<FieldDefinition>(); foreach (XElement include in document.Root.Elements("Include")) { ClassDefinition classDefinition = new ClassDefinition(); classDefinition.SetConfiguration(include); if (classDefinition.Valid) { Classes.Add(classDefinition.Name, classDefinition); foreach (KeyValuePair<string, FieldDefinition> field in classDefinition.Fields) { Fields.Add(field.Value); } } } XElement extraRootElement = document.Root.Element("Extra"); if (extraRootElement != null) { foreach (XElement extraElement in extraRootElement.Elements("Field")) { FieldDefinition tmpDefinition = new FieldDefinition(); tmpDefinition.SetConfiguration(extraElement); if (!Classes.ContainsKey(tmpDefinition.ClassName)) { Debug.Log("ModAPI.Data", "The class \""+tmpDefinition.ClassName+"\" defined in Extra element is not included in this data package."); } else { ClassDefinition cl = Classes[tmpDefinition.ClassName]; if (!cl.Fields.ContainsKey(tmpDefinition.FieldName)) { Debug.Log("ModAPI.Data", "The field \""+tmpDefinition.FieldName+"\" in class \""+tmpDefinition.ClassName+"\" defined in Extra element either doesn't exist or is not included in this data package."); } else { cl.Fields[tmpDefinition.FieldName].SetConfiguration(tmpDefinition.Configuration); double offset = Convert.ToDouble(cl.Fields[tmpDefinition.FieldName].GetExtra("offset", "0")); if (offset != 0.0) { SetOffset(Fields.IndexOf(cl.Fields[tmpDefinition.FieldName]), offset); } //cl.Fields[tmpDefinition.FieldName].Extra = tmpDefinition.Extra; } } } } }
void AddField(FieldInfo field) { FieldDefinition newField = new FieldDefinition(); newField.ClassName = this.Name; newField.FieldName = field.Name; newField.FieldType = field.FieldType; Fields.Add(field.Name, newField); }