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


C# Compiler.CompileExpression方法代码示例

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


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

示例1: Compile

		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("apply-templates", "select", "mode");

			select = c.CompileExpression (c.GetAttribute ("select"));
			mode = c.ParseQNameAttribute ("mode");
			ArrayList sorterList = null;
			if (c.Input.MoveToFirstChild ()) {
				do {
					switch (c.Input.NodeType) {
					case XPathNodeType.Comment:
					case XPathNodeType.ProcessingInstruction:
					case XPathNodeType.Whitespace:
					case XPathNodeType.SignificantWhitespace:
						continue;
					case XPathNodeType.Element:
						if (c.Input.NamespaceURI != XsltNamespace)
							throw new XsltCompileException ("Unexpected element", null, c.Input); // TODO: fwd compat
						
						switch (c.Input.LocalName)
						{
							case "with-param":
								if (withParams == null)
									withParams = new ArrayList ();
								withParams.Add (new XslVariableInformation (c));
								break;
								
							case "sort":
								if (sorterList == null)
									sorterList = new ArrayList ();
								if (select == null)
									select = c.CompileExpression ("*");
								sorterList.Add (new Sort (c));
								//c.AddSort (select, new Sort (c));
								break;
							default:
								throw new XsltCompileException ("Unexpected element", null, c.Input); // todo forwards compat
						}
						break;
					default:
						throw new XsltCompileException ("Unexpected node type " + c.Input.NodeType, null, c.Input);	// todo forwards compat
					}
				} while (c.Input.MoveToNext ());
				c.Input.MoveToParent ();
			}
			if (sorterList != null)
				sortEvaluator = new XslSortEvaluator (select,
					(Sort []) sorterList.ToArray (typeof (Sort)));
		}
开发者ID:nobled,项目名称:mono,代码行数:52,代码来源:XslApplyTemplates.cs

示例2: Compile

		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("value-of", "select", "disable-output-escaping");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
			disableOutputEscaping = c.ParseYesNoAttribute ("disable-output-escaping", false);
			if (c.Input.MoveToFirstChild ()) {
				do {
					switch (c.Input.NodeType) {
					case XPathNodeType.Element:
						if (c.Input.NamespaceURI == XsltNamespace)
							goto case XPathNodeType.SignificantWhitespace;
						// otherwise element in external namespace -> ignore
						break;
					case XPathNodeType.Text:
					case XPathNodeType.SignificantWhitespace:
						throw new XsltCompileException ("XSLT value-of element cannot contain any child.", null, c.Input);
					}
				} while (c.Input.MoveToNext ());
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:25,代码来源:XslValueOf.cs

示例3: Compile

		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("copy-of", "select");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
		}
开发者ID:kdoman21,项目名称:mono,代码行数:10,代码来源:XslCopyOf.cs

示例4: Compile

		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("if", "test");

			c.AssertAttribute ("test");
			test = c.CompileExpression (c.GetAttribute ("test"));

			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}	
开发者ID:nobled,项目名称:mono,代码行数:14,代码来源:XslIf.cs

示例5: XslVariableInformation

		public XslVariableInformation (Compiler c)
		{

			c.CheckExtraAttributes (c.Input.LocalName, "name", "select");

			c.AssertAttribute ("name");

			name = c.ParseQNameAttribute ("name");
			try {
				XmlConvert.VerifyName (name.Name);
			} catch (XmlException ex) {
				throw new XsltCompileException ("Variable name is not qualified name", ex, c.Input);
			}

			string sel = c.GetAttribute ("select");
			if (sel != null && sel != "" ) {
				select = c.CompileExpression (c.GetAttribute ("select"));
				// TODO assert empty
			} else  if (c.Input.MoveToFirstChild ()) {
				content = c.CompileTemplateContent ();
				c.Input.MoveToParent ();
			}
		}
开发者ID:nobled,项目名称:mono,代码行数:23,代码来源:XslVariable.cs

