private static EditorParamsDefine PrepareEditorParamsDefine() { EditorParamsDefine define = new EditorParamsDefine(); //define.EnumTypeName= "MCS.Library.SOA.Web.WebControls.Test.PropertyGrid.EnumValueDefine, MCS.Library.SOA.Web.WebControls.Test"; define.CloneControlID = "ImageUploaderPropertyEditor_ImageUploader"; define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.String, PropertyName = "Width", StringValue = "200" }); define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.Decimal, PropertyName = "ImageWidth", StringValue = "200" }); define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.String, PropertyName = "Height", StringValue = "300" }); define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.String, PropertyName = "ImageHeight", StringValue = "350" }); return(define); }
public void DestTest() { //string joson1 = "{\"cloneControlID\":\"ImageUploaderPropertyEditor_ImageUploader\",\"serverControlProperties\": [{\"propertyName\":\"Width\",\"stringValue\":\"200\"},{\"propertyName\":\"ImageWidth\",\"stringValue\":\"200\"},{\"propertyName\":\"Height\",\"stringValue\":\"300\"},{\"propertyName\":\"ImageHeight\",\"stringValue\":\"350\"}]\"}"; string josn = "{\"cloneControlID\":\"ImageUploaderPropertyEditor_ImageUploader\",\"serverControlProperties\":\"[{\\\"propertyName\\\":\\\"Width\\\",\\\"stringValue\\\":\\\"200\\\"},{\\\"propertyName\\\":\\\"ImageWidth\\\",\\\"stringValue\\\":\\\"200\\\"},{\\\"propertyName\\\":\\\"Height\\\",\\\"stringValue\\\":\\\"300\\\"},{\\\"propertyName\\\":\\\"ImageHeight\\\",\\\"stringValue\\\":\\\"350\\\"}]\"}"; //string jsonTest = "{\"cloneControlID\":\"ImageUploaderPropertyEditor_ImageUploader\",\"serverControlProperties\": \"[{\"propertyName\":\"ImageWidth\",\"stringValue\":\"200\"}]\"}"; EditorParamsDefine deserializedEpd = JSONSerializerExecute.Deserialize <EditorParamsDefine>(josn); }
public virtual void SetControlsPropertyDefineFromEditorParams(PropertyDefine propertyDefine) { var editorParams = ""; if (string.IsNullOrEmpty(propertyDefine.EditorParamsSettingsKey) == false) { var curSettings = PropertyEditorParamsSettings.GetConfig().EditorParams[propertyDefine.EditorParamsSettingsKey]; if (curSettings == null) { throw new System.Configuration.ConfigurationErrorsException(string.Format("找不到Name为{0}的EditorParamsSettings", propertyDefine.EditorParamsSettingsKey)); } editorParams = curSettings.EditorParamsValue.ValueText; } else if (string.IsNullOrEmpty(propertyDefine.EditorParams) && Regex.IsMatch(propertyDefine.EditorParams, @"\{[^{}]*}") == true) { editorParams = propertyDefine.EditorParams; } if (string.IsNullOrEmpty(editorParams) == false) { EditorParamsDefine paraDefine = JSONSerializerExecute.Deserialize <EditorParamsDefine>(editorParams); if (paraDefine.ServerControlProperties.Count > 0) { if (string.IsNullOrEmpty(paraDefine.CloneControlID)) { paraDefine.CloneControlID = this.DefaultCloneControlName(); } if (this.IsCloneControlEditor) { if (this.ControlsPropertyDefine.ContainsKey(paraDefine.CloneControlID)) { this.ControlsPropertyDefine[paraDefine.CloneControlID].ControlPropertyDefineList = paraDefine.ServerControlProperties; this.ControlsPropertyDefine[paraDefine.CloneControlID].ExtendedSettings = paraDefine.ExtendedSettings; this.ControlsPropertyDefine[paraDefine.CloneControlID].UseTemplate = paraDefine.UseTemplate; } else { this.ControlsPropertyDefine.Add(new ControlPropertyDefineWrapper() { ControlID = paraDefine.CloneControlID, ControlPropertyDefineList = paraDefine.ServerControlProperties, ExtendedSettings = paraDefine.ExtendedSettings, UseTemplate = paraDefine.UseTemplate }); } } } if (string.IsNullOrEmpty(paraDefine.ExtendedSettings) == false) { paraDefine.ExtendedSettings = null; propertyDefine.EditorParams = JSONSerializerExecute.Serialize(paraDefine); } } }
private static EditorParamsDefine PrepareEditorParamsDefine() { EditorParamsDefine define = new EditorParamsDefine(); //define.EnumTypeName= "MCS.Library.SOA.Web.WebControls.Test.PropertyGrid.EnumValueDefine, MCS.Library.SOA.Web.WebControls.Test"; define.CloneControlID = "ImageUploaderPropertyEditor_ImageUploader"; define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.String, PropertyName = "Width", StringValue = "200" }); define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.Decimal, PropertyName = "ImageWidth", StringValue = "200" }); define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.String, PropertyName = "Height", StringValue = "300" }); define.ServerControlProperties.Add(new ControlPropertyDefine() { DataType = PropertyDataType.String, PropertyName = "ImageHeight", StringValue = "350" }); return define; }
public void EditorParamsDefineJSONSerializerTest() { RegisterConverter(); EditorParamsDefine epd = PrepareEditorParamsDefine(); string result = JSONSerializerExecute.Serialize(epd); Console.WriteLine(result); EditorParamsDefine deserializedEpd = JSONSerializerExecute.Deserialize <EditorParamsDefine>(result); string reSerialized = JSONSerializerExecute.Serialize(deserializedEpd); Assert.AreEqual(result, reSerialized); }
private List <EnumTypePropertyDescription> CollectEnumDescriptions() { Dictionary <string, EnumTypePropertyDescription> enumDespDict = new Dictionary <string, EnumTypePropertyDescription>(); foreach (string enumParams in PredefinedEnumTypes) { EnumTypePropertyDescription etpd = EnumTypePropertyDescription.FromEnumTypeName(enumParams); if (etpd != null) { enumDespDict.Add(etpd.EnumTypeName, etpd); } } foreach (PropertyValue pv in this.Properties) { if (pv.Definition.DataType == PropertyDataType.Enum && string.IsNullOrEmpty(pv.Definition.EditorParams) == false) { string editorParamName = pv.Definition.EditorParams; if (Regex.IsMatch(pv.Definition.EditorParams, @"\{[^{}]*}") == true) { try { EditorParamsDefine editorParams = JSONSerializerExecute.Deserialize <EditorParamsDefine>(pv.Definition.EditorParams); editorParamName = editorParams.EnumTypeName; //将配置文件里的数据源转换成下拉列表数据源 if (editorParams.ContainsKey("dropDownDataSourceID") == true) { string sourceID = editorParams["dropDownDataSourceID"]; if (PropertyEditorHelper.AllDropdownPropertyDataSource.ContainsKey(sourceID) == true) { EnumTypePropertyDescription etpd = PropertyEditorHelper.GenerateEnumTypePropertyDescription(PropertyEditorHelper.AllDropdownPropertyDataSource[sourceID]); if (etpd != null) { enumDespDict.Add(etpd.EnumTypeName, etpd); } } } } catch (Exception) { //这里吃掉异常,主要原因是兼容老已上线的流程配置文件 editorParamName = pv.Definition.EditorParams; } } if (string.IsNullOrEmpty(editorParamName) == false) { if (enumDespDict.ContainsKey(editorParamName) == false) { EnumTypePropertyDescription etpd = EnumTypePropertyDescription.FromEnumTypeName(editorParamName); if (etpd != null) { enumDespDict.Add(etpd.EnumTypeName, etpd); } } } } } List <EnumTypePropertyDescription> result = new List <EnumTypePropertyDescription>(); foreach (KeyValuePair <string, EnumTypePropertyDescription> kp in enumDespDict) { result.Add(kp.Value); } return(result); }