当前位置: 首页>>代码示例>>C#>>正文


C# Events.ParsingEvent类代码示例

本文整理汇总了C#中YamlDotNet.Core.Events.ParsingEvent的典型用法代码示例。如果您正苦于以下问题:C# ParsingEvent类的具体用法?C# ParsingEvent怎么用?C# ParsingEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParsingEvent类属于YamlDotNet.Core.Events命名空间,在下文中一共展示了ParsingEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Wrap

		private IEnumerable<ParsingEvent> Wrap(IEnumerable<ParsingEvent> events, ParsingEvent start, ParsingEvent end)
		{
			yield return start;
			foreach (var @event in events)
			{
				yield return @event;
			}
			yield return end;
		}
开发者ID:Gwynneth,项目名称:YamlDotNet,代码行数:9,代码来源:EmitterTestsHelper.cs

示例2: ACommentAsTheFirstEventAddsANewLine

        public void ACommentAsTheFirstEventAddsANewLine()
        {
            var events = new ParsingEvent[]
            {
                StandaloneComment("Top comment"),
                Scalar("first").ImplicitPlain,
            };

            var yaml = EmittedTextFrom(StreamedDocumentWith(events));

            yaml.Should()
                .Contain("# Top comment")
                .And.Contain("first")
                .And.NotContain("# Top commentfirst");
        }
开发者ID:aaubry,项目名称:YamlDotNet,代码行数:15,代码来源:EmitterTests.cs

示例3: AssertCurrent

        private void AssertCurrent(Parser parser, ParsingEvent expected)
        {
            Console.WriteLine(expected.GetType().Name);
            Assert.True(expected.GetType().IsAssignableFrom(parser.Current.GetType()), string.Format("The event is not of the expected type. Exprected: {0}, Actual: {1}", expected.GetType().Name, parser.Current.GetType().Name));

            foreach (var property in expected.GetType().GetProperties()) {
                if(property.PropertyType != typeof(Mark) && property.CanRead) {
                    object value = property.GetValue(parser.Current, null);
                    object expectedValue = property.GetValue(expected, null);
                    if(expectedValue != null && Type.GetTypeCode(expectedValue.GetType()) == TypeCode.Object && expectedValue is IEnumerable) {
                        Console.Write("\t{0} = {{", property.Name);
                        bool isFirst = true;
                        foreach(var item in (IEnumerable)value) {
                            if(isFirst) {
                                isFirst = false;
                            } else {
                                Console.Write(", ");
                            }
                            Console.Write(item);
                        }
                        Console.WriteLine("}");

                        if(expectedValue is ICollection && value is ICollection) {
                            Assert.Equal(((ICollection)expectedValue).Count, ((ICollection)value).Count);
                        }

                        IEnumerator values = ((IEnumerable)value).GetEnumerator();
                        IEnumerator expectedValues = ((IEnumerable)expectedValue).GetEnumerator();
                        while(expectedValues.MoveNext()) {
                            Assert.True(values.MoveNext());
                            Assert.Equal(expectedValues.Current, values.Current);
                        }

                        Assert.False(values.MoveNext());
                    } else {
                        Console.WriteLine("\t{0} = {1}", property.Name, value);
                        Assert.Equal(expectedValue, value);
                    }
                }
            }
        }
开发者ID:igor-toporet,项目名称:YamlDotNet,代码行数:41,代码来源:ParserTests.cs

示例4: EmitSequenceStart

        /// <summary>
        /// Expect SEQUENCE-START.
        /// </summary>
        private void EmitSequenceStart(ParsingEvent evt)
        {
            ProcessAnchor();
            ProcessTag();

            var sequenceStart = (SequenceStart) evt;

            if (flowLevel != 0 || isCanonical || sequenceStart.Style == SequenceStyle.Flow || CheckEmptySequence())
            {
                state = EmitterState.FlowSequenceFirstItem;
            }
            else
            {
                state = EmitterState.BlockSequenceFirstItem;
            }
        }
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:19,代码来源:Emitter.cs

