本文整理汇总了C#中IInternalContextAdapter.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# IInternalContextAdapter.Remove方法的具体用法?C# IInternalContextAdapter.Remove怎么用?C# IInternalContextAdapter.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInternalContextAdapter
的用法示例。
在下文中一共展示了IInternalContextAdapter.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: Render
//.........这里部分代码省略.........
ViewComponentCacheBag cachedContent = (ViewComponentCacheBag) cacheProvider.Get(key.ToString());
if (cachedContent != null)
{
// Restore entries
foreach(KeyValuePair<string, object> pair in cachedContent.ContextEntries)
{
context[pair.Key] = pair.Value;
}
// Render from cache
writer.Write(cachedContent.Content);
return true;
}
isOutputtingToCache = true;
bag = new ViewComponentCacheBag();
}
}
ViewComponent component = viewComponentFactory.Create(componentName);
if (component == null)
{
throw new MonoRailException("ViewComponentFactory returned a null ViewComponent for " + componentName + ". " +
"Please investigate the implementation: " + viewComponentFactory.GetType().FullName);
}
try
{
ASTDirective directiveNode = (ASTDirective) node;
IViewRenderer renderer = (IViewRenderer) directiveNode.Directive;
NVelocityViewContextAdapter contextAdapter = new NVelocityViewContextAdapter(componentName, node, viewEngine, renderer);
contextAdapter.Context = isOutputtingToCache ? new CacheAwareContext(context, bag) : context;
INode bodyNode = null;
if (node.ChildrenCount > 0)
{
bodyNode = node.GetChild(node.ChildrenCount - 1);
}
TextWriter output = isOutputtingToCache ? bag.CacheWriter : writer;
contextAdapter.BodyNode = bodyNode;
contextAdapter.ComponentParams = componentParams;
contextAdapter.TextWriter = output;
component.Init(railsContext, contextAdapter);
ProcessSubSections(component, contextAdapter);
const string ViewComponentContextKey = "viewcomponent";
object previousComp = context[ViewComponentContextKey];
try
{
context[ViewComponentContextKey] = component;
component.Render();
if (contextAdapter.ViewToRender != null)
{
RenderComponentView(context, contextAdapter.ViewToRender, output, contextAdapter);
}
if (isOutputtingToCache)
{
// Save output
cacheProvider.Store(key.ToString(), bag);
// Output to correct writer
writer.Write(bag.Content);
}
}
finally
{
if (previousComp != null)
{
context[ViewComponentContextKey] = previousComp;
}
else
{
context.Remove(ViewComponentContextKey);
}
}
}
finally
{
viewComponentFactory.Release(component);
}
return true;
}