Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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)))
 {
 }
Exemplo n.º 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)))
 {
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }