Exemple #1
0
        internal static OwinAppContext Build(Action<IAppBuilder> startup)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            var appContext = new OwinAppContext();
            appContext.Initialize(startup);
            return appContext;
        }
Exemple #2
0
        internal static OwinAppContext Build(Action<IAppBuilder> startup)
        {
            if (startup == null)
            {
                return null;
            }

            var appContext = new OwinAppContext();
            appContext.Initialize(startup);
            return appContext;
        }
Exemple #3
0
        internal static OwinAppContext Build(Action <IAppBuilder> startup)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            var appContext = new OwinAppContext();

            appContext.Initialize(startup);
            return(appContext);
        }
Exemple #4
0
        internal static OwinAppContext Build(Action <IAppBuilder> startup)
        {
            if (startup == null)
            {
                return(null);
            }

            var appContext = new OwinAppContext();

            appContext.Initialize(startup);
            return(appContext);
        }
Exemple #5
0
        /// <summary>
        /// Initialize an OwinRouteHandler
        /// </summary>
        /// <param name="startup">The method to initialize the pipeline that processes requests for the route.</param>
        public OwinRouteHandler(Action <IAppBuilder> startup)
        {
            _pathBase = Utils.NormalizePath(HttpRuntime.AppDomainAppVirtualPath);

            OwinAppContext app         = null;
            bool           initialized = false;
            var            syncLock    = new object();

            _appAccessor = () => LazyInitializer.EnsureInitialized(
                ref app,
                ref initialized,
                ref syncLock,
                () => OwinBuilder.Build(startup));
        }
Exemple #6
0
        private IntegratedPipelineBlueprint InitializeBlueprint()
        {
            IntegratedPipelineBlueprintStage firstStage = null;

            Action <IAppBuilder> startup    = OwinBuilder.GetAppStartup();
            OwinAppContext       appContext = OwinBuilder.Build(builder =>
            {
                EnableIntegratedPipeline(builder, stage => firstStage = stage);
                startup.Invoke(builder);
            });

            string basePath = Utils.NormalizePath(HttpRuntime.AppDomainAppVirtualPath);

            return(new IntegratedPipelineBlueprint(appContext, firstStage, basePath));
        }
Exemple #7
0
        public IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object extraData)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }

            try
            {
                OwinAppContext appContext = _appAccessor.Invoke();

                if (appContext == null)
                {
                    throw new EntryPointNotFoundException(Resources.Exception_NoOwinEntryPointFound);
                }

                // REVIEW: the httpContext.Request.RequestContext may be used here if public property unassigned?
                RequestContext requestContext  = _requestContext ?? new RequestContext(httpContext, new RouteData());
                string         requestPathBase = _pathBase;
                string         requestPath     = _requestPath ?? httpContext.Request.AppRelativeCurrentExecutionFilePath.Substring(1) + httpContext.Request.PathInfo;

                OwinCallContext callContext = appContext.CreateCallContext(
                    requestContext,
                    requestPathBase,
                    requestPath,
                    callback,
                    extraData);

                try
                {
                    callContext.Execute();
                }
                catch (Exception ex)
                {
                    callContext.AsyncResult.Complete(true, ErrorState.Capture(ex));
                }
                return(callContext.AsyncResult);
            }
            catch (Exception ex)
            {
                var failedAsyncResult = new CallContextAsyncResult(null, callback, extraData);
                failedAsyncResult.Complete(true, ErrorState.Capture(ex));
                return(failedAsyncResult);
            }
        }
        internal OwinCallContext(
            OwinAppContext appContext,
            RequestContext requestContext,
            string requestPathBase,
            string requestPath,
            AsyncCallback cb,
            object extraData)
        {
            _appContext      = appContext;
            _requestContext  = requestContext;
            _requestPathBase = requestPathBase;
            _requestPath     = requestPath;

            AsyncResult = new CallContextAsyncResult(this, cb, extraData);

            _httpContext  = _requestContext.HttpContext;
            _httpRequest  = _httpContext.Request;
            _httpResponse = _httpContext.Response;
        }
Exemple #9
0
        internal OwinCallContext(
            OwinAppContext appContext,
            RequestContext requestContext,
            string requestPathBase,
            string requestPath,
            AsyncCallback cb,
            object extraData)
        {
            _trace = TraceFactory.Create(TraceName);

            _appContext = appContext;
            _requestContext = requestContext;
            _requestPathBase = requestPathBase;
            _requestPath = requestPath;

            AsyncResult = new CallContextAsyncResult(this, cb, extraData);

            _httpContext = _requestContext.HttpContext;
            _httpRequest = _httpContext.Request;
            _httpResponse = _httpContext.Response;
        }
        internal OwinCallContext(
            OwinAppContext appContext,
            RequestContext requestContext,
            string requestPathBase,
            string requestPath,
            AsyncCallback cb,
            object extraData)
        {
            _appContext = appContext;
            _requestContext = requestContext;
            _requestPathBase = requestPathBase;
            _requestPath = requestPath;

            AsyncResult = new CallContextAsyncResult(this, cb, extraData);

            _httpContext = _requestContext.HttpContext;
            _httpRequest = _httpContext.Request;
            _httpResponse = _httpContext.Response;

            _disconnectWatcher = new DisconnectWatcher(_httpResponse);
        }
Exemple #11
0
        internal OwinCallContext(
            OwinAppContext appContext,
            RequestContext requestContext,
            string requestPathBase,
            string requestPath,
            AsyncCallback cb,
            object extraData)
        {
            _appContext      = appContext;
            _requestContext  = requestContext;
            _requestPathBase = requestPathBase;
            _requestPath     = requestPath;

            AsyncResult = new CallContextAsyncResult(this, cb, extraData);

            _httpContext  = _requestContext.HttpContext;
            _httpRequest  = _httpContext.Request;
            _httpResponse = _httpContext.Response;

            _disconnectWatcher = new DisconnectWatcher(_httpResponse);
            RegisterForOnSendingHeaders();
        }
Exemple #12
0
 internal OwinHttpHandler(string pathBase, OwinAppContext app)
     : this(pathBase, () => app)
 {
 }
 internal OwinHttpHandler(string pathBase, OwinAppContext app)
     : this(pathBase, () => app)
 {
 }