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


C# IContext.Add方法代码示例

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


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

示例1: Render

        public override void Render(HttpContextBase httpContext, IContext requestContext)
        {
            if (httpContext.Session != null)
                foreach (object key in httpContext.Session.Keys)
                {
                    if (requestContext.Contains(key))
                        throw new ApplicationException(String.Format("{0} is present on both the Session and the Request.", key));

                    requestContext.Add(key.ToString(), httpContext.Session[key.ToString()]);
                }

            try
            {
                var templateTuple = manager.RenderTemplate(requestContext.Response.RenderTarget, (IDictionary<string, object>)requestContext);
                manager = templateTuple.Item1;
                TextReader reader = templateTuple.Item2;
                char[] buffer = new char[4096];
                int count = 0;
                while ((count = reader.ReadBlock(buffer, 0, 4096)) > 0)
                    httpContext.Response.Write(buffer, 0, count);
            }
            catch (Exception ex)
            {
                httpContext.Response.StatusCode = 500;
                httpContext.Response.Write(RenderException(requestContext.Response.RenderTarget, ex, true));
            }
        }
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:27,代码来源:DjangoEngine.cs

示例2: InvokeMethod

        /// <summary>
        /// Obtains and processes the chain of controllers servicing this request. If a transfer is requested
        /// during the processing of a controller, the computed chain of controllers finishes, and then a
        /// recursive call is made to process the new contrller.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="requestPoint">The request point.</param>
        /// <param name="requestContext">The request context.</param>
        public virtual void InvokeMethod(HttpContextBase context, string requestPoint, IContext requestContext)
        {
            logger.Report(Messages.ProcessingRequest, requestPoint);

            try
            {
                InvokeMethodDirect(context, requestPoint, requestContext);
            }
            catch (Exception ex)
            {
                if (!IsMethodDefinedExplicitly(Application.UnhandledException))
                    throw;

                requestContext.Clear();
                requestContext.Add("unhandledException", ex);

                InvokeMethodDirect(context, Application.UnhandledException, requestContext);
            }
        }
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:27,代码来源:MethodDispatcher.cs

示例3: Execute

 public bool Execute(IContext context)
 {
     context.Add(FILTER_KEY, this);
     return false;
 }
开发者ID:benouarred,项目名称:struts-archive,代码行数:5,代码来源:TestFilterCommand.cs

示例4: InvokeMethod


//.........这里部分代码省略.........

								// we only care about the actual return value of the last controller, as intermediate
								// results can be overriden by subsequent controllers. discard intermediate return values.
								securityCheckFailed = !securityController.HasAccess(requestContext, failedPermissions);
							}
						}

						// we have to do the check a second time, because the securityCheckComplete flag
						// gets set inside the top if. doing this in an else up top would skip the first
						// non-security controller
						if (securityCheckComplete)
						{
							if (securityCheckFailed || failedPermissions.Count != 0)
							{
								StringBuilder builder = new StringBuilder();
								foreach (string perm in failedPermissions.Keys)
									builder.AppendLine(perm);

								foreach (KeyValuePair<FailAction, string> kvp in failedPermissions.Values)
									if (kvp.Key == FailAction.Redirect)
									{
										// currently you can only house one transfer request per context, 
										// however, that may change in the future.
										requestContext.ClearTransferRequest();

										// give the fail action target a chance to redirect after re-validating
										requestContext.Transfer(
											kvp.Value +
											(kvp.Value.Contains("?") ? "&" : "?") +
											"originalRequest=" +
											HttpUtility.UrlEncode(requestPoint));

										logger.Report(Messages.SecurityRedirect, kvp.Value, builder.ToString());
										break;
									}

                                if (!requestContext.TransferRequested)
                                    throw new WebException(StatusCode.Unauthorized, "Access denied");
                                else
                                    // break out of the controller loop. we shouldn't be processing any more
                                    // controllers for this request, and need to get into whatever the security
                                    // guys requested
                                    break;
                            }
                            else
                            {
								if (invocationInfo.BindPoint.Controller.DefaultTemplates.Count > 0)
									requestContext.Response.RenderWith(invocationInfo.BindPoint.Controller.DefaultTemplates);

								sw1.Reset();
								sw1.Start();
								controller.ProcessRequest(context, requestContext);
								sw1.Stop();

							}
						}
					}
					finally
					{
						manager.ReturnController(controller, context, requestContext);
						sw.Stop();
						logger.Report(Messages.ControllerInvoked, sw.ElapsedMilliseconds.ToString(),sw1.ElapsedMilliseconds.ToString(), invocationInfo.BindPoint.Controller.ControllerTypeName);

					}
				}

				if (requestContext.TransferRequested)
				{
					string transferRequestPoint = BindPointUtilities.VerbQualify(requestContext.TransferTarget, "get");
					requestContext.ClearTransferRequest();

                    InvokeMethod(context, transferRequestPoint, requestContext);
                }
            }
            catch (Exception ex)
            {
				try
				{
					logger.Report(Messages.UnhandledException,ex.Message,ex.StackTrace);
				}
				catch
				{}

                //Assume that there are some other ctrls which match UnhandledException url and cause an exception.
                //In this case, removing this check may cause an infinite recursion of InvokeMethod and StackOverflow at the end.
                if (handleException)
                    throw new ApplicationException("Cannot process UnhandledException url, maybe some other controllers also match this url and cause an exception", ex);

				if (!IsMethodDefinedExplicitly(Application.UnhandledException))
				{
					throw new ApplicationException("Unhandled exception, and no binding to " + Application.UnhandledException + " found.", ex);
				}

                requestContext.Clear();
                requestContext.Add("unhandledException", ex);

				InvokeMethod(context, Application.UnhandledException, requestContext, true);
                
			}
        }
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:101,代码来源:MethodDispatcher.cs


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