protected override void TestSetUp ()
		{
			base.TestSetUp ();

			helper = null;
			expectedSender = new object ();
			expectedEventArgs = new EventArgs ();
		}
Exemplo n.º 2
0
        public WebApiApplication()
        {
            var asyncHandler = new EventHandlerTaskAsyncHelper(AuthorizeRequestAsync);
            AddOnAuthorizeRequestAsync(asyncHandler.BeginEventHandler, asyncHandler.EndEventHandler);

            asyncHandler = new EventHandlerTaskAsyncHelper(PreRequestHandlerExecuteAsync);
            AddOnPreRequestHandlerExecuteAsync(asyncHandler.BeginEventHandler, asyncHandler.EndEventHandler);
        }
Exemplo n.º 3
0
        public void Init(HttpApplication context)
        {
            var settings = new PortalSettings(new ConfigurationProvider());
            var url = new MongoUrl(settings.MongoConnectionString);
            _userRepository = new UserRepository(url);

            var asyncHelper = new EventHandlerTaskAsyncHelper(AuthenticateRequestAsync);
            context.AddOnAuthenticateRequestAsync(asyncHelper.BeginEventHandler, asyncHelper.EndEventHandler);
        }
Exemplo n.º 4
0
 public void Init(HttpApplication context)
 {
     context.BeginRequest += CreateEventHandler(OnBeginRequest);
     context.EndRequest += CreateEventHandler(OnEndRequest);
     context.AuthenticateRequest += CreateEventHandler(OnAuthenticateRequest);
     context.Error += CreateEventHandler(OnError);
     context.MapRequestHandler += CreateEventHandler(OnMapRequest);
     var asynchelper = new EventHandlerTaskAsyncHelper(OnBeginRequestAsync);
     context.AddOnBeginRequestAsync(asynchelper.BeginEventHandler, asynchelper.EndEventHandler);
 }
        public void Init(HttpApplication context)
        {
            if (webLogger == null)
                return;

            context.BeginRequest += context_BeginRequest;
            context.Error += context_Error;

            EventHandlerTaskAsyncHelper asyncHelper = new EventHandlerTaskAsyncHelper(context_LogRequest);
            context.AddOnLogRequestAsync(asyncHelper.BeginEventHandler, asyncHelper.EndEventHandler);
        }
		protected override IAsyncResult GetAsyncResult (Func<Task> taskFactory, AsyncCallback callback, object state)
		{
			Assert.IsNull (helper, "GetAsyncResult#A01");

			TaskEventHandler handler = (sender, e) => {
				Assert.AreSame (expectedSender, sender, "GetAsyncResult#A02");
				Assert.AreSame (expectedEventArgs, e, "GetAsyncResult#A03");

				return taskFactory ();
			};

			helper = new EventHandlerTaskAsyncHelper (handler);
			return helper.BeginEventHandler (expectedSender, expectedEventArgs, callback, state);
		}
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">
        /// An <see cref="T:System.Web.HttpApplication"/> that provides 
        /// access to the methods, properties, and events common to all 
        /// application objects within an ASP.NET application
        /// </param>
        public void Init(HttpApplication context)
        {
#if NET45

            EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
            context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler);

#else

            context.PostAuthorizeRequest += this.PostAuthorizeRequest;

#endif

            context.PreSendRequestHeaders += this.ContextPreSendRequestHeaders;
        }
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">
        /// An <see cref="T:System.Web.HttpApplication"/> that provides 
        /// access to the methods, properties, and events common to all 
        /// application objects within an ASP.NET application
        /// </param>
        public void Init(HttpApplication context)
        {
            if (!this.hasModuleInitialized)
            {
                Interlocked.CompareExchange(ref initCheck, 1, 0);
                DiskCache.CreateDirectories();
            }

#if NET45

            EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
            context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler);

#else

            context.PostAuthorizeRequest += this.PostAuthorizeRequest;

