コード例 #1
0
        /// <summary>
        /// Register a new step into the pipeline.
        /// </summary>
        /// <param name="behavior">The behavior instance.</param>
        /// <param name="description">The description of the behavior.</param>
        public void Register <T>(T behavior, string description)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), nameof(behavior));

            Register(typeof(T).Name, behavior, description);
        }
コード例 #2
0
        /// <summary>
        /// Replaces an existing step behavior with a new one.
        /// </summary>
        /// <param name="stepId">The identifier of the step to replace its implementation.</param>
        /// <param name="newBehavior">The new <see cref="Behavior{TContext}" /> to use.</param>
        /// <param name="description">The description of the new behavior.</param>
        public void Replace(string stepId, Type newBehavior, string description = null)
        {
            BehaviorTypeChecker.ThrowIfInvalid(newBehavior, nameof(newBehavior));
            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);

            modifications.Replacements.Add(new ReplaceStep(stepId, newBehavior, description));
        }
コード例 #3
0
        /// <summary>
        /// Register a new step into the pipeline.
        /// </summary>
        /// <param name="factoryMethod">A callback that creates the behavior instance.</param>
        /// <param name="description">The description of the behavior.</param>
        public void Register <T>(Func <IServiceProvider, T> factoryMethod, string description)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), "behavior");

            Register(typeof(T).Name, factoryMethod, description);
        }
コード例 #4
0
        /// <summary>
        /// Replaces an existing step behavior with a new one.
        /// </summary>
        /// <param name="stepId">The identifier of the step to replace its implementation.</param>
        /// <param name="factoryMethod">The factory method to create new instances of the behavior.</param>
        /// <param name="description">The description of the new behavior.</param>
        public void Replace <T>(string stepId, Func <IBuilder, T> factoryMethod, string description = null)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), "newBehavior");
            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);

            modifications.Replacements.Add(new ReplaceStep(stepId, typeof(T), description, b => factoryMethod(b)));
        }
コード例 #5
0
        /// <summary>
        /// Replaces an existing step behavior with a new one.
        /// </summary>
        /// <param name="stepId">The identifier of the step to replace its implementation.</param>
        /// <param name="newBehavior">The new <see cref="Behavior{TContext}" /> to use.</param>
        /// <param name="description">The description of the new behavior.</param>
        public void Replace <T>(string stepId, T newBehavior, string description = null)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), nameof(newBehavior));
            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);

            modifications.Replacements.Add(new ReplaceStep(stepId, typeof(T), description, builder => newBehavior));
        }
コード例 #6
0
        /// <summary>
        /// Register a new step into the pipeline.
        /// </summary>
        /// <param name="stepId">The identifier of the new step to add.</param>
        /// <param name="behavior">The <see cref="Behavior{TContext}" /> to execute.</param>
        /// <param name="description">The description of the behavior.</param>
        public void Register(string stepId, Type behavior, string description)
        {
            BehaviorTypeChecker.ThrowIfInvalid(behavior, nameof(behavior));

            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);
            Guard.AgainstNullAndEmpty(nameof(description), description);

            modifications.Additions.Add(RegisterStep.Create(stepId, behavior, description));
        }
コード例 #7
0
        /// <summary>
        /// Registers a new step behavior or replaces the existing one with the same id with a new one.
        /// </summary>
        /// <param name="stepId">The identifier of the step to replace its implementation.</param>
        /// <param name="behavior">The new <see cref="Behavior{TContext}" /> to use.</param>
        /// <param name="description">The description of the new behavior.</param>
        public void RegisterOrReplace(string stepId, Type behavior, string description = null)
        {
            BehaviorTypeChecker.ThrowIfInvalid(behavior, nameof(behavior));
            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);
            EnsureWriteEnabled(stepId, nameof(Replace));
            EnsureWriteEnabled(stepId, nameof(Register));

            modifications.AdditionsOrReplacements.Add(RegisterOrReplaceStep.Create(stepId, behavior, description));
        }
コード例 #8
0
        /// <summary>
        /// Register a new step into the pipeline.
        /// </summary>
        /// <param name="stepId">The identifier of the new step to add.</param>
        /// <param name="behavior">The behavior instance.</param>
        /// <param name="description">The description of the behavior.</param>
        public void Register <T>(string stepId, T behavior, string description)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), nameof(behavior));

            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);
            Guard.AgainstNullAndEmpty(nameof(description), description);

            modifications.Additions.Add(RegisterStep.Create(stepId, typeof(T), description, _ => behavior));
        }
コード例 #9
0
        /// <summary>
        /// Register a new step into the pipeline.
        /// </summary>
        /// <param name="stepId">The identifier of the new step to add.</param>
        /// <param name="factoryMethod">A callback that creates the behavior instance.</param>
        /// <param name="description">The description of the behavior.</param>
        public void Register <T>(string stepId, Func <IBuilder, T> factoryMethod, string description)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), "behavior");

            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);
            Guard.AgainstNullAndEmpty(nameof(description), description);

            modifications.Additions.Add(RegisterStep.Create(stepId, typeof(T), description, b => factoryMethod(b)));
        }
コード例 #10
0
        /// <summary>
        /// Registers a new step behavior or replaces the existing one with the same id with a new one.
        /// </summary>
        /// <param name="stepId">The identifier of the step to replace its implementation.</param>
        /// <param name="behavior">The new <see cref="Behavior{TContext}" /> to use.</param>
        /// <param name="description">The description of the new behavior.</param>
        public void RegisterOrReplace <T>(string stepId, T behavior, string description = null)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), nameof(behavior));
            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);
            EnsureWriteEnabled(stepId, nameof(Replace));
            EnsureWriteEnabled(stepId, nameof(Register));

            modifications.AdditionsOrReplacements.Add(RegisterOrReplaceStep.Create(stepId, typeof(T), description, builder => behavior));
        }
コード例 #11
0
        /// <summary>
        /// Registers a new step behavior or replaces the existing one with the same id with a new one.
        /// </summary>
        /// <param name="stepId">The identifier of the step to replace its implementation.</param>
        /// <param name="factoryMethod">The factory method to create new instances of the behavior.</param>
        /// <param name="description">The description of the new behavior.</param>
        public void RegisterOrReplace <T>(string stepId, Func <IServiceProvider, T> factoryMethod, string description = null)
            where T : IBehavior
        {
            BehaviorTypeChecker.ThrowIfInvalid(typeof(T), "behavior");
            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);
            EnsureWriteEnabled(stepId, nameof(Replace));
            EnsureWriteEnabled(stepId, nameof(Register));

            modifications.AdditionsOrReplacements.Add(RegisterOrReplaceStep.Create(stepId, typeof(T), description, b => factoryMethod(b)));
        }
コード例 #12
0
ファイル: RegisterStep.cs プロジェクト: wzl-bxg/NServiceBus
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterStep" /> class.
        /// </summary>
        /// <param name="stepId">The unique identifier for this steps.</param>
        /// <param name="behavior">The type of <see cref="Behavior{TContext}" /> to register.</param>
        /// <param name="description">A brief description of what this step does.</param>
        /// <param name="factoryMethod">A factory method for creating the behavior.</param>
        protected RegisterStep(string stepId, Type behavior, string description, Func <IServiceProvider, IBehavior> factoryMethod = null)
        {
            this.factoryMethod = factoryMethod;
            BehaviorTypeChecker.ThrowIfInvalid(behavior, "behavior");
            Guard.AgainstNullAndEmpty(nameof(stepId), stepId);
            Guard.AgainstNullAndEmpty(nameof(description), description);

            BehaviorType = behavior;
            StepId       = stepId;
            Description  = description;
        }
コード例 #13
0
ファイル: PipelineSettings.cs プロジェクト: wulg/NServiceBus
        /// <summary>
        /// Replaces an existing step behavior with a new one.
        /// </summary>
        /// <param name="stepId">The identifier of the step to replace its implementation.</param>
        /// <param name="newBehavior">The new <see cref="IBehavior{TContext}"/> to use.</param>
        /// <param name="description">The description of the new behavior.</param>
        public void Replace(string stepId, Type newBehavior, string description = null)
        {
            BehaviorTypeChecker.ThrowIfInvalid(newBehavior, "newBehavior");

            if (string.IsNullOrEmpty(stepId))
            {
                throw new ArgumentNullException("stepId");
            }

            config.Settings.Get <PipelineModifications>().Replacements.Add(new ReplaceBehavior(stepId, newBehavior, description));
        }
コード例 #14
0
ファイル: PipelineSettings.cs プロジェクト: wulg/NServiceBus
        /// <summary>
        /// Register a new step into the pipeline.
        /// </summary>
        /// <param name="stepId">The identifier of the new step to add.</param>
        /// <param name="behavior">The <see cref="IBehavior{TContext}"/> to execute.</param>
        /// <param name="description">The description of the behavior.</param>
        public void Register(string stepId, Type behavior, string description)
        {
            BehaviorTypeChecker.ThrowIfInvalid(behavior, "behavior");

            if (string.IsNullOrEmpty(stepId))
            {
                throw new ArgumentNullException("stepId");
            }

            if (string.IsNullOrEmpty(description))
            {
                throw new ArgumentNullException("description");
            }

            config.Settings.Get <PipelineModifications>().Additions.Add(RegisterStep.Create(stepId, behavior, description));
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterStep"/> class.
        /// </summary>
        /// <param name="stepId">The unique identifier for this steps.</param>
        /// <param name="behavior">The type of <see cref="IBehavior{TContext}"/> to register.</param>
        /// <param name="description">A brief description of what this step does.</param>
        protected RegisterStep(string stepId, Type behavior, string description)
        {
            BehaviorTypeChecker.ThrowIfInvalid(behavior, "behavior");

            if (String.IsNullOrEmpty(stepId))
            {
                throw new ArgumentNullException("stepId");
            }

            if (String.IsNullOrEmpty(description))
            {
                throw new ArgumentNullException("description");
            }

            BehaviorType = behavior;
            StepId       = stepId;
            Description  = description;
        }
コード例 #16
0
        /// <summary>
        /// Register a new step into the pipeline.
        /// </summary>
        /// <param name="behavior">The <see cref="Behavior{TContext}" /> to execute.</param>
        /// <param name="description">The description of the behavior.</param>
        public void Register(Type behavior, string description)
        {
            BehaviorTypeChecker.ThrowIfInvalid(behavior, nameof(behavior));

            Register(behavior.Name, behavior, description);
        }