public DataMap ToDataMap(string forms) { NameValueCollection kv = Parse(forms); DataMap map = new DataMap(); Dictionary <string, DataMapField> dict = new Dictionary <string, DataMapField>(); for (int i = 0; i < kv.Count; i++) { var key = kv.Keys[i]; var dim = key.Substring(0, key.IndexOf(".")); var _token = key.Substring(key.IndexOf(".") + 1); DataMapField field = null; if (dict.ContainsKey(dim)) { field = dict[dim]; } else { field = CreateDataMapField(_token, kv[key]); dict.Add(dim, field); } field.AddAttribute(_token, kv[i]); } foreach (var o in dict.Values) { map.Fields.Add(o); } return(map); }
private bool Contain(DataMapField field) { foreach (var o in Fields) { if (o.DisplayName == field.DisplayName) { return(true); } } return(false); }
private void FieldMerge(IMapAttribute map, DataMapField newField) { foreach (var o in Fields) { if (o.DisplayName == newField.DisplayName) { if (!string.IsNullOrEmpty(newField.Value)) { o.Value = newField.Value; } } } }
private DataMapField CreateDataMapField(string key, string value) { DataMapField field = null; if (key != "cssClass") { return(null); } switch (value) { case "input_text": field = new InputDataMapField(); break; case "checkbox": field = new CheckBoxDataMapField(); break; case "select": field = new SelectDataMapField(); break; case "radio": field = new RadioDataMapField(); break; case "textarea": field = new TextAreaDataMapField(); break; case "input_file": field = new FileInputDataMapField(); break; default: break; } return(field); }
static private DataMapField GetDataMapField(JsonDataMapField o) { string type = o.CssClass; DataMapField p = null; if (type == "input_text") { p = new InputDataMapField(); } else if (type == "checkbox") { p = new CheckBoxDataMapField(); ((CheckBoxDataMapField)p).Options.AddRange(o.Options); } else if (type == "select") { p = new SelectDataMapField(); ((SelectDataMapField)p).Options.AddRange(o.Options); } else if (type == "radio") { p = new RadioDataMapField(); ((RadioDataMapField)p).Options.AddRange(o.Options); } else if (type == "textarea") { p = new TextAreaDataMapField(); } else { p = new DataMapField(); } p.CssClass = o.CssClass; p.Value = o.Value; p.Required = o.Required; p.DisplayName = o.DisplayName; return(p); }