示例6: Compile

		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("for-each", "select");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
			ArrayList sorterList = null;
			
			if (c.Input.MoveToFirstChild ()) {
				bool alldone = true;
				do {
					if (c.Input.NodeType == XPathNodeType.Text)
						{ alldone = false; break; }
					
					if (c.Input.NodeType != XPathNodeType.Element)
						continue;
					if (c.Input.NamespaceURI != Compiler.XsltNamespace)
						{ alldone = false; break; }
					if (c.Input.LocalName != "sort")
						{ alldone = false; break; }
					//c.AddSort (select, new Sort (c));
					if (sorterList == null)
						sorterList = new ArrayList ();
					sorterList.Add (new Sort (c));
				} while (c.Input.MoveToNext ());
				if (!alldone)
					children = c.CompileTemplateContent ();
				c.Input.MoveToParent ();
			}
			if (sorterList != null)
				sortEvaluator = new XslSortEvaluator (select,
					(Sort []) sorterList.ToArray (typeof (Sort)));
		}
开发者ID:nobled,项目名称:mono,代码行数:36,代码来源:XslForEach.cs

示例7: XslAvt

		public XslAvt (string str, Compiler comp) {
			if (str.IndexOf ("{") == -1 && str.IndexOf ("}") == -1) {
				// That was easy ;-).
				simpleString = str;
				return;
			}
			avtParts = new ArrayList ();
			StringBuilder sb = new StringBuilder ();
			StringReader r = new StringReader (str);
			
			
			
			while (r.Peek () != -1) {
				char c = (char)r.Read ();
				switch (c) {					
				case '{':
					if ((char)r.Peek () == '{') {
						// {{ == escaped {
						sb.Append ((char)r.Read ());
						break;
					}
					
					if (sb.Length != 0) {
						// Ok, we have already found a text
						// part, lets save that.
						avtParts.Add (new SimpleAvtPart (sb.ToString ()));
						sb.Length = 0;
					}
					
					while ((c = (char)r.Read ()) != '}') {
						switch (c) {
						case '\'': case '"': {
							// We are inside a quote
							char unq = c;
							sb.Append (c);
							while ((c = (char)r.Read ()) != unq) {
								sb.Append (c);
								if (r.Peek () == -1)
									throw new XsltCompileException ("Unexpected end of AVT", null, comp.Input);
							}
								
							
							sb.Append (c);
							break;
						} // ' or "
						default:
							sb.Append (c);
							break;
						}
						if (r.Peek () == -1) throw new XsltCompileException ("Unexpected end of AVT", null, comp.Input);
					}
					
						
					avtParts.Add (new XPathAvtPart (comp.CompileExpression (sb.ToString ())));
					sb.Length = 0;
					break;
				case '}':
					c = (char)r.Read ();
					if (c != '}')
						throw new XsltCompileException ("Braces must be escaped", null, comp.Input);
					goto default;
				default:
					sb.Append (c);
					break;
				}
			}
			if (sb.Length != 0) {
				// Ok, we have already found a text
				// part, lets save that.
				avtParts.Add (new SimpleAvtPart (sb.ToString ()));
				sb.Length = 0;
			}
		}
开发者ID:nobled,项目名称:mono,代码行数:73,代码来源:XslAvt.cs

示例8: Compile

		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("number", "level", "count", "from", "value", "format", "lang", "letter-value", "grouping-separator", "grouping-size");

			switch (c.GetAttribute ("level"))
			{
			case "single":
				level = XslNumberingLevel.Single;
				break;
			case "multiple":
				level = XslNumberingLevel.Multiple;
				break;
			case "any":
				level = XslNumberingLevel.Any;
				break;
			case null:
			case "":
			default:
				level = XslNumberingLevel.Single; // single == default
				break;
			}
			
			count = c.CompilePattern (c.GetAttribute ("count"), c.Input);
			from = c.CompilePattern (c.GetAttribute ("from"), c.Input);
			value = c.CompileExpression (c.GetAttribute ("value"));
			
			format = c.ParseAvtAttribute ("format");
			lang = c.ParseAvtAttribute ("lang");
			letterValue = c.ParseAvtAttribute ("letter-value");
			groupingSeparator = c.ParseAvtAttribute ("grouping-separator");
			groupingSize = c.ParseAvtAttribute ("grouping-size");
		}
开发者ID:xzkmxd,项目名称:mono,代码行数:35,代码来源:XslNumber.cs


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