/// <summary> /// Parses OrderCustomPropertiesInfo. /// </summary> public static OrderCustomPropertiesInfo ParseOrderCustomPropertiesInfo(string xml) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); OrderCustomPropertiesInfo info = null; XmlNode root = xmlDoc.SelectSingleNode(NODE_ORDERCUSTOMPROP); if (root != null) { info = new OrderCustomPropertiesInfo(); foreach (XmlNode node in root.ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; // skip comments and other non element nodes } if (node.Name.Equals(NODE_PROPERTY, StringComparison.OrdinalIgnoreCase)) { XmlAttributeCollection attributes = node.Attributes; string name = attributes[ATTR_NAME].Value; string description = null; if (null != attributes[ATTR_DESCRIPTION]) { description = attributes[ATTR_DESCRIPTION].Value; } int length = int.Parse(attributes[ATTR_MAXLENGTH].Value); OrderCustomPropertyType type = OrderCustomPropertyType.Text; // NOTE: for default used text XmlAttribute typeAttribute = attributes[ATTR_TYPE]; if (null != typeAttribute) { type = (OrderCustomPropertyType)Enum.Parse(typeof(OrderCustomPropertyType), typeAttribute.Value); } bool orderPairKey = false; // default XmlAttribute orderPairKeyAttribute = attributes[ATTR_ORDERPAIRKEY]; if (null != orderPairKeyAttribute) { orderPairKey = bool.Parse(orderPairKeyAttribute.Value); } info.Add(new OrderCustomProperty(name, type, length, description, orderPairKey)); } else { throw new FormatException(); } } } else { throw new FormatException(); } return(info); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates a new instance of the <c>OrderCustomProperty</c> class. /// </summary> public OrderCustomProperty(string name, OrderCustomPropertyType type, int length, string description, Boolean orderPairKey) { _name = name; _type = type; _length = ((OrderCustomPropertyType.Numeric == type) && (length <= 0)) ? NUMERIC_DEFAULT_LENGTH : length; _description = description; _orderPairKey = orderPairKey; }