Пример #1
0
        /// <summary>
        /// Inserts a behavior into the stunt behavior pipeline at the specified
        /// index.
        /// </summary>
        public static TStunt InsertBehavior <TStunt>(this TStunt stunt, int index, ExecuteDelegate behavior, AppliesTo appliesTo = null, string name = null)
        {
            if (stunt is IStunt target)
            {
                target.Behaviors.Insert(index, StuntBehavior.Create(behavior, appliesTo, name));
            }
            else
            {
                throw new ArgumentException(nameof(stunt));
            }

            return(stunt);
        }
Пример #2
0
        /// <summary>
        /// Adds a behavior to a stunt.
        /// </summary>
        public static TStunt AddBehavior <TStunt>(this TStunt stunt, ExecuteDelegate behavior, AppliesTo appliesTo = null, string name = null)
        {
            // We can't just add a constraint to the method signature, because
            // proxies are typically generated and don't expose the IProxy interface directly.
            if (stunt is IStunt target)
            {
                target.Behaviors.Add(StuntBehavior.Create(behavior, appliesTo, name));
            }
            else
            {
                throw new ArgumentException(nameof(stunt));
            }

            return(stunt);
        }
Пример #3
0
 /// <summary>
 /// Creates a new <see cref="BehaviorPipeline"/> with the given set of
 /// <see cref="ExecuteDelegate"/> delegates.
 /// </summary>
 /// <param name="behaviors">Behaviors to add to the pipeline.</param>
 public BehaviorPipeline(IEnumerable <ExecuteDelegate> behaviors)
     : this(behaviors.Select(behavior => StuntBehavior.Create(behavior)))
 {
 }
Пример #4
0
 /// <summary>
 /// Creates a new <see cref="BehaviorPipeline"/> with the given set of
 /// <see cref="InvokeBehavior"/> delegates.
 /// </summary>
 /// <param name="behaviors">Behaviors to add to the pipeline.</param>
 public BehaviorPipeline(IEnumerable <InvokeBehavior> behaviors)
     : this(behaviors.Select(behavior => StuntBehavior.Create(behavior)))
 {
 }
Пример #5
0
 /// <summary>
 /// Inserts a behavior into the stunt behavior pipeline at the specified
 /// index.
 /// </summary>
 public static IStunt InsertBehavior(this IStunt stunt, int index, ExecuteDelegate behavior, AppliesTo appliesTo = null, string name = null)
 {
     stunt.Behaviors.Insert(index, StuntBehavior.Create(behavior, appliesTo, name));
     return(stunt);
 }
Пример #6
0
 /// <summary>
 /// Adds a behavior to a stunt.
 /// </summary>
 public static IStunt AddBehavior(this IStunt stunt, ExecuteDelegate behavior, AppliesTo appliesTo = null, string name = null)
 {
     stunt.Behaviors.Add(StuntBehavior.Create(behavior, appliesTo, name));
     return(stunt);
 }