/// <summary> /// Parses a property definition /// </summary> /// <param name="n">XmlElement for the property definition obtained from the Mingle API</param> public void Parse(XElement propertyXml) { string me = new StackFrame().GetMethod().Name; TraceLog.WriteLine(me, "Entering..."); foreach (XElement e in propertyXml.Elements()) { // TraceLog.WriteLine(me,string.Format("<{0}>{1}", e.Name, e.InnerText)); switch (e.Name.LocalName) { case "id": Id = Convert.ToInt32(e.Value); break; case "name": Name = e.Value; break; case "description": Description = e.Value; break; case "data_type": DataType = e.Value; break; case "is_numeric": IsNumeric = Convert.ToBoolean(e.Value); break; case "hidden": Hidden = Convert.ToBoolean(e.Value); break; case "restricted": Restricted = Convert.ToBoolean(e.Value); break; case "transition_only": IsTransitionOnly = Convert.ToBoolean(e.Value); break; case "project": foreach (XmlNode child in e.ChildNodes) { if (child.Name == "identifier") { ProjectId = e.InnerText; } if (child.Name == "name") { ProjectName = e.InnerText; } } break; case "column_name": ColumnName = e.Value; break; case "position": if (!string.IsNullOrEmpty(e.Value)) { Position = Convert.ToInt32(e.Value); } break; case "property_values_description": PropertyValuesDescription = e.Value; break; case "card_types": foreach (XmlNode cardTypeNode in e.ChildNodes) { if (cardTypeNode.Name == "card_type") { foreach (XmlNode nameNode in cardTypeNode) { if (nameNode.Name == "name") { CardTypes.Add(nameNode.InnerText); } } } } break; case "property_value_details": foreach (XElement propertyValue in e.Elements()) { try { var pv = new MinglePropertyValue(); // TraceLog.WriteLine(new StackFrame().GetMethod().Name, "Parsing property_value"); pv.Parse(propertyValue); PropertyValueDetails.Add(pv); // TraceLog.WriteLine(new StackFrame().GetMethod().Name, string.Format("Parsed property_value {0}", pv.Id)); } catch (XmlException ex) { TraceLog.Exception(new StackFrame().GetMethod().Name, ex); throw; } catch (ArgumentException ex) { TraceLog.Exception(new StackFrame().GetMethod().Name, ex); throw; } } break; default: break; } } TraceLog.WriteLine(me, "Leaving..."); }
/// <summary> /// Parses a property definition /// </summary> /// <param name="n">XmlElement for the property definition obtained from the Mingle API</param> public void Parse(XElement propertyXml) { string me = new StackFrame().GetMethod().Name; TraceLog.WriteLine(me, "Entering..."); foreach (XElement e in propertyXml.Elements()) { // TraceLog.WriteLine(me,string.Format("<{0}>{1}", e.Name, e.InnerText)); switch (e.Name.LocalName) { case "id": Id = Convert.ToInt32(e.Value); break; case "name": Name = e.Value; break; case "description": Description = e.Value; break; case "data_type": DataType = e.Value; break; case "is_numeric": IsNumeric = Convert.ToBoolean(e.Value); break; case "hidden": Hidden = Convert.ToBoolean(e.Value); break; case "restricted": Restricted = Convert.ToBoolean(e.Value); break; case "transition_only": IsTransitionOnly = Convert.ToBoolean(e.Value); break; case "project": foreach (XmlNode child in e.ChildNodes) { if (child.Name == "identifier") ProjectId = e.InnerText; if (child.Name == "name") ProjectName = e.InnerText; } break; case "column_name": ColumnName = e.Value; break; case "position": if (!string.IsNullOrEmpty(e.Value)) Position = Convert.ToInt32(e.Value); break; case "property_values_description": PropertyValuesDescription = e.Value; break; case "card_types": foreach (XmlNode cardTypeNode in e.ChildNodes) if (cardTypeNode.Name == "card_type") foreach (XmlNode nameNode in cardTypeNode) if (nameNode.Name == "name") CardTypes.Add(nameNode.InnerText); break; case "property_value_details": foreach (XElement propertyValue in e.Elements()) { try { var pv = new MinglePropertyValue(); // TraceLog.WriteLine(new StackFrame().GetMethod().Name, "Parsing property_value"); pv.Parse(propertyValue); PropertyValueDetails.Add(pv); // TraceLog.WriteLine(new StackFrame().GetMethod().Name, string.Format("Parsed property_value {0}", pv.Id)); } catch (XmlException ex) { TraceLog.Exception(new StackFrame().GetMethod().Name, ex); throw; } catch (ArgumentException ex) { TraceLog.Exception(new StackFrame().GetMethod().Name, ex); throw; } } break; default: break; } } TraceLog.WriteLine(me, "Leaving..."); }