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


C# INode.Value方法代码示例

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


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

示例1: RenderOutput

		/// <summary>
		/// does the actual rendering of the included file
		/// </summary>
		/// <param name="node">AST argument of type StringLiteral or Reference</param>
		/// <param name="context">valid context so we can render References</param>
		/// <param name="writer">output Writer</param>
		/// <returns>boolean success or failure.  failures are logged</returns>
		private bool RenderOutput(INode node, IInternalContextAdapter context, TextWriter writer)
		{
			if (node == null)
			{
				rsvc.Error("#include() error :  null argument");
				return false;
			}

			// does it have a value?  If you have a null reference, then no.
			Object val = node.Value(context);
			if (val == null)
			{
				rsvc.Error("#include() error :  null argument");
				return false;
			}

			// get the path
			String arg = val.ToString();

			Resource resource = null;

			Resource current = context.CurrentResource;

			try
			{
				// get the resource, and assume that we use the encoding of the current template
				// the 'current resource' can be null if we are processing a stream....
				String encoding = null;

				if (current != null)
					encoding = current.Encoding;
				else
					encoding = (String) rsvc.GetProperty(RuntimeConstants.INPUT_ENCODING);

				resource = rsvc.GetContent(arg, encoding);
			}
			catch(ResourceNotFoundException)
			{
				// the arg wasn't found.  Note it and throw
				rsvc.Error("#include(): cannot find resource '" + arg + "', called from template " + context.CurrentTemplateName +
				           " at (" + Line + ", " + Column + ")");
				throw;
			}
			catch(Exception e)
			{
				rsvc.Error("#include(): arg = '" + arg + "',  called from template " + context.CurrentTemplateName + " at (" + Line +
				           ", " + Column + ") : " + e);
			}

			if (resource == null)
				return false;

			writer.Write((String) resource.Data);
			return true;
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:62,代码来源:Include.cs

示例2: RenderOutput

		/// <summary>
		/// does the actual rendering of the included file
		/// </summary>
		/// <param name="node">AST argument of type StringLiteral or Reference</param>
		/// <param name="context">valid context so we can render References</param>
		/// <param name="writer">output Writer</param>
		/// <returns>boolean success or failure.  failures are logged</returns>
		private bool RenderOutput(INode node, IInternalContextAdapter context, TextWriter writer)
		{
			if (node == null)
			{
				runtimeServices.Error("#include() error :  null argument");
				return false;
			}

			// does it have a value?  If you have a null reference, then no.
			Object val = node.Value(context);
			if (val == null)
			{
				runtimeServices.Error("#include() error :  null argument");
				return false;
			}

			// get the path
			String arg = val.ToString();

			Resource resource = null;

			Resource current = context.CurrentResource;

			try
			{
				// get the resource, and assume that we use the encoding of the current template
				// the 'current resource' can be null if we are processing a stream....
				String encoding;

				if (current == null)
				{
					encoding = (String) runtimeServices.GetProperty(RuntimeConstants.INPUT_ENCODING);
				}
				else
				{
					encoding = current.Encoding;
				}

				resource = runtimeServices.GetContent(arg, encoding);
			}
			catch(ResourceNotFoundException)
			{
				// the arg wasn't found.  Note it and throw
				runtimeServices.Error(
					string.Format("#include(): cannot find resource '{0}', called from template {1} at ({2}, {3})", arg,
					              context.CurrentTemplateName, Line, Column));
				throw;
			}
			catch(Exception e)
			{
				runtimeServices.Error(
					string.Format("#include(): arg = '{0}',  called from template {1} at ({2}, {3}) : {4}", arg,
					              context.CurrentTemplateName, Line, Column, e));
			}

			if (resource == null)
			{
				return false;
			}

			writer.Write((String) resource.Data);
			return true;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:70,代码来源:Include.cs


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