本文整理汇总了C#中FlexWiki.ExecutionContext.AddCacheRule方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext.AddCacheRule方法的具体用法?C# ExecutionContext.AddCacheRule怎么用?C# ExecutionContext.AddCacheRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexWiki.ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.AddCacheRule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExposedAbout
public string ExposedAbout(ExecutionContext ctx)
{
ctx.AddCacheRule(CacheRuleForFederationProperties);
return AboutWikiString;
}
示例2: ExposedContentBaseForNamespace
public ContentBase ExposedContentBaseForNamespace(ExecutionContext ctx, string ns)
{
ctx.AddCacheRule(this.CacheRuleForNamespaces);
ContentBase answer = ContentBaseForNamespace(ns);
if (answer != null)
{
ctx.AddCacheRule(answer.CacheRuleForDefinition);
}
return answer;
}
示例3: EvaluateToObject
public IBELObject EvaluateToObject(TopicContext topicContext, Hashtable externalWikimap)
{
_CacheRules = new ArrayList();
if (ParseTree == null)
{
ErrorString = "Expression can not be evaluated; parse failed.";
State = InterpreterState.EvaluationFailure;
return null;
}
ExecutionContext ctx = new ExecutionContext(topicContext);
ctx.WikiTalkVersion = WikiTalkVersion;
IBELObject answer = null;
try
{
ctx.ExternalWikiMap = externalWikimap;
IScope theScope = null;
ctx.Presenter = Presenter;
TopicInfo topic = topicContext != null ? topicContext.CurrentTopic : null;
if (topic != null && topic.Fullname != null)
{
// Locate any topics via the NamespaceWith property to see if there's anybody else we should import (for all topics in the namespace)
ArrayList nswith = topicContext.CurrentFederation.GetTopicInfo(ctx, topicContext.CurrentTopic.ContentBase.DefinitionTopicName.Fullname).GetListProperty("NamespaceWith");
if (nswith != null)
{
nswith.Reverse();
foreach (string top in nswith)
{
AbsoluteTopicName abs = topic.ContentBase.UnambiguousTopicNameFor(new RelativeTopicName(top));
if (abs == null)
{
throw new Exception("No such topic: " + top + " (as specifed in NamespaceWith: property for " + topicContext.CurrentTopic.ContentBase.DefinitionTopicName.Fullname + ")");
}
theScope = new TopicScope(theScope, new DynamicTopic(topic.Federation, abs));
ctx.AddCacheRule(new TopicsCacheRule(topic.Federation, abs));
}
}
// Locate any topics via the with property to see if there's anybody else we should import
ArrayList with = topicContext.CurrentTopic.GetListProperty("With");
if (with != null)
{
with.Reverse();
foreach (string top in with)
{
AbsoluteTopicName abs = topic.ContentBase.UnambiguousTopicNameFor(new RelativeTopicName(top));
if (abs == null)
{
throw new Exception("No such topic: " + top + " (as specifed in With: property for " + topicContext.CurrentTopic + ")");
}
theScope = new TopicScope(theScope, new DynamicTopic(topic.Federation, abs));
ctx.AddCacheRule(new TopicsCacheRule(topic.Federation, abs));
}
}
// add the topic to the current scope (this guy goes at the front of the queue!)
theScope = new TopicScope(theScope, new DynamicTopic(topic.Federation, topic.Fullname));
}
if (theScope != null)
ctx.PushScope(theScope); // make sure we can use local references
// parse tree -> live objects
answer = ParseTree.Expose(ctx);
if (theScope != null)
ctx.PopScope();
_CacheRules = ctx.CacheRules;
}
catch (Exception e)
{
_CacheRules = ctx.CacheRules;
ErrorString = e.Message;
State = InterpreterState.EvaluationFailure;
return null;
}
State = InterpreterState.EvaluationSuccess;
return answer;
}
示例4: DynamicTopicForTopic
public DynamicTopic DynamicTopicForTopic(ExecutionContext ctx, string top)
{
AbsoluteTopicName abs = new AbsoluteTopicName(top);
if (abs.Namespace == null)
{
throw new Exception("Only fully-qualified topic names can be used with GetTopic(): only got " + top);
}
DynamicNamespace dns = DynamicNamespaceForNamespace(ctx, abs.Namespace);
ctx.AddCacheRule(new TopicsCacheRule(this, abs));
return dns.DynamicTopicFor(abs.Name);
}
示例5: Property
public string Property(ExecutionContext ctx, string topic, string property)
{
AbsoluteTopicName abs = null;
bool ambig = false;
string answer = null;
try
{
ContentBase cb = ctx.CurrentContentBase;
if (cb == null)
cb = ctx.CurrentFederation.DefaultContentBase;
RelativeTopicName rel = new RelativeTopicName(topic);
ctx.AddCacheRule(cb.CacheRuleForAllPossibleInstancesOfTopic(rel));
abs = cb.UnambiguousTopicNameFor(rel);
}
catch (TopicIsAmbiguousException)
{
ambig = true;
}
if (abs != null)
{
// Got a unique one!
answer = ctx.CurrentFederation.GetTopicProperty(abs, property);
}
else
{
if (ambig)
throw new ArgumentException("Ambiguous topic name: " + topic);
else
throw new ArgumentException("Unknown topic name: " + topic);
}
return answer;
}
示例6: Topics
public ArrayList Topics(ExecutionContext ctx)
{
ArrayList answer = new ArrayList();
foreach (AbsoluteTopicName name in AllTopics(false))
answer.Add(new TopicInfo(Federation, name));
// Add cache rules for all the topics in the namespaces and for the definition (in case the imports change)
ctx.AddCacheRule(new AllTopicsInNamespaceCacheRule(Federation, Namespace));
return answer;
}
示例7: ExposedName
public string ExposedName(ExecutionContext ctx)
{
ctx.AddCacheRule(CacheRuleForDefinition);
return Namespace;
}
示例8: ValueOf
//.........这里部分代码省略.........
InvocationFrame invocationFrame = new InvocationFrame();
if (needExecutionContext)
args.Add(ctx);
ArrayList parameterPresentFlags = null;
if (needExecutionContext)
{
parameterPresentFlags = new ArrayList();
parameterPresentFlags.Add(true); // we know for sure the first arg is supplied; it's the execution context :-)
}
int offset = (needExecutionContext ? 1 : 0);
for (int each = offset; each < parms.Length; each++)
{
object arg = null;
if (arguments != null && (each - offset) < arguments.Count)
arg = (ParseTreeNode)(arguments[each - offset]);
if (!BELMember.IsOptionalParameter(parms[each]) && arg == null)
throw new MemberInvocationException(ctx.CurrentLocation, "Missing argument " + (each - offset) + " for " + ExternalTypeName + "." + name);
if (parameterPresentFlags != null)
parameterPresentFlags.Add(arg != null);
if (mi.ExposedMethod.IsCustomArgumentProcessor)
{
args.Add(arg);
}
else
{
if (arg == null)
args.Add(AbsentValueForParameter(parms[each]));
else
args.Add(ConvertFromBELObjectIfNeeded(((ExposableParseTreeNode)arg).Expose(ctx)));
}
}
invocationFrame.WasParameterSuppliedFlags = parameterPresentFlags;
// If we have extras (beyond those needed) and they're allowed, stash them in the MIC, too
if (mi.ExposedMethod.AllowsVariableArguments)
{
ArrayList extras = new ArrayList();
int extraCount = got - need;
if (arguments != null)
{
for (int i = need; i < got; i++)
{
object arg = arguments[i];
if (mi.ExposedMethod.IsCustomArgumentProcessor)
{
extras.Add(arg);
}
else
{
if (arg == null)
extras.Add(null);
else
extras.Add(ConvertFromBELObjectIfNeeded(((ExposableParseTreeNode)arg).Expose(ctx)));
}
}
}
invocationFrame.ExtraArguments = extras;
}
// Check types
for (int each = 0; each < parms.Length; each++)
{
bool bad = false;
if (args[each] == null)
{
if (parms[each].ParameterType.IsValueType)
bad = true;
}
else
{
if (!parms[each].ParameterType.IsAssignableFrom(args[each].GetType()))
bad = true;
}
if (bad)
throw new MemberInvocationException(ctx.CurrentLocation, "Argument " + (each + 1) + " for " + ExternalTypeName + "." + name + " is not of the correct type (was "
+ ExternalTypeNameForType(args[each].GetType()) +
", but needed " + ExternalTypeNameForType(parms[each].ParameterType) + ")");
}
// And now, invoke away!!
object result = null;
invocationFrame.PushScope(ctx.CurrentScope); // the new frame starts with the same scope as this one
ctx.PushFrame(invocationFrame);
if (Federation.GetPerformanceCounter(Federation.PerformanceCounterNames.MethodInvocation) != null)
Federation.GetPerformanceCounter(Federation.PerformanceCounterNames.MethodInvocation).Increment();
try
{
result = mi.MethodInfo.Invoke(this, args.ToArray());
}
catch (TargetInvocationException ex)
{
throw ex.InnerException;
}
ctx.PopFrame();
if (mi.ExposedMethod.CachePolicy == ExposedMethodFlags.CachePolicyNever)
ctx.AddCacheRule(new CacheRuleNever());
return Wrap(result);
}
示例9: ExposedImageURL
public string ExposedImageURL(ExecutionContext ctx)
{
ctx.AddCacheRule(CacheRuleForDefinition);
return ImageURL;
}
示例10: ExposedTitle
public string ExposedTitle(ExecutionContext ctx)
{
ctx.AddCacheRule(CacheRuleForDefinition);
return FriendlyTitle;
}
示例11: ExposedContact
public string ExposedContact(ExecutionContext ctx)
{
ctx.AddCacheRule(CacheRuleForDefinition);
return Contact;
}
示例12: ExposedDescription
public string ExposedDescription(ExecutionContext ctx)
{
ctx.AddCacheRule(CacheRuleForDefinition);
return Description;
}
示例13: AllNamespacesWithDetails
public string AllNamespacesWithDetails(ExecutionContext ctx)
{
ArrayList files = new ArrayList();
StringBuilder b = new StringBuilder();
ArrayList bases = new ArrayList();
Federation fed =ctx.CurrentFederation;
foreach (string ns in fed.Namespaces)
{
ContentBase cb = fed.ContentBaseForNamespace(ns);
bases.Add(cb);
ctx.AddCacheRule(cb.CacheRuleForDefinition);
}
// And now add the namespace map itself
ctx.AddCacheRule(fed.CacheRuleForNamespaces);
bases.Sort();
foreach (ContentBase info in bases)
{
b.Append(
"||\"" + info.FriendlyTitle + "\":" + info.Namespace + "." + info.HomePage +
"||" + info.Description +
"||" + (info.Contact == null ? "" : info.Contact) +
"||\n");
}
return b.ToString();
}
示例14: ExposedNamespaces
public ArrayList ExposedNamespaces(ExecutionContext ctx)
{
ctx.AddCacheRule(this.CacheRuleForNamespaces);
return AllNamespaces;
}
示例15: ExposedImports
public ArrayList ExposedImports(ExecutionContext ctx)
{
ctx.AddCacheRule(CacheRuleForDefinition);
ArrayList answer = new ArrayList();
foreach (ContentBase cb in ImportedContentBases)
answer.Add(cb);
return answer;
}