Beispiel #1
0
        public void Init(HttpApplication context)
        {
            IntegratedPipelineBlueprint blueprint = LazyInitializer.EnsureInitialized(
                ref _blueprint,
                ref _blueprintInitialized,
                ref _blueprintLock,
                InitializeBlueprint);

            if (blueprint != null)
            {
                var integratedPipelineContext = new IntegratedPipelineContext(blueprint);
                integratedPipelineContext.Initialize(context);
            }
        }
Beispiel #2
0
        private static void EnableIntegratedPipeline(IAppBuilder app, Action <IntegratedPipelineBlueprintStage> onStageCreated)
        {
            var stage = new IntegratedPipelineBlueprintStage {
                Name = "PreHandlerExecute"
            };

            onStageCreated(stage);
            Action <IAppBuilder, string> stageMarker = (builder, name) =>
            {
                Func <AppFunc, AppFunc> decoupler = next =>
                {
                    if (string.Equals(name, stage.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        // no decoupling needed when pipeline is already split at this name
                        return(next);
                    }
                    if (!IntegratedPipelineContext.VerifyStageOrder(name, stage.Name))
                    {
                        // Stage markers added out of order will be ignored.
                        // Out of order stages/middleware may be run earlier than expected.
                        // TODO: LOG
                        return(next);
                    }
                    stage.EntryPoint = next;
                    stage            = new IntegratedPipelineBlueprintStage
                    {
                        Name      = name,
                        NextStage = stage,
                    };
                    onStageCreated(stage);
                    return((AppFunc)IntegratedPipelineContext.ExitPointInvoked);
                };
                app.Use(decoupler);
            };

            app.Properties[Constants.IntegratedPipelineStageMarker] = stageMarker;
            app.Properties[Constants.BuilderDefaultApp]             = (Func <IDictionary <string, object>, Task>)IntegratedPipelineContext.DefaultAppInvoked;
        }