private static IEnumerable <MessageField> GetMessageFields(XElement xElement) { IEnumerable <XElement> elements = xElement.Elements(); IList <Xml.MessageField> messageFields = new List <MessageField>(); Int32 index = 0; bool isExtension = false; foreach (XElement e in elements) { if (e.Name.LocalName.Equals("field")) { Xml.MessageField dMessageField = ToField(e, index, isExtension); messageFields.Add(dMessageField); index++; } if (e.Name.LocalName.Equals("extensions")) { isExtension = true; } } return(messageFields); }
private string GetName(Xml.MessageField xMessageField) { if (_messageFieldNameTransformation == null) { return(xMessageField.Name); } return(_messageFieldNameTransformation.Transform(xMessageField)); }
private Data.MessageField ToModel(Xml.MessageField xMessageField, Int32 definitionIndex) { Data.MessageField dMessageField = new Data.MessageField(); dMessageField.XmlDefinition = xMessageField; dMessageField.DefinitionIndex = definitionIndex; dMessageField.Type = GetFieldType(xMessageField); dMessageField.Name = GetName(xMessageField); dMessageField.Units = xMessageField.Units; dMessageField.Display = StringHelper.TrimAndNormalizeCarriageReturn(xMessageField.Display); dMessageField.Text = StringHelper.TrimAndNormalizeCarriageReturn(xMessageField.Text); return(dMessageField); }
private static Xml.MessageField ToField(XElement xElement, Int32 index, bool isExtension) { Xml.MessageField messageField = new Xml.MessageField(); messageField.Index = index; messageField.Type = xElement.Attribute("type").Value; messageField.Name = xElement.Attribute("name").Value; messageField.Enum = xElement.Attribute("enum")?.Value; messageField.Units = xElement.Attribute("units")?.Value; messageField.Display = xElement.Attribute("display")?.Value; messageField.Text = xElement.Value; messageField.IsExtension = isExtension; return(messageField); }
private Data.MessageFieldType GetFieldType(Xml.MessageField xMessageField) { MessageFieldDataType dataType = TypeHelper.ToDataType(xMessageField.Type); int typeLength = TypeHelper.GetTypeLength(dataType); bool isArray = TypeHelper.IsArray(xMessageField.Type); if (isArray) { Int32 arrayLength = TypeHelper.GetArraySize(xMessageField.Type); return(new Data.MessageFieldType(dataType, typeLength, arrayLength)); } bool isNotNullEnum = !String.IsNullOrWhiteSpace(xMessageField.Enum); if (isNotNullEnum) { Data.Enum vEnum = _enumByXmlEnumName[xMessageField.Enum]; return(new Data.MessageFieldType(dataType, typeLength, vEnum)); } return(new Data.MessageFieldType(dataType, typeLength)); }