Example #1
0
        public Pair CreateMappedPair(ICharStream input, int nameQuotesType, Interval nameInterval, DelimiterEnum delimiter,
                                     Interval delimiterInterval, int valueQuotesType, Interval valueInterval, int valueIndent)
        {
            Pair pair;
            var  name  = PairFactoryForXml.GetNameText(input, nameQuotesType, nameInterval);
            var  value = PairFactoryForXml.GetValue(input, delimiter, valueQuotesType, valueInterval,
                                                    valueIndent, _context, (Module)_module);

            if (nameQuotesType > 0)
            {
                if (delimiter == DelimiterEnum.None)
                {
                    value = PairFactoryForXml.GetValue(input, delimiter, nameQuotesType, nameInterval,
                                                       0, _context, (Module)_module);
                    valueQuotesType = nameQuotesType;
                }
                pair = new Element
                {
                    Name               = name,
                    NameQuotesType     = nameQuotesType,
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };

                SetValueType((Element)pair, delimiter, value.Item1, valueQuotesType);
            }
            else if (name.StartsWith("@"))
            {
                pair = new DOM.Mapped.Attribute()
                {
                    Name               = name.Substring(1),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!$"))
            {
                pair = new DOM.Mapped.AliasDefinition
                {
                    Name               = VerifyName(name.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!#"))
            {
                pair = new DOM.Mapped.NamespaceDefinition
                {
                    Name               = VerifyNsName(name.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!%"))
            {
                pair = new DOM.Mapped.Parameter
                {
                    Name               = VerifyNsName(name.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!"))
            {
                pair = new DOM.Mapped.Document
                {
                    Name               = VerifyName(name.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("$"))
            {
                pair = new DOM.Mapped.Alias()
                {
                    Name               = VerifyName(name.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("%"))
            {
                pair = new DOM.Mapped.Argument()
                {
                    Name               = VerifyName(name.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };

                SetValueType((IMappedPair)pair, delimiter, value.Item1, valueQuotesType);
            }
            else if (name.StartsWith("#"))
            {
                pair = new DOM.Mapped.Scope
                {
                    NsPrefix          = VerifyScopeName(name.Substring(1), nameInterval, _module),
                    NameInterval      = nameInterval,
                    Delimiter         = delimiter,
                    DelimiterInterval = delimiterInterval
                };
                SetValueType((IMappedPair)pair, delimiter, value.Item1, valueQuotesType);
            }
            else
            {
                pair = new Element
                {
                    Name               = name,
                    NameQuotesType     = nameQuotesType,
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
                if (delimiter == DelimiterEnum.None)
                {
                    value = PairFactoryForXml.GetValue(input, delimiter, nameQuotesType, nameInterval,
                                                       0, _context, (Module)_module);
                    valueQuotesType = nameQuotesType;
                }
            }
            SetValueType((IMappedPair)pair, delimiter, value.Item1, valueQuotesType);
            return(pair);
        }
Example #2
0
        /// <inheritdoc />
        public Pair CreateMappedPair(ITextSource textSource, int nameQuotesType, Interval nameInterval, AssignmentEnum assignment,
                                     Interval assignmentInterval, int valueQuotesType, Interval valueInterval, int valueIndent)
        {
            Pair pair;
            var  name  = PairFactoryForXml.GetNameText(textSource, nameQuotesType, nameInterval);
            var  value = PairFactoryForXml.GetValue(textSource, assignment, valueQuotesType, valueInterval,
                                                    valueIndent, _context, (Module)_module);

            if (nameQuotesType > 0)
            {
                if (assignment == AssignmentEnum.None)
                {
                    value = PairFactoryForXml.GetValue(textSource, assignment, nameQuotesType, nameInterval,
                                                       0, _context, (Module)_module);
                    valueQuotesType = nameQuotesType;
                }
                pair = new Element(
                    name,
                    nameQuotesType: nameQuotesType,
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                    );
            }
            else if (name.StartsWith("@"))
            {
                pair = new DOM.Mapped.Attribute(
                    name.Substring(1),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                    );
            }
            else if (name.StartsWith("!$"))
            {
                pair = new DOM.Mapped.AliasDefinition
                       (
                    VerifyName(name.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("!#"))
            {
                pair = new DOM.Mapped.NamespaceDefinition
                       (
                    VerifyNsName(name.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("!%"))
            {
                pair = new DOM.Mapped.Parameter
                       (
                    VerifyNsName(name.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("!"))
            {
                pair = new DOM.Mapped.Document
                       (
                    VerifyName(name.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("$"))
            {
                pair = new DOM.Mapped.Alias
                       (
                    VerifyName(name.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("%"))
            {
                pair = new DOM.Mapped.Argument
                       (
                    VerifyName(name.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            //else if (name.StartsWith("#"))
            //{
            //    pair = new DOM.Mapped.Scope
            //    {
            //        NsPrefix = VerifyScopeName(name.Substring(1), nameInterval, _module),
            //        NameInterval = nameInterval,
            //        Assignment = assignment,
            //        AssignmentInterval = assignmentInterval
            //    };
            //    SetValueType((IMappedPair) pair, assignment, value.Item1, valueQuotesType);
            //}
            else
            {
                pair = new Element
                       (
                    name,
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment,
                                            (assignment == AssignmentEnum.None? PairFactoryForXml.GetValue(textSource, assignment, nameQuotesType, nameInterval,
                                                                                                           0, _context, (Module)_module).Item1:value.Item1),
                                            assignment == AssignmentEnum.None ? nameQuotesType: valueQuotesType)
                       );
            }

            return(pair);
        }