Esempio n. 1
0
 public RecordReader(XElement element, EntityDefinition entity, DocumentSettings settings, IEnumerable <Record> baseRecords = null)
     : base(element, entity, settings)
 {
     BaseRecords = (baseRecords != null)
         ? new BaseRecordCollection(baseRecords)
         : Empty.BaseRecordCollection;
 }
Esempio n. 2
0
        internal static Document Create(XmlReader xmlReader, DocumentSettings settings = null)
        {
            if (settings == null)
            {
                settings = new DocumentSettings();
            }

            return(new Document(XDocument.Load(xmlReader, settings.LoadOptions), settings));
        }
Esempio n. 3
0
        internal static Document Create(Stream stream, DocumentSettings settings = null)
        {
            if (settings == null)
            {
                settings = new DocumentSettings();
            }

            return(new Document(XDocument.Load(stream, settings.LoadOptions), settings));
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public static RecordCollection ReadRecords(XmlReader xmlReader, DocumentSettings settings = null)
 {
     return(Create(xmlReader, settings).Records());
 }
Esempio n. 6
0
 public static RecordCollection ReadRecords(Stream stream, DocumentSettings settings = null)
 {
     return(Create(stream, settings).Records());
 }
Esempio n. 7
0
 public static RecordCollection ReadRecords(string uri, DocumentSettings settings = null)
 {
     return(Create(uri, settings).Records());
 }
Esempio n. 8
0
 private Document(XDocument document, DocumentSettings settings)
 {
     XDocument = document;
     Settings  = settings;
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 public BaseRecordReader(XElement element, EntityDefinition entity, DocumentSettings settings)
     : base(element, entity, settings)
 {
 }
Esempio n. 11
0
 protected AbstractRecordReader(XElement element, EntityDefinition entity, DocumentSettings settings)
 {
     Element  = element;
     Entity   = entity;
     Settings = settings;
 }
Esempio n. 12
0
 public EntityElement(XElement element, DocumentSettings settings)
     : this(element, settings, baseEntity : null)
 {
 }