示例5: EmitNode

        /// <summary>
        /// Expect a node.
        /// </summary>
        private void EmitNode(ParsingEvent evt, bool isRoot, bool isMapping, bool isSimpleKey)
        {
            isRootContext = isRoot;
            isMappingContext = isMapping;
            isSimpleKeyContext = isSimpleKey;

            switch (evt.Type)
            {
                case EventType.Alias:
                    EmitAlias();
                    break;

                case EventType.Scalar:
                    EmitScalar(evt);
                    break;

                case EventType.SequenceStart:
                    EmitSequenceStart(evt);
                    break;

                case EventType.MappingStart:
                    EmitMappingStart(evt);
                    break;

                default:
                    throw new YamlException(string.Format("Expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, got {0}", evt.Type));
            }
        }
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:31,代码来源:Emitter.cs

示例6: EmitFlowSequenceItem

        /// <summary>
        /// Expect a flow item node.
        /// </summary>
        private void EmitFlowSequenceItem(ParsingEvent evt, bool isFirst)
        {
            if (isFirst)
            {
                WriteIndicator("[", true, true, false);
                IncreaseIndent(true, false);
                ++flowLevel;
            }

            if (evt is SequenceEnd)
            {
                --flowLevel;
                indent = indents.Pop();
                if (isCanonical && !isFirst)
                {
                    WriteIndicator(",", false, false, false);
                    WriteIndent();
                }
                WriteIndicator("]", false, false, false);
                state = states.Pop();
                return;
            }

            if (!isFirst)
            {
                WriteIndicator(",", false, false, false);
            }

            if (isCanonical || column > bestWidth)
            {
                WriteIndent();
            }

            states.Push(EmitterState.FlowSequenceItem);

            EmitNode(evt, false, false, false);
        }
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:40,代码来源:Emitter.cs

示例7: EmitFlowMappingKey

        /// <summary>
        /// Expect a flow key node.
        /// </summary>
        private void EmitFlowMappingKey(ParsingEvent evt, bool isFirst)
        {
            if (isFirst)
            {
                WriteIndicator("{", true, true, false);
                IncreaseIndent(true, false);
                ++flowLevel;
            }

            if (evt is MappingEnd)
            {
                --flowLevel;
                indent = indents.Pop();
                if (isCanonical && !isFirst)
                {
                    WriteIndicator(",", false, false, false);
                    WriteIndent();
                }
                WriteIndicator("}", false, false, false);
                state = states.Pop();
                return;
            }

            if (!isFirst)
            {
                WriteIndicator(",", false, false, false);
            }
            if (isCanonical || column > bestWidth)
            {
                WriteIndent();
            }

            if (!isCanonical && CheckSimpleKey())
            {
                states.Push(EmitterState.FlowMappingSimpleValue);
                EmitNode(evt, false, true, true);
            }
            else
            {
                WriteIndicator("?", true, false, false);
                states.Push(EmitterState.FlowMappingValue);
                EmitNode(evt, false, true, false);
            }
        }
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:47,代码来源:Emitter.cs

示例8: EmitDocumentEnd

        /// <summary>
        /// Expect DOCUMENT-END.
        /// </summary>
        private void EmitDocumentEnd(ParsingEvent evt)
        {
            var documentEnd = evt as DocumentEnd;
            if (documentEnd != null)
            {
                WriteIndent();
                if (!documentEnd.IsImplicit)
                {
                    WriteIndicator("...", true, false, false);
                    WriteIndent();
                    isDocumentEndWritten = true;
                }

                state = EmitterState.DocumentStart;

                tagDirectives.Clear();
            }
            else
            {
                throw new YamlException("Expected DOCUMENT-END.");
            }
        }
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:25,代码来源:Emitter.cs

