本文整理汇总了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;
}
示例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;
}
示例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
//.........这里部分代码省略.........