コード例 #1
0
ファイル: ProxyExtensions.cs プロジェクト: tralivali1234/moq
 /// <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));
     }
 }
コード例 #2
0
ファイル: ProxyExtensions.cs プロジェクト: tralivali1234/moq
 /// <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));
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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)))
 {
 }
コード例 #8
0
ファイル: ProxyExtensions.cs プロジェクト: tralivali1234/moq
 /// <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));
 }
コード例 #9
0
ファイル: ProxyExtensions.cs プロジェクト: tralivali1234/moq
 /// <summary>
 /// Adds a behavior to a proxy.
 /// </summary>
 public static void AddProxyBehavior(this IProxy proxy, InvokeBehavior behavior)
 {
     proxy.Behaviors.Add(ProxyBehavior.Create(behavior));
 }