Exemple #1
0
 /// <summary>
 /// Inserts a behavior into the proxy behasvior pipeline at the specified
 /// index.
 /// </summary>
 public static void InsertProxyBehavior(this object proxy, int index, InvokeBehavior behavior)
 {
     if (proxy is IProxy target)
     {
         target.Behaviors.Insert(index, ProxyBehavior.Create(behavior));
     }
     else
     {
         throw new ArgumentException(nameof(proxy));
     }
 }
Exemple #2
0
 /// <summary>
 /// Adds a behavior to a proxy.
 /// </summary>
 public static void AddProxyBehavior(this object proxy, InvokeBehavior behavior)
 {
     if (proxy is IProxy target)
     {
         target.Behaviors.Add(ProxyBehavior.Create(behavior));
     }
     else
     {
         throw new ArgumentException(nameof(proxy));
     }
 }
Exemple #3
0
        /// <summary>
        /// Inserts a behavior into the proxy behasvior pipeline at the specified
        /// index.
        /// </summary>
        public static TProxy InsertBehavior <TProxy>(this TProxy proxy, int index, InvokeBehavior behavior, AppliesTo appliesTo = null, string name = null)
        {
            if (proxy is IProxy target)
            {
                target.Behaviors.Insert(index, ProxyBehavior.Create(behavior, appliesTo, name));
            }
            else
            {
                throw new ArgumentException(nameof(proxy));
            }

            return(proxy);
        }
Exemple #4
0
        /// <summary>
        /// Adds a behavior to a proxy.
        /// </summary>
        public static TProxy AddBehavior <TProxy>(this TProxy proxy, InvokeBehavior behavior, AppliesTo appliesTo = null, string name = null)
        {
            // We can't just add a constraint to the method signature, because
            // proxies are typically geneated and don't expose the IProxy interface directly.
            if (proxy is IProxy target)
            {
                target.Behaviors.Add(ProxyBehavior.Create(behavior, appliesTo, name));
            }
            else
            {
                throw new ArgumentException(nameof(proxy));
            }

            return(proxy);
        }
Exemple #5
0
 /// <summary>
 /// Inserts a behavior into the proxy behavior pipeline at the specified
 /// index.
 /// </summary>
 public static IProxy InsertBehavior(this IProxy proxy, int index, InvokeBehavior behavior, AppliesTo appliesTo = null, string name = null)
 {
     proxy.Behaviors.Insert(index, ProxyBehavior.Create(behavior, appliesTo, name));
     return(proxy);
 }
Exemple #6
0
 /// <summary>
 /// Adds a behavior to a proxy.
 /// </summary>
 public static IProxy AddBehavior(this IProxy proxy, InvokeBehavior behavior, AppliesTo appliesTo = null, string name = null)
 {
     proxy.Behaviors.Add(ProxyBehavior.Create(behavior, appliesTo, name));
     return(proxy);
 }
Exemple #7
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 => ProxyBehavior.Create(behavior)))
 {
 }
Exemple #8
0
 /// <summary>
 /// Inserts a behavior into the proxy behavior pipeline at the specified
 /// index.
 /// </summary>
 public static void InsertProxyBehavior(this IProxy proxy, int index, InvokeBehavior behavior)
 {
     proxy.Behaviors.Insert(index, ProxyBehavior.Create(behavior));
 }
Exemple #9
0
 /// <summary>
 /// Adds a behavior to a proxy.
 /// </summary>
 public static void AddProxyBehavior(this IProxy proxy, InvokeBehavior behavior)
 {
     proxy.Behaviors.Add(ProxyBehavior.Create(behavior));
 }