private void DrawProperties() { // no component type = no drawing if (_componentType?.Type == null) { return; } // check component instance if (_component == null || _component.GetType() != _componentType.Type) { _component = Activator.CreateInstance(_componentType.Type) as ISharedComponentData; if (_component == null) { return; } _fields = _componentType.Type.GetFields(BindingFlags.Instance | BindingFlags.Public) .Select(f => SharedComponentField.Create(_component, f)) .ToArray(); _allFieldsValid = !_fields.Any(f => f is SharedComponentFieldUndefined); } foreach (var field in _fields) { field.Draw(); } }
public SharedComponentFieldFlagEnum(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo) { }
public static SharedComponentField Create(ISharedComponentData component, FieldInfo fieldInfo) { // floating-points if (fieldInfo.FieldType == typeof(float)) { return(new SharedComponentFieldFloat(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(double)) { return(new SharedComponentFieldDouble(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(decimal)) { return(new SharedComponentFieldDecimal(component, fieldInfo)); } // integral if (fieldInfo.FieldType == typeof(int)) { return(new SharedComponentFieldInt(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(uint)) { return(new SharedComponentFieldUInt(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(long)) { return(new SharedComponentFieldLong(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(ulong)) { return(new SharedComponentFieldULong(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(short)) { return(new SharedComponentFieldShort(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(ushort)) { return(new SharedComponentFieldUShort(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(byte)) { return(new SharedComponentFieldByte(component, fieldInfo)); } if (fieldInfo.FieldType == typeof(sbyte)) { return(new SharedComponentFieldSByte(component, fieldInfo)); } // enum if (fieldInfo.FieldType.IsEnum) { if (fieldInfo.FieldType.IsDefined(typeof(FlagsAttribute), false)) { return(new SharedComponentFieldFlagEnum(component, fieldInfo)); } else { return(new SharedComponentFieldEnum(component, fieldInfo)); } } // fallback return(new SharedComponentFieldUndefined(component, fieldInfo)); }
public SharedComponentFieldSByte(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo) { }
protected SharedComponentField(ISharedComponentData component, FieldInfo fieldInfo) { _component = component; _fieldInfo = fieldInfo; _editorName = ObjectNames.NicifyVariableName(_fieldInfo.Name); }
public SharedComponentFieldUShort(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo) { }
public SharedComponentFieldDecimal(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo) { }
public SharedComponentFieldUndefined(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo) { }