public RecordReader(XElement element, EntityDefinition entity, DocumentSettings settings, IEnumerable <Record> baseRecords = null) : base(element, entity, settings) { BaseRecords = (baseRecords != null) ? new BaseRecordCollection(baseRecords) : Empty.BaseRecordCollection; }
internal static Document Create(XmlReader xmlReader, DocumentSettings settings = null) { if (settings == null) { settings = new DocumentSettings(); } return(new Document(XDocument.Load(xmlReader, settings.LoadOptions), settings)); }
internal static Document Create(Stream stream, DocumentSettings settings = null) { if (settings == null) { settings = new DocumentSettings(); } return(new Document(XDocument.Load(stream, settings.LoadOptions), settings)); }
public EntityElement(XElement element, DocumentSettings settings, EntityDefinition baseEntity = null) { Settings = settings; Scan(element.Elements()); ExtendedKeyedCollection <string, PropertyDefinition> properties = null; ExtendedKeyedCollection <string, Variable> variables = null; if (_declarationsElement != null) { ScanDeclarations(_declarationsElement.Elements(), out properties, out variables); } Entity = new EntityDefinition(element, baseEntity, properties, variables); }
public static RecordCollection ReadRecords(XmlReader xmlReader, DocumentSettings settings = null) { return(Create(xmlReader, settings).Records()); }
public static RecordCollection ReadRecords(Stream stream, DocumentSettings settings = null) { return(Create(stream, settings).Records()); }
public static RecordCollection ReadRecords(string uri, DocumentSettings settings = null) { return(Create(uri, settings).Records()); }
private Document(XDocument document, DocumentSettings settings) { XDocument = document; Settings = settings; }
public static string GetAttributeValue(string value, AbstractRecordReader reader) { DocumentSettings settings = reader.Settings; if (!settings.UseVariables) { return(value); } for (int i = 0; i < value.Length; i++) { if (value[i] == settings.OpenVariableDelimiter) { if (i == value.Length - 1) { Throw.CharacterMustBeEscaped(value, settings.OpenVariableDelimiter); } else if (value[i + 1] == settings.OpenVariableDelimiter) { i++; } else { bool fInside = true; int startIndex = i; int lastEndIndex = 0; i++; var sb = new StringBuilder(); while (i < value.Length) { if (!fInside) { if (value[i] == settings.OpenVariableDelimiter) { fInside = true; startIndex = i; } else if (value[i] == settings.CloseVariableDelimiter) { if (i == value.Length - 1 || value[i + 1] != settings.CloseVariableDelimiter) { Throw.CharacterMustBeEscaped(value, settings.CloseVariableDelimiter); } } } else { if (value[i] == settings.OpenVariableDelimiter) { if (i - startIndex == 1) { fInside = false; startIndex = -1; } else { Throw.VariableNameCannotContainCharacter(value, settings.OpenVariableDelimiter); } } else if (value[i] == settings.CloseVariableDelimiter) { int length = i - startIndex - 1; if (length == 0) { Throw.VariableNameCannotBeEmpty(value); } string variableName = value.Substring(startIndex + 1, length); Variable variable = reader.FindVariable(variableName); if (variable == null) { Throw.VariableIsNotDefined(value, variableName); } sb.Append(value, lastEndIndex, startIndex - lastEndIndex); sb.Append(variable.Value); fInside = false; startIndex = -1; lastEndIndex = i + 1; } } i++; } if (fInside) { Throw.VariableMustBeClosed(value, settings.OpenVariableDelimiter); } if (lastEndIndex > 0) { sb.Append(value, lastEndIndex, value.Length - lastEndIndex); } return(sb.ToString()); } } } return(value); }
public BaseRecordReader(XElement element, EntityDefinition entity, DocumentSettings settings) : base(element, entity, settings) { }
protected AbstractRecordReader(XElement element, EntityDefinition entity, DocumentSettings settings) { Element = element; Entity = entity; Settings = settings; }
public EntityElement(XElement element, DocumentSettings settings) : this(element, settings, baseEntity : null) { }