示例9: MoveNext

		public bool MoveNext()
		{
			if (_currentIndex < 0)
			{
				while (_innerParser.MoveNext())
				{
					_allEvents.Add(_innerParser.Current);
				}

				for (int i = _allEvents.Count - 2; i >= 0; --i)
				{
					var merge = _allEvents[i] as Scalar;
					if (merge != null && merge.Value == "<<")
					{
						var anchorAlias = _allEvents[i + 1] as AnchorAlias;
						if (anchorAlias != null)
						{
							var mergedEvents = GetMappingEvents(anchorAlias.Value);
							_allEvents.RemoveRange(i, 2);
							_allEvents.InsertRange(i, mergedEvents);
							continue;
						}

						var sequence = _allEvents[i + 1] as SequenceStart;
						if (sequence != null)
						{
							var mergedEvents = new List<IEnumerable<ParsingEvent>>();
							var sequenceEndFound = false;
							for (var itemIndex = i + 2; itemIndex < _allEvents.Count; ++itemIndex)
							{
								anchorAlias = _allEvents[itemIndex] as AnchorAlias;
								if (anchorAlias != null)
								{
									mergedEvents.Add(GetMappingEvents(anchorAlias.Value));
									continue;
								}

								if (_allEvents[itemIndex] is SequenceEnd)
								{
									_allEvents.RemoveRange(i, itemIndex - i + 1);
									_allEvents.InsertRange(i, mergedEvents.SelectMany(e => e));
									sequenceEndFound = true;
									break;
								}
							}

							if (sequenceEndFound)
							{
								continue;
							}
						}

						throw new SemanticErrorException(merge.Start, merge.End, "Unrecognized merge key pattern");
					}
				}
			}

			var nextIndex = _currentIndex + 1;
			if (nextIndex < _allEvents.Count)
			{
				Current = _allEvents[nextIndex];
				_currentIndex = nextIndex;
				return true;
			}
			return false;
		}
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:66,代码来源:MergingParser.cs

示例10: MappingEnd

			void IParsingEventVisitor.Visit(MappingEnd e)
			{
				clonedEvent = new MappingEnd(e.Start, e.End);
			}
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:4,代码来源:MergingParser.cs

示例11: MappingStart

			void IParsingEventVisitor.Visit(MappingStart e)
			{
				clonedEvent = new MappingStart(null, e.Tag, e.IsImplicit, e.Style, e.Start, e.End);
			}
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:4,代码来源:MergingParser.cs

示例12: SequenceEnd

			void IParsingEventVisitor.Visit(SequenceEnd e)
			{
				clonedEvent = new SequenceEnd(e.Start, e.End);
			}
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:4,代码来源:MergingParser.cs

示例13: SequenceStart

			void IParsingEventVisitor.Visit(SequenceStart e)
			{
				clonedEvent = new SequenceStart(null, e.Tag, e.IsImplicit, e.Style, e.Start, e.End);
			}
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:4,代码来源:MergingParser.cs

示例14: Scalar

			void IParsingEventVisitor.Visit(Scalar e)
			{
				clonedEvent = new Scalar(null, e.Tag, e.Value, e.Style, e.IsPlainImplicit, e.IsQuotedImplicit, e.Start, e.End);
			}
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:4,代码来源:MergingParser.cs

示例15: EmitBlockSequenceItem

        /// <summary>
        /// Expect a block item node.
        /// </summary>
        private void EmitBlockSequenceItem(ParsingEvent evt, bool isFirst)
        {
            if (isFirst)
            {
                IncreaseIndent(false, (isMappingContext && !isIndentation));
            }

            if (evt is SequenceEnd)
            {
                indent = indents.Pop();
                state = states.Pop();
                return;
            }

            WriteIndent();
            WriteIndicator("-", true, false, true);
            states.Push(EmitterState.BlockSequenceItem);

            EmitNode(evt, false, false, false);
        }
开发者ID:Cyberbanan,项目名称:Projeny,代码行数:23,代码来源:Emitter.cs


注:本文中的YamlDotNet.Core.Events.ParsingEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。