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


C# ExecutionContext.AddCacheRule方法代码示例

本文整理汇总了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;
 }
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:Federation.cs

示例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;
 }
开发者ID:nuxleus,项目名称:flexwiki,代码行数:10,代码来源:Federation.cs

示例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;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:78,代码来源:BehaviorInterpreter.cs

示例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);
 }
开发者ID:nuxleus,项目名称:flexwiki,代码行数:11,代码来源:Federation.cs

示例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;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:32,代码来源:ClassicBehaviors.cs

示例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;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:11,代码来源:ContentBase.cs

示例7: ExposedName

		public string ExposedName(ExecutionContext ctx)
		{
			ctx.AddCacheRule(CacheRuleForDefinition);
			return Namespace;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:ContentBase.cs

示例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);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:101,代码来源:ReflectedValueSource.cs

示例9: ExposedImageURL

		public string ExposedImageURL(ExecutionContext ctx)
		{
			ctx.AddCacheRule(CacheRuleForDefinition);
			return ImageURL;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:ContentBase.cs

示例10: ExposedTitle

		public string ExposedTitle(ExecutionContext ctx)
		{
			ctx.AddCacheRule(CacheRuleForDefinition);
			return FriendlyTitle;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:ContentBase.cs

示例11: ExposedContact

		public string ExposedContact(ExecutionContext ctx)
		{
			ctx.AddCacheRule(CacheRuleForDefinition);
			return Contact;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:ContentBase.cs

示例12: ExposedDescription

		public string ExposedDescription(ExecutionContext ctx)
		{
			ctx.AddCacheRule(CacheRuleForDefinition);
			return Description;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:ContentBase.cs

示例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();
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:26,代码来源:ClassicBehaviors.cs

示例14: ExposedNamespaces

 public ArrayList ExposedNamespaces(ExecutionContext ctx)
 {
   ctx.AddCacheRule(this.CacheRuleForNamespaces);
   return AllNamespaces;
 }
开发者ID:nuxleus,项目名称:flexwiki,代码行数:5,代码来源:Federation.cs

示例15: ExposedImports

		public ArrayList ExposedImports(ExecutionContext ctx)
		{
			ctx.AddCacheRule(CacheRuleForDefinition);
			ArrayList answer = new ArrayList();
			foreach (ContentBase cb in ImportedContentBases)
				answer.Add(cb);
			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:8,代码来源:ContentBase.cs


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