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


C# IContext.Put方法代码示例

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


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

示例1: HandleRequest

	/// <summary>
	/// Override HandleRequest method so that what is put in the context and what template
	/// is loaded can be determined by this application.
	/// </summary>
	/// <param name="request"></param>
	/// <param name="response"></param>
	/// <param name="ctx"></param>
	/// <returns></returns>
	protected override Template HandleRequest(HttpContext context, IContext ctx ) {

	    // invoke handleRequest
	    // request.Path holds the entire path to the file from the root of the web (i.e. /nvelocity/examples/simplehttp/foo/bar/template.vm)
	    // request.ApplicationPath should hold the path to the root of this application (i.e. /nvelocity/examples/simplehttp)
	    // the difference between the (changeing case to lower as they may not be the same) is the path from the root to the file (i.e. /foo/bar/template.vm)
	    String template = context.Request.Path;
	    if (template.ToLower().StartsWith(context.Request.ApplicationPath.ToLower())) {
		template = template.Substring(context.Request.ApplicationPath.Length)
		;
	    }

	    ctx.Put("page", context.Request.Path);
	    ctx.Put("template", template)
	    ;

	    Template t = GetTemplate(template)
	    ;
	    if (t == null) {
		throw new System.Exception ("HandleRequest(HttpContext, IContext) returned null - no template selected!" );
	    }

	    return t;
	}
开发者ID:DF-thangld,项目名称:web_game,代码行数:32,代码来源:SimpleNVelocityHandler.cs

示例2: RenderLayout

		protected void RenderLayout(string layoutName, string contents, IContext ctx, TextWriter output)
		{
			ctx.Put(TemplateKeys.ChildContent, contents);

			var template = velocity.GetTemplate(layoutName);

			BeforeMerge(velocity, template, ctx);

			template.Merge(ctx, output);
		}
开发者ID:john-surcombe,项目名称:Castle.MonoRail,代码行数:10,代码来源:NVelocityViewEngine.cs

示例3: populateInitialContext

	/// <summary>
	/// <p>Place useful objects into the initial context.</p>
	/// <p>TexenTask places <code>Date().toString()</code> into the
	/// context as <code>$now</code>.  Subclasses who want to vary the
	/// objects in the context should override this method.</p>
	/// <p><code>$generator</code> is not put into the context in this
	/// method.</p>
	/// </summary>
	/// <param name="context">The context to populate, as retrieved from
	/// {@link #initControlContext()}.
	/// @throws Exception Error while populating context.  The {@link
	/// #execute()} method will catch and rethrow as a
	/// <code>BuildException</code>.
	/// </param>
	protected internal virtual void  populateInitialContext(IContext context) {
	    context.Put("now", System.DateTime.Now.ToString("r"));
	}
开发者ID:DF-thangld,项目名称:web_game,代码行数:17,代码来源:TexenTask.cs

示例4: fillContextProperties

	/// <summary> Add objects to the context from the current properties.
	/// *
	/// </summary>
	/// <param name="Context">control context to fill with objects
	/// that are specified in the default.properties
	/// file
	///
	/// </param>
	protected internal virtual void  fillContextProperties(IContext context) {
	    IDictionaryEnumerator enum_Renamed = props.GetEnumerator();

	    while (enum_Renamed.MoveNext()) {
		DictionaryEntry de = (DictionaryEntry)enum_Renamed.Current;
		String nm = (String)de.Key;
		if (nm.StartsWith("context.objects.")) {

		    System.String contextObj = (System.String) props.GetString(nm);
		    int colon = nm.LastIndexOf((System.Char) '.');
		    System.String contextName = nm.Substring(colon + 1);

		    //try {
		    Log.WriteLine(LogPrefix + "loading " + contextObj + " as " + nm);
		    System.Type cls = System.Type.GetType(contextObj);
		    System.Object o = System.Activator.CreateInstance(cls);
		    context.Put(contextName, o);
		    //} catch (System.Exception e) {
		    //	SupportClass.WriteStackTrace(e, Console.Error);
		    //	//TO DO: Log Something Here
		    //}
		}
	    }
	}
开发者ID:DF-thangld,项目名称:web_game,代码行数:32,代码来源:Generator.cs

示例5: fillContextDefaults

	/// <summary> Add properties that will aways be in the context by default
	/// *
	/// </summary>
	/// <param name="Context">control context to fill with default values.
	///
	/// </param>
	protected internal virtual void  fillContextDefaults(IContext context) {
	    context.Put("generator", instance);
	    context.Put("outputDirectory", OutputPath);
	}
开发者ID:DF-thangld,项目名称:web_game,代码行数:10,代码来源:Generator.cs

示例6: fillContextHash

	///
	/// <summary> Add all the contents of a Hashtable to the context.
	/// *
	/// </summary>
	/// <param name="Context">context to fill with objects
	/// </param>
	/// <param name="Hashtable">source of objects
	///
	/// </param>
	protected internal virtual void  fillContextHash(IContext context, System.Collections.Hashtable objs) {
	    System.Collections.IEnumerator enum_Renamed = (System.Collections.IEnumerator) objs.Keys;
	    //UPGRADE_TODO: method 'java.util.Enumeration.hasMoreElements' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationhasMoreElements"'
	    while (enum_Renamed.MoveNext()) {
		//UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1043"'
		//UPGRADE_TODO: method 'java.util.Enumeration.nextElement' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationnextElement"'
		System.String key = enum_Renamed.Current.ToString();
		context.Put(key, objs[key]);
	    }
	}
开发者ID:DF-thangld,项目名称:web_game,代码行数:19,代码来源:Generator.cs

示例7: RenderLayout

		protected void RenderLayout(string layoutName, string contents, IContext ctx, IRailsEngineContext context, TextWriter output)
		{
			try
			{
				ctx.Put(TemplateKeys.ChildContent, contents);

				Template template = velocity.GetTemplate(layoutName);

				BeforeMerge(velocity, template, ctx);

				template.Merge(ctx, output);
			}
			catch(Exception ex)
			{
				if (context.Request.IsLocal)
				{
					SendErrorDetails(ex, context.Response.Output);
				}
				else
				{
					throw new RailsException("Error processing layout. Maybe the layout file does not exists? File: " + layoutName, ex);
				}
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:24,代码来源:NVelocityViewEngine.cs


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