public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { PropertyDefine pd = new PropertyDefine(); pd.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty); pd.DisplayName = DictionaryHelper.GetValue(dictionary, "displayName", string.Empty); pd.Category = DictionaryHelper.GetValue(dictionary, "category", string.Empty); pd.DefaultValue = DictionaryHelper.GetValue(dictionary, "defaultValue", string.Empty); pd.DataType = DictionaryHelper.GetValue(dictionary, "dataType", PropertyDataType.String); pd.Description = DictionaryHelper.GetValue(dictionary, "description", string.Empty); pd.ReadOnly = DictionaryHelper.GetValue(dictionary, "readOnly", false); pd.Visible = DictionaryHelper.GetValue(dictionary, "visible", true); pd.EditorKey = DictionaryHelper.GetValue(dictionary, "editorKey", string.Empty); pd.PersisterKey = DictionaryHelper.GetValue(dictionary, "persisterKey", string.Empty); pd.EditorParamsSettingsKey = DictionaryHelper.GetValue(dictionary, "editorParamsSettingsKey", string.Empty); pd.EditorParams = DictionaryHelper.GetValue(dictionary, "editorParams", string.Empty); pd.SortOrder = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF); pd.MaxLength = DictionaryHelper.GetValue(dictionary, "maxLength", 0xFFFF); pd.IsRequired = DictionaryHelper.GetValue(dictionary, "isRequired", false); pd.ShowTitle = DictionaryHelper.GetValue(dictionary, "showTitle", true); if (dictionary.ContainsKey("validators") == true) { PropertyValidatorDescriptorCollection validators = JSONSerializerExecute.Deserialize <PropertyValidatorDescriptorCollection>(dictionary["validators"]); pd.Validators.Clear(); pd.Validators.CopyFrom(validators); } PropertyValue pv = new PropertyValue(pd); pv.StringValue = DictionaryHelper.GetValue(dictionary, "value", (string)null); return(pv); }
public void Deserialize(XElement node, XmlDeserializeContext context) { object pv = null; int objID = node.Attribute("v", -1); if (context.ObjectContext.TryGetValue(objID, out pv) == true) { this._Definition = ((PropertyValue)pv).Clone().Definition; } else { this._Definition = new PropertyDefine(); this._Definition.Deserialize(node, context); objID = node.Attribute("id", -1); if (objID > -1) { context.ObjectContext.Add(objID, this); } } string sv = node.Attribute("_sv", this._StringValue); if (string.IsNullOrEmpty(sv)) { this._StringValue = this._Definition.DefaultValue; } else { this._StringValue = sv; } }
public virtual PropertyDefine Clone() { PropertyDefine newDefine = new PropertyDefine(); newDefine.Name = this.Name; newDefine.DisplayName = this.DisplayName; newDefine.Category = this.Category; newDefine.DataType = this.DataType; newDefine.DefaultValue = this.DefaultValue; newDefine.Description = this.Description; newDefine.EditorKey = this.EditorKey; newDefine.ReadOnly = this.ReadOnly; newDefine.Visible = this.Visible; newDefine.AllowOverride = this.AllowOverride; newDefine.EditorParamsSettingsKey = this.EditorParamsSettingsKey; newDefine.EditorParams = this.EditorParams; newDefine.PersisterKey = this.PersisterKey; newDefine.SortOrder = this.SortOrder; newDefine.MaxLength = this.MaxLength; newDefine.IsRequired = this.IsRequired; newDefine.ShowTitle = this.ShowTitle; newDefine.Validators.CopyFrom(this.Validators); return(newDefine); }
private static PropertyValue BuildPropertyValue(string name, string category) { PropertyDefine define = new PropertyDefine(); define.Name = name; define.Category = category; define.ReadOnly = true; PropertyValue result = new PropertyValue(define); return(result); }
public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { PropertyDefine pd = new PropertyDefine(); pd.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty); PropertyValue pv = new PropertyValue(pd); pv.StringValue = DictionaryHelper.GetValue(dictionary, "value", (string)null); return(pv); }
/// <summary> /// 校验器的类型信息转换成属性值集合 /// </summary> /// <param name="validatorType"></param> /// <returns></returns> public static PropertyValueCollection ToPropertyValues(this ValidatorTypeConfigurationElement validatorType) { PropertyValueCollection properties = new PropertyValueCollection(); foreach (ValidatorParameterConfigurationElement paramElement in validatorType.Parameters) { PropertyDefine pd = paramElement.ToPropertyDefine(); properties.Add(new PropertyValue(pd)); } return(properties); }
/// <summary> /// 将参数类型信息转换成属性定义 /// </summary> /// <param name="paramElement"></param> /// <returns></returns> public static PropertyDefine ToPropertyDefine(this ValidatorParameterConfigurationElement paramElement) { paramElement.NullCheck("paramElement"); PropertyDefine pd = new PropertyDefine(); pd.Name = paramElement.Name; pd.DisplayName = paramElement.Description; pd.Description = paramElement.Description; pd.DataType = (PropertyDataType)Enum.Parse(typeof(PropertyDataType), paramElement.DataType.ToString(), true); pd.DefaultValue = paramElement.ParamValue; return(pd); }
/// <summary> /// 为通用的序列化而显示实现接口IXElementSerializable /// </summary> /// <param name="node"></param> /// <param name="context"></param> void IXElementSerializable.Deserialize(XElement node, XmlDeserializeContext context) { this._Definition = new PropertyDefine(); this._Definition.Deserialize(node, context); string sv = node.Attribute("_sv", this._StringValue); if (string.IsNullOrEmpty(sv)) { this._StringValue = this._Definition.DefaultValue; } else { this._StringValue = sv; } }
public PropertyValue(PropertyDefine def) { ExceptionHelper.FalseThrow <ArgumentNullException>(def != null, "def"); this._Definition = def; }