#endif

            context.PreSendRequestHeaders += this.ContextPreSendRequestHeaders;
        }
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">
        /// An <see cref="T:System.Web.HttpApplication"/> that provides
        /// access to the methods, properties, and events common to all
        /// application objects within an ASP.NET application
        /// </param>
        public void Init(HttpApplication context)
        {
            if (preserveExifMetaData == null)
            {
                preserveExifMetaData = ImageProcessorConfiguration.Instance.PreserveExifMetaData;
            }

            EventHandlerTaskAsyncHelper postAuthorizeHelper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
            context.AddOnPostAuthorizeRequestAsync(postAuthorizeHelper.BeginEventHandler, postAuthorizeHelper.EndEventHandler);

            context.PostReleaseRequestState += this.PostReleaseRequestState;

            EventHandlerTaskAsyncHelper postProcessHelper = new EventHandlerTaskAsyncHelper(this.PostProcessImage);
            context.AddOnEndRequestAsync(postProcessHelper.BeginEventHandler, postProcessHelper.EndEventHandler);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">
        /// An <see cref="T:System.Web.HttpApplication"/> that provides 
        /// access to the methods, properties, and events common to all 
        /// application objects within an ASP.NET application
        /// </param>
        public void Init(HttpApplication context)
        {
            if (remotePrefix == null)
            {
                remotePrefix = ImageProcessorConfig.Instance.RemotePrefix;
            }

            if (preserveExifMetaData == null)
            {
                preserveExifMetaData = ImageProcessorConfig.Instance.PreserveExifMetaData;
            }

#if NET45
            EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
            context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler);
#else
            context.PostAuthorizeRequest += this.PostAuthorizeRequest;
#endif
            context.PreSendRequestHeaders += this.ContextPreSendRequestHeaders;
        }
 public void Init(HttpApplication app)
 {
     var asyncHelper = new EventHandlerTaskAsyncHelper(OnEndRequestAsync);
     app.AddOnEndRequestAsync(asyncHelper.BeginEventHandler, asyncHelper.EndEventHandler);
     app.PreSendRequestHeaders += context_PreSendRequestHeaders;
 }
		public void Constructor_NullHandler ()
		{
			var helper = new EventHandlerTaskAsyncHelper (null);
		}
		public void Constructor ()
		{
			var helper = new EventHandlerTaskAsyncHelper (DummyTaskEventHandler);
		}
		public void EndEventHandler ()
		{
			var helper = new EventHandlerTaskAsyncHelper (DummyTaskEventHandler);

			Assert.IsNotNull (helper.EndEventHandler, "#A01");
		}
 public void Init(HttpApplication context)
 {
     var authenticateRequestHelper = new EventHandlerTaskAsyncHelper(OnAuthenticateRequest);
     context.AddOnAuthenticateRequestAsync(authenticateRequestHelper.BeginEventHandler, authenticateRequestHelper.EndEventHandler);
 }
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="application">
        /// An <see cref="T:System.Web.HttpApplication"/> that provides
        /// access to the methods, properties, and events common to all
        /// application objects within an ASP.NET application
        /// </param>
        public void Init(HttpApplication application)
        {
            if (preserveExifMetaData == null)
            {
                preserveExifMetaData = ImageProcessorConfiguration.Instance.PreserveExifMetaData;
            }

            if (allowCacheBuster == null)
            {
                allowCacheBuster = ImageProcessorConfiguration.Instance.AllowCacheBuster;
            }

            if (fixGamma == null)
            {
                fixGamma = ImageProcessorConfiguration.Instance.FixGamma;
            }

            if (interceptAllRequests == null)
            {
                interceptAllRequests = ImageProcessorConfiguration.Instance.InterceptAllRequests;
            }

            EventHandlerTaskAsyncHelper postAuthorizeHelper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
            application.AddOnPostAuthorizeRequestAsync(postAuthorizeHelper.BeginEventHandler, postAuthorizeHelper.EndEventHandler);

            application.PostReleaseRequestState += this.PostReleaseRequestState;

            EventHandlerTaskAsyncHelper onEndRquestsHelper = new EventHandlerTaskAsyncHelper(this.OnEndRequest);
            application.AddOnEndRequestAsync(onEndRquestsHelper.BeginEventHandler, onEndRquestsHelper.EndEventHandler);
        }
		/// <summary>
		/// Initializes the module derived from IHttpModule when called by the HttpRuntime . 
		/// </summary>
		/// <param name="httpapp">The HttpApplication module</param>
		public void Init(HttpApplication httpapp)
		{
			this.app = httpapp;
            var wrapper = new EventHandlerTaskAsyncHelper(OnAuthenticate);
            app.AddOnAuthenticateRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler);
		}