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


C# IInternalContextAdapter.Put方法代码示例

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


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

示例1: 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 ec = context.EventCartridge;

					bool doit = true;

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

					if (doit)
					{
						rsvc.Error("RHS of #set statement is null. Context will not be modified. " + context.CurrentTemplateName +
						           " [line " + Line + ", column " + 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:nats,项目名称:castle-1.0.3-mono,代码行数:60,代码来源:ASTSetDirective.cs

示例2: setObject

		/// <summary>  Invoked by VMContext when Context.put() is called for a proxied reference.
		/// *
		/// </summary>
		/// <param name="context">context to modify via direct placement, or AST.setValue()
		/// </param>
		/// <param name="o"> new value of reference
		/// </param>
		/// <returns>Object currently null
		///
		/// </returns>
		public Object setObject(IInternalContextAdapter context, Object o)
		{
			/*
	    *  if we are a reference, we could be updating a property
	    */

			if (type == ParserTreeConstants.REFERENCE)
			{
				if (numTreeChildren > 0)
				{
					/*
		    *  we are a property, and being updated such as
		    *  #foo( $bar.BangStart) 
		    */

					try
					{
						((ASTReference) nodeTree).SetValue(context, o);
					}
					catch(MethodInvocationException methodInvocationException)
					{
						runtimeServices.Error(
							string.Format("VMProxyArg.getObject() : method invocation error setting value : {0}", methodInvocationException));
					}
				}
				else
				{
					/*
		    *  we are a 'single level' reference like $foo, so we can set
		    *  out context directly
		    */

					context.Put(singleLevelRef, o);

					// alternate impl : userContext.put( singleLevelRef, o);
				}
			}
			else
			{
				/*
		*  if we aren't a reference, then we simply switch type, 
		*  get a new value, and it doesn't go into the context
		*
		*  in current impl, this shouldn't happen.
		*/

				type = GENERALSTATIC;
				staticObject = o;

				runtimeServices.Error(
					string.Format("VMProxyArg.setObject() : Programmer error : I am a constant!  No setting! : {0} / {1}",
					              contextReference, callerReference));
			}

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

示例3: Render

        /// <summary>
        /// renders the #foreach() block
        /// </summary>
        public override bool Render(IInternalContextAdapter context, TextWriter writer, INode node)
        {
            // do our introspection to see what our collection is
            IEnumerator enumerator = GetIterator(context, node);
            INode bodyNode = node.GetChild(3);

            INode[][] sections = PrepareSections(bodyNode);
            bool isFancyLoop = (sections != null);

            if (enumerator == null && !isFancyLoop)
            {
                return true;
            }

            int counter = counterInitialValue;

            // save the element key if there is one,
            // and the loop counter
            Object o = context.Get(elementKey);
            Object ctr = context.Get(counterName);

            if (enumerator != null && enumerator.MoveNext())
            {
                do
                {
                    object current = enumerator.Current;

                    context.Put(counterName, counter);
                    //context.Put(hasNextName, enumerator.MoveNext() ? Boolean.TrueString : Boolean.FalseString);
                    context.Put(elementKey, current);

                    try
                    {
                        if (isFancyLoop)
                        {
                            if (counter == counterInitialValue)
                            {
                                ProcessSection(ForeachSectionEnum.BeforeAll, sections, context, writer);
                            }
                            else
                            {
                                ProcessSection(ForeachSectionEnum.Between, sections, context, writer);
                            }

                            ProcessSection(ForeachSectionEnum.Before, sections, context, writer);

                            // since 1st item is zero we invert odd/even
                            if ((counter - counterInitialValue) % 2 == 0)
                            {
                                ProcessSection(ForeachSectionEnum.Odd, sections, context, writer);
                            }
                            else
                            {
                                ProcessSection(ForeachSectionEnum.Even, sections, context, writer);
                            }

                            ProcessSection(ForeachSectionEnum.Each, sections, context, writer);

                            ProcessSection(ForeachSectionEnum.After, sections, context, writer);
                        }
                        else
                        {
                            bodyNode.Render(context, writer);
                        }
                    }
                    catch (BreakException)
                    {
                        break;
                    }
                    counter++;
                } while (enumerator.MoveNext());
            }

            if (isFancyLoop)
            {
                if (counter > counterInitialValue)
                {
                    ProcessSection(ForeachSectionEnum.AfterAll, sections, context, writer);
                }
                else
                {
                    ProcessSection(ForeachSectionEnum.NoData, sections, context, writer);
                }
            }

            // restores the loop counter (if we were nested)
            // if we have one, else just removes
            if (ctr == null)
            {
                context.Remove(counterName);
            }
            else
            {
                context.Put(counterName, ctr);
            }

            // restores element key if exists
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:Transformalize,代码行数:101,代码来源:Foreach.cs


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