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


C# YamlStream.Accept方法代码示例

本文整理汇总了C#中YamlStream.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# YamlStream.Accept方法的具体用法?C# YamlStream.Accept怎么用?C# YamlStream.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YamlStream的用法示例。


在下文中一共展示了YamlStream.Accept方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseModel

 private static NamedModel ParseModel(string input)
 {
     if (input == null) throw new ArgumentNullException("input");
     using (var yamlSource = File.OpenText(input))
     {
         var stream = new YamlStream();
         stream.Load(yamlSource);
         var visitor = new ComposeNamedModelVisitor();
         stream.Accept(visitor);
         return visitor.Model;
     }
 }
开发者ID:yreynhout,项目名称:MessTalk,代码行数:12,代码来源:Program.cs

示例2: AllAliasesMustBeResolved

        public void AllAliasesMustBeResolved()
        {
            YamlStream original = new YamlStream();
            original.Load(YamlFile("invalid-reference.yaml"));

            var visitor = new AliasFindingVisitor();

            try
            {
                original.Accept(visitor);
            }
            catch (NotSupportedException)
            {
                foreach (var node in visitor.CurrentPath)
                {
                    TestContext.WriteLine(node.ToString());
                }

                Assert.Fail();
            }
        }
开发者ID:chipdude,项目名称:yamldotnet,代码行数:21,代码来源:YamlStreamTests.cs

示例3: Parse

        public IDictionary<string, string> Parse(Stream input)
        {
            IDictionary<string, string> data = new SortedDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            var visitor = new ContextAwareVisitor();

            var yamlStream = new YamlStream();

            using (var reader = new StreamReader(input))
            {
                yamlStream.Load(reader);

            }

            if (!yamlStream.Documents.Any())
            {
                return data;
            }

            yamlStream.Accept(visitor);

            foreach (var item in visitor.Items)
            {
                var key = item.Key;

                if (!string.IsNullOrEmpty(this.root))
                {
                    key = ConfigurationPath.Combine(this.root, key);
                }

                if (data.ContainsKey(key))
                {
                    throw new FormatException(string.Format("The key '{0}' is duplicated.", key));
                }
                data[key] = item.Value;
            }

            return data;
        }
开发者ID:nbarbettini,项目名称:FlexibleConfiguration,代码行数:38,代码来源:YamlParser.cs

示例4: RoundtripSample

		public void RoundtripSample()
		{
			var original = new YamlStream();
			original.Load(YamlFile("sample.yaml"));
			original.Accept(new TracingVisitor());
		}
开发者ID:modulexcite,项目名称:SharpYaml,代码行数:6,代码来源:YamlStreamTests.cs

示例5: RoundtripTest

		private void RoundtripTest(string yamlFileName)
		{
			var original = new YamlStream();
			original.Load(YamlFile(yamlFileName));

			var buffer = new StringBuilder();
			original.Save(new StringWriter(buffer));

			Dump.WriteLine(buffer);

			var final = new YamlStream();
			final.Load(new StringReader(buffer.ToString()));

			var originalBuilder = new YamlDocumentStructureBuilder();
			original.Accept(originalBuilder);

			var finalBuilder = new YamlDocumentStructureBuilder();
			final.Accept(finalBuilder);

			Dump.WriteLine("The original document produced {0} events.", originalBuilder.Events.Count);
			Dump.WriteLine("The final document produced {0} events.", finalBuilder.Events.Count);
			Assert.AreEqual(originalBuilder.Events.Count, finalBuilder.Events.Count);

			for (var i = 0; i < originalBuilder.Events.Count; ++i)
			{
				var originalEvent = originalBuilder.Events[i];
				var finalEvent = finalBuilder.Events[i];

				Assert.AreEqual(originalEvent.Type, finalEvent.Type);
				Assert.AreEqual(originalEvent.Value, finalEvent.Value);
			}
		}
开发者ID:modulexcite,项目名称:SharpYaml,代码行数:32,代码来源:YamlStreamTests.cs

示例6: Run

		public void Run(string[] args)
		{
			var original = new YamlStream();
			original.Load(new StringReader(Sample));
			original.Accept(new TracingVisitor());
		}
开发者ID:Gwynneth,项目名称:YamlDotNet,代码行数:6,代码来源:VisitYamlStream.cs

示例7: RoundtripTest

        private void RoundtripTest(string yamlFileName)
        {
            YamlStream original = new YamlStream();
            original.Load(YamlFile(yamlFileName));

            StringBuilder buffer = new StringBuilder();
            original.Save(new StringWriter(buffer));

            Console.WriteLine(buffer.ToString());

            YamlStream final = new YamlStream();
            final.Load(new StringReader(buffer.ToString()));

            YamlDocumentStructureBuilder originalBuilder = new YamlDocumentStructureBuilder();
            original.Accept(originalBuilder);

            YamlDocumentStructureBuilder finalBuilder = new YamlDocumentStructureBuilder();
            final.Accept(finalBuilder);

            Console.WriteLine("The original document produced {0} events.", originalBuilder.Events.Count);
            Console.WriteLine("The final document produced {0} events.", finalBuilder.Events.Count);
            Assert.Equal(originalBuilder.Events.Count, finalBuilder.Events.Count);

            for (int i = 0; i < originalBuilder.Events.Count; ++i)
            {
                YamlNodeEvent originalEvent = originalBuilder.Events[i];
                YamlNodeEvent finalEvent = finalBuilder.Events[i];

                Assert.Equal(originalEvent.Type, finalEvent.Type);
                //Assert.Equal(originalEvent.Tag, finalEvent.Tag);
                //Assert.Equal(originalEvent.Anchor, finalEvent.Anchor);
                Assert.Equal(originalEvent.Value, finalEvent.Value);
            }
        }
开发者ID:imgen,项目名称:YamlDotNet,代码行数:34,代码来源:YamlStreamTests.cs


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