コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FilterActionAnnotation"/> class describing a FilterAction.
        /// </summary>
        /// <param name="actionName">Name of the action.</param>
        /// <param name="flowBehavior">The flow behavior of the filter action indicating how a certain FilterAction influences the flow through the filterset.</param>
        /// <param name="substitutionBehavior">The substitution behavior of the filter action.</param>
        /// <remarks>Place this attribute only at classes inheriting the <see cref="T:FilterType"></see> base class since the filter action must implement the <c>Execute</c> method.</remarks>
        /// <example>
        /// Place this custom attribute on classes inheriting <see cref="T:FilterAction"></see> like in the following example.
        /// <code>
        /// [FilterActionAttribute("TracingInAction", FilterFlowBehavior.Continue, MessageSubstitutionBehavior.Original)]
        /// public class TracingInAction : FilterAction
        /// {
        /// public override void Execute(JoinPointContext context)
        /// {
        /// }
        /// }
        /// </code>
        /// In this example, the name of the filter action is <c>TracingInAction</c>, the flow behavior is <c>continue</c> and the message substitution behavior is <c>original</c>.
        /// The <c>TracingInAction</c> class implements the <c>Execute</c> function with a custom implementation of the filter action. In this case, it will perform some sort of tracing operation.
        /// </example>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="name"/> is <see langword="null"></see> or empty, this exception is thrown.
        /// </exception>
        public FilterActionAttribute(string actionName, FilterFlowBehavior flowBehavior, MessageSubstitutionBehavior substitutionBehavior)
        {
            if (string.IsNullOrEmpty(actionName))
            {
                throw new ArgumentNullException("actionName");
            }

            _actionName           = actionName;
            _flowBehavior         = flowBehavior;
            _substitutionBehavior = substitutionBehavior;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FilterActionAnnotation"/> class describing a FilterAction.
        /// </summary>
        /// <param name="actionName">The unique name of the filter action.</param>
        /// <param name="flowBehavior">The flow behavior of the filter action indicating how a certain FilterAction influences the flow through the filterset.</param>
        /// <param name="substitutionBehavior">The substitution behavior of the filter action.</param>
        /// <param name="createJoinPointContext">if set to <c>true</c>, the weaver injects a join point context object to be used in the <c>Execute</c> method.
        /// When <c>false</c>, this step will be skipped and a null reference is placed instead of a Join Point Context.</param>
        /// <remarks>Place this attribute only at classes inheriting the <see cref="T:FilterType"></see> base class since the filter action must implement the <c>Execute</c> method.</remarks>
        /// <example>
        /// Place this custom attribute on classes inheriting <see cref="T:FilterAction"></see> like in the following example.
        /// <code>
        /// [FilterActionAttribute("TracingInAction", FilterFlowBehavior.Continue, MessageSubstitutionBehavior.Original, false)]
        /// public class TracingInAction : FilterAction
        /// {
        ///    public override void Execute(JoinPointContext context)
        ///    {
        ///       // Because the createJoinPointContext parameter is false, the context will be null!
        ///    }
        /// }
        /// </code>
        /// In this example, the name of the filter action is <c>TracingInAction</c>, the flow behavior is <c>continue</c> and the message substitution behavior is <c>original</c>.
        /// The <c>TracingInAction</c> class implements the <c>Execute</c> function with a custom implementation of the filter action.
        /// In this case, it can not use the JoinPointContext because the Attribute indicates that a JoinPointContext is not needed for this filter action.
        /// </example>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="name"/> is <see langword="null"></see> or empty, this exception is thrown.
        /// </exception>
        public FilterActionAttribute(string actionName, FilterFlowBehavior flowBehavior, MessageSubstitutionBehavior substitutionBehavior, bool createJoinPointContext)
        {
            if (string.IsNullOrEmpty(actionName))
            {
                throw new ArgumentNullException("actionName");
            }

            _actionName           = actionName;
            _flowBehavior         = flowBehavior;
            _substitutionBehavior = substitutionBehavior;
            _createJPC            = createJoinPointContext;
        }