當前位置: 首頁>>代碼示例>>C#>>正文


C# Factory.Expression方法代碼示例

本文整理匯總了C#中System.Factory.Expression方法的典型用法代碼示例。如果您正苦於以下問題:C# Factory.Expression方法的具體用法?C# Factory.Expression怎麽用?C# Factory.Expression使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Factory的用法示例。


在下文中一共展示了Factory.Expression方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CollapsesPreviousWhiteSpace

		public void CollapsesPreviousWhiteSpace()
		{
			var factory = new Factory();
			
			// "Hello {{~test}}"
			var document = factory.Document(
				factory.Text("Hello"),
				factory.WhiteSpace(1),
				factory.Expression(
					factory.MetaCode("{{", T.OpenTag),
					factory.MetaCode("~", T.Tilde),
					factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)),
					factory.MetaCode("}}", T.CloseTag)));

			factory = new Factory();

			// "Hello{{~test}}"
			var expected = factory.Document(
				factory.Text("Hello"),
				factory.WhiteSpace(1, collapsed: true),
				factory.Expression(
					factory.MetaCode("{{", T.OpenTag),
					factory.MetaCode("~", T.Tilde),
					factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)),
					factory.MetaCode("}}", T.CloseTag)));

			var visitor = new WhiteSpaceCollapsingParserVisitor();
			visitor.VisitBlock(document);

			var builder = new StringBuilder();
			var comparer = new EquivalanceComparer(builder, 0);

			Assert.True(comparer.Equals(expected, document), builder.ToString());
		}
開發者ID:furesoft,項目名稱:FuManchu,代碼行數:34,代碼來源:WhiteSpaceCollapsingParserVisitorFacts.cs

示例2: CollapsesWhiteSpaceInParentBlocks

		public void CollapsesWhiteSpaceInParentBlocks()
		{
			var factory = new Factory();

			// "Message:{{#this~}} Hello {{~/this~}} There"
			var document = factory.Document(
				factory.Text("Message:"),
				factory.Tag("this",
					factory.TagElement("this",
						factory.MetaCode("{{", T.OpenTag),
						factory.MetaCode("#", T.Hash),
						factory.Expression(factory.Parameter("this")),
						factory.MetaCode("~", T.Tilde),
						factory.MetaCode("}}", T.CloseTag)),
					factory.WhiteSpace(1),
					factory.Text("Hello"),
					factory.WhiteSpace(1),
						factory.TagElement("this",
							factory.MetaCode("{{", T.OpenTag),
							factory.MetaCode("~", T.Tilde),
							factory.MetaCode("/", T.Slash),
							factory.Expression(factory.Parameter("this")),
							factory.MetaCode("~", T.Tilde),
							factory.MetaCode("}}", T.CloseTag))),
				factory.WhiteSpace(1),
				factory.Text("There"));

			factory = new Factory();

			// "Message:{{#this~}}Hello{{~/this~}}There"
			var expected = factory.Document(
				factory.Text("Message:"),
				factory.Tag("this",
					factory.TagElement("this",
						factory.MetaCode("{{", T.OpenTag),
						factory.MetaCode("#", T.Hash),
						factory.Expression(factory.Parameter("this")),
						factory.MetaCode("~", T.Tilde),
						factory.MetaCode("}}", T.CloseTag)),
					factory.WhiteSpace(1, collapsed: true),
					factory.Text("Hello"),
					factory.WhiteSpace(1, collapsed: true),
						factory.TagElement("this",
							factory.MetaCode("{{", T.OpenTag),
							factory.MetaCode("~", T.Tilde),
							factory.MetaCode("/", T.Slash),
							factory.Expression(factory.Parameter("this")),
							factory.MetaCode("~", T.Tilde),
							factory.MetaCode("}}", T.CloseTag))),
				factory.WhiteSpace(1, collapsed: true),
				factory.Text("There"));

			var visitor = new WhiteSpaceCollapsingParserVisitor();
			visitor.VisitBlock(document);

			var builder = new StringBuilder();
			var comparer = new EquivalanceComparer(builder, 0);

			Assert.True(comparer.Equals(expected, document), builder.ToString());
		}
開發者ID:furesoft,項目名稱:FuManchu,代碼行數:60,代碼來源:WhiteSpaceCollapsingParserVisitorFacts.cs


注:本文中的System.Factory.Expression方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。