public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { EditorParamsDefine paDefine = new EditorParamsDefine(); foreach (KeyValuePair <string, object> item in dictionary) { if (string.Compare(item.Key, "serverControlProperties", true) == 0) { string strServerControlProperties = DictionaryHelper.GetValue(dictionary, "serverControlProperties", string.Empty); if (strServerControlProperties.IsNotEmpty()) { List <ControlPropertyDefine> desControlProperties = JSONSerializerExecute.Deserialize <List <ControlPropertyDefine> >(strServerControlProperties); desControlProperties.ForEach(pcd => { paDefine.ServerControlProperties.Add(pcd); }); } } else { paDefine.Add(item.Key, item.Value != null ? item.Value.ToString() : string.Empty); } } return(paDefine); }
public override void Write(T currentProperty, PersisterContext <T> context) { string value = currentProperty.StringValue; EditorParamsDefine paraDefine = null; if (currentProperty.Definition.EditorParams.IsNotEmpty()) { base.Register(); paraDefine = JSONSerializerExecute.Deserialize <EditorParamsDefine>(currentProperty.Definition.EditorParams); } if (value.IsNotEmpty()) { if (string.Compare(currentProperty.StringValue, currentProperty.Definition.DefaultValue, true) != 0) { if (paraDefine.ContainsKey("TagPropertyName") == true) { currentProperty.StringValue = PwdCalculate("", string.Format("{0},{1}", context.Properties[paraDefine["TagPropertyName"]].StringValue, value)); } else { currentProperty.StringValue = PwdCalculate("", value); } } } }
public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); EditorParamsDefine paDefine = (EditorParamsDefine)obj; foreach (KeyValuePair <string, string> item in paDefine) { if (string.IsNullOrEmpty(item.Value) == false) { dictionary.Add(item.Key, item.Value); } } if (paDefine.ServerControlProperties.Count > 0) { dictionary.Add("serverControlProperties", JSONSerializerExecute.Serialize(paDefine.ServerControlProperties)); } return(dictionary); }