/// <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)); } }
/// <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)); } }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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))) { }
/// <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)); }
/// <summary> /// Adds a behavior to a proxy. /// </summary> public static void AddProxyBehavior(this IProxy proxy, InvokeBehavior behavior) { proxy.Behaviors.Add(ProxyBehavior.Create(behavior)); }