private string ParseDescription(FormBase _baseForm) { string result = string.Empty; string key = "Description"; if (_baseForm.ContainsKey(key)) { SimpleList <string> _list = (SimpleList <string>)_baseForm[key]; string[] list = _list.ToArray(); foreach (string line in list) { result += line + "\r\n\t"; } result = result.Substring(0, result.Length - 3); } if (specDef.ContainsKey(key)) { specDef.Remove(key); } return(result); }
private ViewMap ParseView(FormBase _baseForm, string field) { ViewMap view = new ViewMap(); if (_baseForm.ContainsKey(field)) { SimpleList <string> _list = (SimpleList <string>)_baseForm[field]; string[] list = _list.ToArray(); foreach (string line in list) { view.Add(line); } } else { view = null; } if (specDef.ContainsKey(field)) { specDef.Remove(field); } return(view); }
/// <summary> /// Parse the fields from a branch specification /// </summary> /// <param name="spec">Text of the branch specification in server format</param> /// <returns></returns> public bool Parse(String spec) { _baseForm = new FormBase(); _baseForm.Parse(spec); // parse the values into the underlying dictionary if (_baseForm.ContainsKey("Branch")) { Id = _baseForm["Branch"] as string; } if (_baseForm.ContainsKey("Owner")) { if (_baseForm["Owner"] is string) { Owner = _baseForm["Owner"] as string; } if (_baseForm["Owner"] is IList <string> ) { IList <string> strList = _baseForm["Owner"] as IList <string>; Owner = string.Empty; for (int idx = 0; idx < strList.Count; idx++) { if (idx > 0) { Owner += "\r\n"; } Owner += strList[idx]; } } if (_baseForm["Owner"] is SimpleList <string> ) { SimpleList <string> strList = _baseForm["Owner"] as SimpleList <string>; Owner = string.Empty; SimpleListItem <string> current = strList.Head; bool addCRLF = false; while (current != null) { if (addCRLF) { Owner += "\r\n"; } else { addCRLF = true; } Owner += current.Item; current = current.Next; } } } if (_baseForm.ContainsKey("Update")) { DateTime v = DateTime.MinValue; DateTime.TryParse(_baseForm["Update"] as string, out v); Updated = v; } if (_baseForm.ContainsKey("Access")) { DateTime v = DateTime.MinValue; DateTime.TryParse(_baseForm["Access"] as string, out v); Accessed = v; } if (_baseForm.ContainsKey("Description")) { if (_baseForm["Description"] is string) { Description = _baseForm["Description"] as string; } if (_baseForm["Description"] is IList <string> ) { IList <string> strList = _baseForm["Description"] as IList <string>; Description = string.Empty; for (int idx = 0; idx < strList.Count; idx++) { if (idx > 0) { Description += "\r\n"; } Description += strList[idx]; } } if (_baseForm["Description"] is SimpleList <string> ) { SimpleList <string> strList = _baseForm["Description"] as SimpleList <string>; Description = string.Empty; SimpleListItem <string> current = strList.Head; bool addCRLF = false; while (current != null) { if (addCRLF) { Description += "\r\n"; } else { addCRLF = true; } Description += current.Item; current = current.Next; } } } if (_baseForm.ContainsKey("Options")) { #pragma warning disable 618 Options = _baseForm["Options"] as string; #pragma warning restore 618 } if (_baseForm.ContainsKey("View")) { if (_baseForm["View"] is IList <string> ) { IList <string> lines = _baseForm["View"] as IList <string>; ViewMap = new ViewMap(lines.ToArray()); } else if (_baseForm["View"] is SimpleList <string> ) { SimpleList <string> lines = _baseForm["View"] as SimpleList <string>; ViewMap = new ViewMap(lines.ToArray()); } } return(true); }
/// <summary> /// Parse the fields from a label specification /// </summary> /// <param name="spec">Text of the label specification in server format</param> /// <returns></returns> public bool Parse(String spec) { _baseForm = new FormBase(); _baseForm.Parse(spec); // parse the values into the underlying dictionary if (_baseForm.ContainsKey("Label")) { Id = _baseForm["Label"] as string; } if (_baseForm.ContainsKey("Owner")) { Owner = _baseForm["Owner"] as string; } if (_baseForm.ContainsKey("Update")) { DateTime v = DateTime.MinValue; DateTime.TryParse(_baseForm["Update"] as string, out v); Update = v; } if (_baseForm.ContainsKey("Access")) { DateTime v = DateTime.MinValue; DateTime.TryParse(_baseForm["Access"] as string, out v); Access = v; } if (_baseForm.ContainsKey("Description")) { object d = _baseForm["Description"]; if (d is string) { Description = _baseForm["Description"] as string; } else if (d is string[]) { string[] a = d as string[]; Description = string.Empty; for (int idx = 0; idx < a.Length; idx++) { if (idx > 0) { Description += "\r\n"; } Description += a[idx]; } } else if (d is IList <string> ) { IList <string> l = d as IList <string>; Description = string.Empty; for (int idx = 0; idx < l.Count; idx++) { if (idx > 0) { Description += "\r\n"; } Description += l[idx]; } } else if (d is SimpleList <string> ) { SimpleList <string> l = d as SimpleList <string>; Description = string.Empty; SimpleListItem <string> current = l.Head; bool addCRLF = false; while (current != null) { if (addCRLF) { Description += "\r\n"; } else { addCRLF = true; } Description += current.Item; current = current.Next; } } } if (_baseForm.ContainsKey("Options")) { #pragma warning disable 618 Options = _baseForm["Options"] as string; #pragma warning restore 618 } if (_baseForm.ContainsKey("Revision")) { Revision = _baseForm["Revision"] as string; } if (_baseForm.ContainsKey("ServerID")) { Revision = _baseForm["ServerID"] as string; } if (_baseForm.ContainsKey("View")) { if (_baseForm["View"] is IList <string> ) { IList <string> lines = _baseForm["View"] as IList <string>; ViewMap = new ViewMap(lines.ToArray()); } if (_baseForm["View"] is SimpleList <string> ) { SimpleList <string> lines = _baseForm["View"] as SimpleList <string>; ViewMap = new ViewMap(lines.ToArray()); } } return(true); }