예제 #1
0
        private void Load(IParser parser, DocumentLoadingState state)
        {
            MappingStart mappingStart = parser.Expect <MappingStart>();

            Load(mappingStart, state);
            Style = mappingStart.Style;
            bool flag = false;

            while (!parser.Accept <MappingEnd>())
            {
                YamlNode yamlNode  = YamlNode.ParseNode(parser, state);
                YamlNode yamlNode2 = YamlNode.ParseNode(parser, state);
                try
                {
                    children.Add(yamlNode, yamlNode2);
                }
                catch (ArgumentException innerException)
                {
                    throw new YamlException(yamlNode.Start, yamlNode.End, "Duplicate key", innerException);
                }
                flag |= (yamlNode is YamlAliasNode || yamlNode2 is YamlAliasNode);
            }
            if (flag)
            {
                state.AddNodeWithUnresolvedAliases(this);
            }
            parser.Expect <MappingEnd>();
        }
예제 #2
0
        private void Load(IParser parser, DocumentLoadingState state)
        {
            var mapping = parser.Consume <MappingStart>();

            Load(mapping, state);
            Style = mapping.Style;

            bool hasUnresolvedAliases = false;

            while (!parser.TryConsume <MappingEnd>(out var _))
            {
                var key   = ParseNode(parser, state);
                var value = ParseNode(parser, state);

                try
                {
                    children.Add(key, value);
                }
                catch (ArgumentException err)
                {
                    throw new YamlException(key.Start, key.End, "Duplicate key", err);
                }

                hasUnresolvedAliases |= key is YamlAliasNode || value is YamlAliasNode;
            }

            if (hasUnresolvedAliases)
            {
                state.AddNodeWithUnresolvedAliases(this);
            }
        }
예제 #3
0
        private void Load(IParser parser, DocumentLoadingState state)
        {
            var mapping = parser.Expect <MappingStart>();

            Load(mapping, state);
            Style = mapping.Style;

            bool hasUnresolvedAliases = false;

            while (!parser.Accept <MappingEnd>())
            {
                var key   = ParseNode(parser, state);
                var value = ParseNode(parser, state);

                try
                {
                    children.Add(key, value);
                }
                catch (ArgumentException err)
                {
                    throw new YamlException(key.Start, key.End, "Duplicate key", err);
                }

                hasUnresolvedAliases |= key is YamlAliasNode || value is YamlAliasNode;
            }

            if (hasUnresolvedAliases)
            {
                state.AddNodeWithUnresolvedAliases(this);
            }
#if DEBUG
            else
            {
                foreach (var child in children)
                {
                    if (child.Key is YamlAliasNode)
                    {
                        throw new InvalidOperationException("Error in alias resolution.");
                    }
                    if (child.Value is YamlAliasNode)
                    {
                        throw new InvalidOperationException("Error in alias resolution.");
                    }
                }
            }
#endif

            parser.Expect <MappingEnd>();
        }
예제 #4
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MappingStart"/> class.
		/// </summary>
		/// <param name="anchor">The anchor.</param>
		/// <param name="tag">The tag.</param>
		/// <param name="isImplicit">Indicates whether the event is implicit.</param>
		/// <param name="style">The style of the mapping.</param>
		/// <param name="start">The start position of the event.</param>
		/// <param name="end">The end position of the event.</param>
		public MappingStart(string anchor, string tag, bool isImplicit, MappingStyle style, Mark start, Mark end)
			: base(anchor, tag, start, end)
		{
			this.isImplicit = isImplicit;
			this.style = style;
		}
예제 #5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MappingStart"/> class.
		/// </summary>
		/// <param name="anchor">The anchor.</param>
		/// <param name="tag">The tag.</param>
		/// <param name="isImplicit">Indicates whether the event is implicit.</param>
		/// <param name="style">The style of the mapping.</param>
		public MappingStart(string anchor, string tag, bool isImplicit, MappingStyle style)
			: this(anchor, tag, isImplicit, style, Mark.Empty, Mark.Empty)
		{
		}
예제 #6
0
			public MappingStartBuilder(MappingStyle style)
			{
				this.style = style;
				@implicit = DefaultImplicit;
			}
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MappingStart"/> class.
 /// </summary>
 /// <param name="anchor">The anchor.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="style">The style of the mapping.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public MappingStart(string anchor, string tag, bool isImplicit, MappingStyle style, Mark start, Mark end)
     : base(anchor, tag, start, end)
 {
     this.isImplicit = isImplicit;
     this.style      = style;
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MappingStart"/> class.
 /// </summary>
 /// <param name="anchor">The anchor.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="style">The style of the mapping.</param>
 public MappingStart(string anchor, string tag, bool isImplicit, MappingStyle style)
     : this(anchor, tag, isImplicit, style, Mark.Empty, Mark.Empty)
 {
 }
예제 #9
0
 public YAMLMappingNode(MappingStyle style)
 {
     Style = style;
 }
예제 #10
0
 public MappingStartBuilder(MappingStyle style)
 {
     this.style = style;
     @implicit  = DefaultImplicit;
 }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MappingStart"/> class.
 /// </summary>
 /// <param name="anchor">The anchor.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="style">The style of the mapping.</param>
 public MappingStart(AnchorName anchor, TagName tag, bool isImplicit, MappingStyle style)
     : this(anchor, tag, isImplicit, style, Mark.Empty, Mark.Empty)
 {
 }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MappingStart"/> class.
 /// </summary>
 /// <param name="anchor">The anchor.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="style">The style of the mapping.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public MappingStart(AnchorName anchor, TagName tag, bool isImplicit, MappingStyle style, Mark start, Mark end)
     : base(anchor, tag, start, end)
 {
     this.IsImplicit = isImplicit;
     this.Style      = style;
 }