public static void SetDefaultValues(this DynamicModelPropertyInfo info, Dictionary <string, object> propertyNames) { if (propertyNames.ContainsKey(info.Name)) { info.RemoveAttributes(typeof(DefaultValueAttribute)); info.AddAttribute(new DefaultValueAttribute(propertyNames[info.Name])); } }
public static void SetCategory(this DynamicModelPropertyInfo info, Dictionary <string, string> propertyNames) { if (propertyNames.ContainsKey(info.Name)) { info.RemoveAttributes(typeof(BrowsableAttribute)); info.AddAttribute(new CategoryAttribute(propertyNames[info.Name])); } }
public static void CreateValueCalculator(this DynamicModelPropertyInfo info, string expressionPath = null) { info.AddAttribute(new BrowsableAttribute(false)); // return; // CreateValueCalculatorCore(info); // ModelValueCalculatorAttribute modelValueCalculatorAttribute; // if (expressionPath != null) { // modelValueCalculatorAttribute = new ModelValueCalculatorAttribute(expressionPath); // info.AddAttribute(new ModelValueCalculatorWrapperAttribute(modelValueCalculatorAttribute, null)); // } else { // info.RemoveAttributes(typeof(ReadOnlyAttribute)); // var type = typeof(MapModelValueCalculator); // modelValueCalculatorAttribute = new ModelValueCalculatorAttribute(type); // info.AddAttribute(new ModelValueCalculatorWrapperAttribute(modelValueCalculatorAttribute, type)); // info.AddAttribute(new ModelReadOnlyAttribute(typeof(MapModelReadOnlyCalculator))); // } }
static void CreateValueCalculatorCore(DynamicModelPropertyInfo info) { info.RemoveAttributes(typeof(DefaultValueAttribute)); info.AddAttribute(new ReadOnlyAttribute(true)); }
public static void CreateValueCalculator(this DynamicModelPropertyInfo info, IModelValueCalculator modelValueCalculator) { CreateValueCalculatorCore(info); info.AddAttribute(new ModelValueCalculatorWrapperAttribute(modelValueCalculator.GetType())); }