本文整理汇总了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");
};
}
示例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();
}
}
}
示例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());
}
示例4: GetApplicationTypeEvents
Hashtable GetApplicationTypeEvents (HttpApplication app)
{
if (have_app_events)
return app_event_handlers;
return GetApplicationTypeEvents (app.GetType ());
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
}
示例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;
}
示例10: FireContainerInitialized
void FireContainerInitialized( HttpApplication instance, DefaultMonoRailContainer container )
{
ExecuteContainerEvent(
instance.GetType().GetMethod( "MonoRail_ContainerInitialized" ),
instance,
container );
}