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


C# HttpApplication.GetType方法代码示例

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


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

示例1: Init

        public void Init(HttpApplication app) {

            string[] events = { "BeginRequest", "AuthenticateRequest",
                "PostAuthenticateRequest", "AuthorizeRequest", "ResolveRequestCache",
                "PostResolveRequestCache", "MapRequestHandler", "PostMapRequestHandler",
                "AcquireRequestState", "PostAcquireRequestState", 
                "PreRequestHandlerExecute", "PostRequestHandlerExecute", 
                 "ReleaseRequestState", "PostReleaseRequestState",
                "UpdateRequestCache", "LogRequest", "PostLogRequest",
                "EndRequest", "PreSendRequestHeaders", "PreSendRequestContent"};


            MethodInfo methodInfo = GetType().GetMethod("HandleEvent");
            foreach (string name in events) {
                EventInfo evInfo = app.GetType().GetEvent(name);

                evInfo.AddEventHandler(app, 
                    Delegate.CreateDelegate(evInfo.EventHandlerType,
                        this, methodInfo));
            }

            app.Error += (src, args) => {
                System.Diagnostics.Debug.WriteLine("Event: Error");
            };
        }
开发者ID:kinshines,项目名称:Pro.ASP.NET.MVC.5.Platform,代码行数:25,代码来源:EventListModule.cs

示例2: DisposeHttpApplication

        /// <summary>
        /// Disposes of the HTTP applications that was created as an entry point.
        /// </summary>
        private void DisposeHttpApplication()
        {
            HttpApplication httpApplication = this.httpApplication;
            this.httpApplication = null;

            if (httpApplication != null)
            {
                try
                {
                    MethodInfo method = HttpApplicationProbe.FindExitPoint(httpApplication.GetType());

                    if (method != null)
                    {
                        this.logger.Info("Invoking exit point for HTTP application {0}.", httpApplication.GetType().FullName);
                        this.InvokeEventHandler(httpApplication, method);
                    }
                    else
                    {
                        this.logger.Info("No exit point found for HTTP application {0}.", httpApplication.GetType().FullName);
                    }
                }
                finally
                {
                    httpApplication.Dispose();
                }
            }
        }
开发者ID:ChadBurggraf,项目名称:blue-collar,代码行数:30,代码来源:MachineProxy.cs

示例3: Init

        /// <summary>
        ///     Register for events
        /// </summary>
        /// <param name="context"></param>
        public void Init(HttpApplication context)
        {
            context.PostRequestHandlerExecute += this.OnPostRequestHandlerExecute;
            context.PreRequestHandlerExecute += this.OnPreRequestHandlerExecute;
            context.PostMapRequestHandler += this.OnPostMapRequestHandler;

            // Connect runtime
            this._runtime.Subscribe(this);

            // Map application context
            this.MapApplicationContext(context.GetType());
        }
开发者ID:jstemerdink,项目名称:owasp-esapi-dotnet,代码行数:16,代码来源:EsapiRuntimeModule.cs

示例4: GetApplicationTypeEvents

		Hashtable GetApplicationTypeEvents (HttpApplication app)
		{
			if (have_app_events)
				return app_event_handlers;

			return GetApplicationTypeEvents (app.GetType ());
		}
开发者ID:vargaz,项目名称:mono,代码行数:7,代码来源:HttpApplicationFactory.cs

示例5: GetContext

		/// <summary>
		/// Creates a new pseudo HttpContext and uses reflection to mimic what would happen
		/// in an ASP.net hosting environment.  Reflection is used only on the properties required
		/// by the session state module.
		/// </summary>
		/// <param name="request">Pseudo request object used in the context</param>
		/// <param name="response">Pseudo response object used in the context</param>
		/// <returns>A pseudo HttpContext object</returns>
		private HttpContext GetContext(out HttpRequest request, out HttpResponse response)
		{
			request = new HttpRequest("dummy.txt", "http://localhost/dummy.txt", string.Empty);

			HttpApplication httpApp = new HttpApplication();
			HttpApplicationState stateValue = (HttpApplicationState)Activator.CreateInstance(typeof(HttpApplicationState), true);

			var httpAppFactoryType = httpApp.GetType().Assembly.GetType("System.Web.HttpApplicationFactory");
			var httpAppFactory = Activator.CreateInstance(httpAppFactoryType, true);
			var httpAppFactoryStaticInstanceField = httpAppFactoryType.GetField("_theApplicationFactory", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
			var theHttpAppFactory = httpAppFactoryStaticInstanceField.GetValue(httpAppFactory);

			var httpAppStateField = httpAppFactoryType.GetField("_state", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
			httpAppStateField.SetValue(theHttpAppFactory, stateValue);

			var stateField = httpApp.GetType().GetField("_state", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
			stateField.SetValue(httpApp, stateValue);

			response = new HttpResponse(null);

			return new HttpContext(request, response);
		}
开发者ID:stratusdata,项目名称:MongoDB.Web,代码行数:30,代码来源:CacheTests.cs

示例6: Init

        /// <summary>
        /// Register for events
        /// </summary>
        /// <param name="context"></param>
        public void Init(HttpApplication context)
        {
            context.PostRequestHandlerExecute+= new EventHandler(OnPostRequestHandlerExecute);
            context.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
            context.PostMapRequestHandler += new EventHandler(OnPostMapRequestHandler);

            // Connect runtime
            _runtime.Subscribe(this);

            // Map application context
            MapApplicationContext(context.GetType());
        }
开发者ID:rsheynin,项目名称:owasp-esapi-dotnet,代码行数:16,代码来源:EsapiRuntimeModule.cs

示例7: ForHttpApplication

 /// <summary>
 /// Attach the <see cref="HttpApplication"/> that the <see cref="DreamApplication"/> to be built will be attached to.
 /// </summary>
 /// <param name="application">HttpApplication to attach to.</param>
 /// <returns>Current builder instance.</returns>
 public DreamApplicationConfigurationBuilder ForHttpApplication(HttpApplication application)
 {
     return WithApplicationAssembly(application.GetType().BaseType.Assembly);
 }
开发者ID:heran,项目名称:DReAM,代码行数:9,代码来源:DreamApplicationConfigurationBuilder.cs

示例8: GetGlobalAssembly

 private static Assembly GetGlobalAssembly(HttpApplication app)
 {
     if (_globalAssembly != null) return _globalAssembly;
     lock (_syncRoot)
     {
         if (_globalAssembly != null) return _globalAssembly;
         if (app == null) throw new ApplicationException();
         Type t = app.GetType();
         while (t != null && t.Namespace == "ASP")
         {
             t = t.BaseType;
         }
         if (t == null) throw new ApplicationException();
         _globalAssembly = Assembly.GetAssembly(t);
         return _globalAssembly;
     }
 }
开发者ID:ranyjax,项目名称:WebApi,代码行数:17,代码来源:ApiRouteHandler.cs

示例9: ObtainConfiguration

		IMonoRailConfiguration ObtainConfiguration( HttpApplication appInstance )
		{
			IMonoRailConfiguration config = MonoRailConfiguration.GetConfig();
			MethodInfo method = appInstance.GetType().GetMethod( "MonoRail_Configure" );

			if ( method != null )
			{
				config = config ?? new MonoRailConfiguration();

				if ( method.IsStatic )
				{
					method.Invoke( null, new object[] { config } );
				}
				else
				{
					method.Invoke( appInstance, new object[] { config } );
				}
			}

			if ( config == null )
			{
				throw new ApplicationException( "You have to provide a small configuration to use MonoRail. This can be done using the web.config or your global asax (your class that extends HttpApplication) through the method MonoRail_Configure(IMonoRailConfiguration config). Check the samples or the documentation." );
			}

			return config;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:26,代码来源:MonoRailHttpHandlerFactoryEx.cs

示例10: FireContainerInitialized

		void FireContainerInitialized( HttpApplication instance, DefaultMonoRailContainer container )
		{
			ExecuteContainerEvent( 
				instance.GetType().GetMethod( "MonoRail_ContainerInitialized" ), 
				instance, 
				container );
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:MonoRailHttpHandlerFactoryEx.cs


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