• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IInternalContextAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Value

		/// <summary>
		/// Computes the result of the division. Currently limited to Integers.
		/// </summary>
		/// <returns>Integer(value) or null</returns>
		public override Object Value(IInternalContextAdapter context)
		{
			// get the two args
			Object left = GetChild(0).Value(context);
			Object right = GetChild(1).Value(context);

			// if either is null, lets log and bail
			if (left == null || right == null)
			{
				runtimeServices.Error(
					string.Format(
						"{0} side ({1}) of division operation has null value. Operation not possible. {2} [line {3}, column {4}]",
						(left == null ? "Left" : "Right"), GetChild((left == null ? 0 : 1)).Literal, context.CurrentTemplateName, Line,
						Column));
				return null;
			}

			Type maxType = MathUtil.ToMaxType(left.GetType(), right.GetType());
			if (maxType == null)
			{
				return null;
			}

			try
			{
				return MathUtil.Div(maxType, left, right);
			}
			catch (DivideByZeroException)
			{
				runtimeServices.Error("Right side of division operation is zero. Must be non-zero. " + context.CurrentTemplateName + " [line " + Line + ", column " + Column + "]");
			}
			return null;
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:37,代码来源:ASTDivNode.cs


示例2: Evaluate

        public override bool Evaluate(IInternalContextAdapter context)
        {
            // get the two args
            Object left = GetChild(0).Value(context);
            Object right = GetChild(1).Value(context);

            // if either is null, lets log and bail
            if (left == null || right == null)
            {
                runtimeServices.Error(
                    string.Format(
                        "{0} side ({1}) of '>=' operation has null value. Operation not possible. {2} [line {3}, column {4}]",
                        (left == null ? "Left" : "Right"), GetChild((left == null ? 0 : 1)).Literal, context.CurrentTemplateName, Line,
                        Column));
                return false;
            }

            try
            {
                return ObjectComparer.CompareObjects(left, right) >= 0;
            }
            catch(ArgumentException ae)
            {
                runtimeServices.Error(ae.Message);

                return false;
            }
        }
开发者ID:rasmus-toftdahl-olesen,项目名称:NVelocity,代码行数:28,代码来源:ASTGENode.cs


示例3: Value

		/// <summary>
		/// Computes the sum of the two nodes.
		/// Currently only integer operations are supported.
		/// </summary>
		/// <returns>Integer object with value, or null</returns>
		public override Object Value(IInternalContextAdapter context)
		{
			// get the two addends
			Object left = GetChild(0).Value(context);
			Object right = GetChild(1).Value(context);

			// if either is null, lets log and bail
			if (left == null || right == null)
			{
				runtimeServices.Error(
					string.Format(
						"{0} side ({1}) of addition operation has null value. Operation not possible. {2} [line {3}, column {4}]",
						(left == null ? "Left" : "Right"), GetChild((left == null ? 0 : 1)).Literal, context.CurrentTemplateName, Line,
						Column));
				return null;
			}

			Type maxType = MathUtil.ToMaxType(left.GetType(), right.GetType());

			if (maxType == null)
			{
				return null;
			}

			return MathUtil.Add(maxType, left, right);

			// if not an Integer, not much we can do either
//			if (!(left is Int32) || !(right is Int32))
//			{
//				runtimeServices.Error((!(left is Int32) ? "Left" : "Right") + " side of addition operation is not a valid type. " + "Currently only integers (1,2,3...) and Integer type is supported. " + context.CurrentTemplateName + " [line " + Line + ", column " + Column + "]");
//
//				return null;
//			}
//			return ((Int32) left) + ((Int32) right);
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:40,代码来源:ASTAddNode.cs


示例4: Render

		public override bool Render(IInternalContextAdapter context, TextWriter writer, INode node)
		{
			if (node.ChildrenCount != 2)
			{
				throw new MonoRailException("#capturefor directive expects an id attribute and a template block");
			}

			var idNode = (ASTWord) node.GetChild(0);
			var bodyNode = (ASTBlock) node.GetChild(1);

			var id = idNode.Literal;

			var buffer = new StringWriter();
			var sb = buffer.GetStringBuilder();

			bodyNode.Render(context, buffer);

			var currentContent = context[id] as string;

			if( currentContent != null )
			{
				sb.Append(currentContent);
			}

			context[id] = sb.ToString();

			return true;
		}
开发者ID:smoothdeveloper,项目名称:Castle.MonoRail,代码行数:28,代码来源:CaptureForDirective.cs


示例5: Render

		public override bool Render(IInternalContextAdapter context, TextWriter writer)
		{
			// Check if the #if(expression) construct evaluates to true:
			// if so render and leave immediately because there
			// is nothing left to do!
			if (GetChild(0).Evaluate(context))
			{
				GetChild(1).Render(context, writer);
				return true;
			}

			int totalNodes = ChildrenCount;

			// Now check the remaining nodes left in the
			// if construct. The nodes are either elseif
			// nodes or else nodes. Each of these node
			// types knows how to evaluate themselves. If
			// a node evaluates to true then the node will
			// render itself and this method will return
			// as there is nothing left to do.
			for(int i = 2; i < totalNodes; i++)
			{
				if (GetChild(i).Evaluate(context))
				{
					GetChild(i).Render(context, writer);
					return true;
				}
			}

			// This is reached when an ASTIfStatement
			// consists of an if/elseif sequence where
			// none of the nodes evaluate to true.
			return true;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:34,代码来源:ASTIfStatement.cs


示例6: Evaluate

		public override bool Evaluate(IInternalContextAdapter context)
		{
			// get the two args
			Object left = GetChild(0).Value(context);
			Object right = GetChild(1).Value(context);

			// if either is null, lets log and bail
			if (left == null || right == null)
			{
				rsvc.Error((left == null ? "Left" : "Right") + " side (" + GetChild((left == null ? 0 : 1)).Literal +
				           ") of '>' operation has null value." + " Operation not possible. " + context.CurrentTemplateName +
				           " [line " + Line + ", column " + Column + "]");
				return false;
			}

			try
			{
				return ObjectComparer.CompareObjects(left, right) == ObjectComparer.Greater;
			}
			catch(ArgumentException ae)
			{
				rsvc.Error(ae.Message);

				return false;
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:26,代码来源:ASTGTNode.cs


示例7: Evaluate

		public override bool Evaluate(IInternalContextAdapter context)
		{
			if (GetChild(0).Evaluate(context))
				return false;
			else
				return true;
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:ASTNotNode.cs


示例8: Value

		/// <summary>
		/// Computes the value of the subtraction.
		/// Currently limited to integers.
		/// </summary>
		/// <returns>Integer(value) or null</returns>
		public override Object Value(IInternalContextAdapter context)
		{
			// get the two args
			Object left = GetChild(0).Value(context);
			Object right = GetChild(1).Value(context);

			// if either is null, lets log and bail
			if (left == null || right == null)
			{
				rsvc.Error((left == null ? "Left" : "Right") + " side (" + GetChild((left == null ? 0 : 1)).Literal +
				           ") of subtraction operation has null value." + " Operation not possible. " + context.CurrentTemplateName +
				           " [line " + Line + ", column " + Column + "]");
				return null;
			}

			Type maxType = MathUtil.ToMaxType(left.GetType(), right.GetType());

			if (maxType == null)
			{
				return null;
			}

			return MathUtil.Sub(maxType, left, right);

			// if not an Integer, not much we can do either
//			if (!(left is Int32) || !(right is Int32))
//			{
//				rsvc.Error((!(left is Int32) ? "Left" : "Right") + " side of subtraction operation is not a valid type. " + "Currently only integers (1,2,3...) and Integer type is supported. " + context.CurrentTemplateName + " [line " + Line + ", column " + Column + "]");
//
//				return null;
//			}
//
//			return ((Int32) left) - ((Int32) right);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:39,代码来源:ASTSubtractNode.cs


示例9: Render

		/// <summary>   puts the value of the RHS into the context under the key of the LHS
		/// </summary>
		public override bool Render(IInternalContextAdapter context, TextWriter writer)
		{
			/*
	    *  get the RHS node, and it's value
	    */

			Object value = right.Value(context);

			/*
	    * it's an error if we don't have a value of some sort
	    */

			if (value == null)
			{
				/*
				*  first, are we supposed to say anything anyway?
				*/
				if (blather)
				{
					EventCartridge eventCartridge = context.EventCartridge;

					bool doIt = true;

					/*
		    *  if we have an EventCartridge...
		    */
					if (eventCartridge != null)
					{
						doIt = eventCartridge.ShouldLogOnNullSet(left.Literal, right.Literal);
					}

					if (doIt)
					{
						runtimeServices.Error(
							string.Format("RHS of #set statement is null. Context will not be modified. {0} [line {1}, column {2}]",
							              context.CurrentTemplateName, Line, Column));
					}
				}

				return false;
			}

			/*
	    *  if the LHS is simple, just punch the value into the context
	    *  otherwise, use the setValue() method do to it.
	    *  Maybe we should always use setValue()
	    */

			if (left.ChildrenCount == 0)
			{
				context.Put(leftReference, value);
			}
			else
			{
				left.SetValue(context, value);
			}

			return true;
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:61,代码来源:ASTSetDirective.cs


示例10: Init

		/// <summary>
		/// How this directive is to be initialized.
		/// </summary>
		public virtual void Init(IRuntimeServices rs, IInternalContextAdapter context, INode node)
		{
			runtimeServices = rs;

//			int i, k = node.jjtGetNumChildren();
//			for (i = 0; i < k; i++)
//				node.jjtGetChild(i).init(context, rs);
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:11,代码来源:Directive.cs


示例11: Init

		public override Object Init(IInternalContextAdapter context, Object data)
		{
			Token t = FirstToken;

			text = NodeUtils.tokenLiteral(t);

			return data;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:8,代码来源:ASTText.cs


示例12: Init

		/// <summary>
		/// simple init - don't do anything that is context specific.
		/// just get what we need from the AST, which is static.
		/// </summary>
		public override Object Init(IInternalContextAdapter context, Object data)
		{
			base.Init(context, data);

			identifier = FirstToken.Image;

			uberInfo = new Info(context.CurrentTemplateName, Line, Column);
			return data;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:13,代码来源:ASTIdentifier.cs


示例13: Init

		/// <summary>
		/// simple init - init our subtree and get what we can from
		/// the AST
		/// </summary>
		public override Object Init(IInternalContextAdapter context, Object data)
		{
			base.Init(context, data);

			methodName = FirstToken.Image;
			paramCount = ChildrenCount - 1;

			return data;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:13,代码来源:ASTMethod.cs


示例14: Render

		public override bool Render(IInternalContextAdapter context, TextWriter writer)
		{
			int i, k = ChildrenCount;

			for(i = 0; i < k; i++)
				GetChild(i).Render(context, writer);

			return true;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:9,代码来源:ASTBlock.cs


示例15: Init

		/// <summary>  init : we don't have to do much.  Init the tree (there
		/// shouldn't be one) and then see if interpolation is turned on.
		/// </summary>
		public override Object Init(IInternalContextAdapter context, Object data)
		{
			base.Init(context, data);

			/*
			*  the stringlit is set at template parse time, so we can 
			*  do this here for now.  if things change and we can somehow 
			* create stringlits at runtime, this must
			*  move to the runtime execution path
			*
			*  so, only if interpolation is turned on AND it starts 
			*  with a " AND it has a  directive or reference, then we 
			*  can  interpolate.  Otherwise, don't bother.
			*/

			interpolate = FirstToken.Image.StartsWith("\"") &&
			              ((FirstToken.Image.IndexOf('$') != - 1) ||
			               (FirstToken.Image.IndexOf('#') != - 1));

			/*
			*  get the contents of the string, minus the '/" at each end
			*/

			image = FirstToken.Image.Substring(1, (FirstToken.Image.Length - 1) - (1));
			/*
			* tack a space on the end (dreaded <MORE> kludge)
			*/

			interpolateimage = image + " ";

			if (interpolate)
			{
				/*
				*  now parse and init the nodeTree
				*/
				TextReader br = new StringReader(interpolateimage);

				/*
				* it's possible to not have an initialization context - or we don't
				* want to trust the caller - so have a fallback value if so
				*
				*  Also, do *not* dump the VM namespace for this template
				*/

				nodeTree = rsvc.Parse(br, (context != null) ? context.CurrentTemplateName : "StringLiteral", false);

				/*
				*  init with context. It won't modify anything
				*/

				nodeTree.Init(context, rsvc);
			}

			return data;
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:58,代码来源:ASTStringLiteral.cs


示例16: Value

		public override Object Value(IInternalContextAdapter context)
		{
			int size = ChildrenCount;

			ArrayList objectArray = new ArrayList(size);

			for(int i = 0; i < size; i++)
				objectArray.Add(GetChild(i).Value(context));

			return objectArray;
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:11,代码来源:ASTObjectArray.cs


示例17: Init

		/// <summary>  Initialization method - doesn't do much but do the object
		/// creation.  We only need to do it once.
		/// </summary>
		public override Object Init(IInternalContextAdapter context, Object data)
		{
			/*
	    *  init the tree correctly
	    */

			base.Init(context, data);

			valueField = Int32.Parse(FirstToken.Image);

			return data;
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:15,代码来源:ASTNumberLiteral.cs


示例18: Init

		/// <summary>
		/// simple init - init the tree and get the elementKey from
		/// the AST
		/// </summary>
		public override void Init(IRuntimeServices rs, IInternalContextAdapter context, INode node)
		{
			base.Init(rs, context, node);

			// get the msg, and add the space so we don't have to
			// do it each time
			outputMsgStart = rsvc.GetString(RuntimeConstants.ERRORMSG_START);
			outputMsgStart = outputMsgStart + " ";

			outputMsgEnd = rsvc.GetString(RuntimeConstants.ERRORMSG_END);
			outputMsgEnd = " " + outputMsgEnd;
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:16,代码来源:Include.cs


示例19: Render

        /// <summary>
        /// iterates through the argument list and renders every
        /// argument that is appropriate.  Any non appropriate
        /// arguments are logged, but render() continues.
        /// </summary>
        public override bool Render(IInternalContextAdapter context, TextWriter writer, INode node)
        {
            // did we get an argument?
            if (!AssertArgument(node))
            {
                return false;
            }

            // does it have a value?  If you have a null reference, then no.
            Object value;
            if (!AssertNodeHasValue(node, context, out value))
            {
                return false;
            }

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

            AssertTemplateStack(context);

            Resource current = context.CurrentResource;

            // 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;
            }

            // now use the Runtime resource loader to get the template
            Template t = null;

            t = GetTemplate(arg, encoding, context);
            if (t == null)
            {
                return false;
            }

            // and render it
            if (!RenderTemplate(t, arg, writer, context))
            {
                return false;
            }

            return true;
        }
开发者ID:rasmus-toftdahl-olesen,项目名称:NVelocity,代码行数:57,代码来源:Parse.cs


示例20: Value

		/// <summary>
		/// does the real work.  Creates an Vector of Integers with the
		/// right value range
		/// </summary>
		/// <param name="context">app context used if Left or Right of .. is a ref</param>
		/// <returns>Object array of Integers</returns>
		public override Object Value(IInternalContextAdapter context)
		{
			// get the two range ends
			Object left = GetChild(0).Value(context);
			Object right = GetChild(1).Value(context);

			// if either is null, lets log and bail
			if (left == null || right == null)
			{
				runtimeServices.Error(
					string.Format(
						"{0} side of range operator [n..m] has null value. Operation not possible. {1} [line {2}, column {3}]",
						(left == null ? "Left" : "Right"), context.CurrentTemplateName, Line, Column));
				return null;
			}

			// if not an Integer, not much we can do either
			if (!(left is Int32) || !(right is Int32))
			{
				runtimeServices.Error(
					string.Format(
						"{0} side of range operator is not a valid type. Currently only integers (1,2,3...) and Integer type is supported. {1} [line {2}, column {3}]",
						(!(left is Int32) ? "Left" : "Right"), context.CurrentTemplateName, Line, Column));

				return null;
			}

			// get the two integer values of the ends of the range
			int l = ((Int32) left);
			int r = ((Int32) right);

			// find out how many there are
			int num = Math.Abs(l - r);
			num += 1;

			// see if your increment is Pos or Neg
			int delta = (l >= r) ? - 1 : 1;

			// make the vector and fill it
			ArrayList foo = new ArrayList(num);
			int val = l;

			for(int i = 0; i < num; i++)
			{
				foo.Add(val);
				val += delta;
			}

			return foo;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:56,代码来源:ASTIntegerRange.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IInternalObjectContainer类代码示例发布时间:2022-05-24
下一篇:
C# IInternalConfigRecord类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap