public bool TryGetValue(int methodHash, out DynamicProxyOnBuilder value)
 {
     value = null;
     if (!this.List.ContainsKey(methodHash))
     {
         return(false);
     }
     value = this.List[methodHash];
     return(true);
 }
 public void Add(int methodHash, DynamicProxyOnBuilder onBuilder)
 {
     if (this.List.ContainsKey(methodHash))
     {
         this.Set(methodHash, onBuilder);
     }
     else
     {
         this.List.Add(methodHash, onBuilder);
     }
 }
Exemple #3
0
        public DynamicProxyOnBuilder On(MethodInfo method)
        {
            var builder = new DynamicProxyOnBuilder();

            if (method.ReturnType != typeof(void))
            {
                builder.ReturnType = method.ReturnType;
            }
            this.ProxyCalls.Add(method.GetHashCode(), builder);
            return(builder);
        }
Exemple #4
0
        public DynamicProxyOnBuilder On <T1, TReturn>(Expression <Func <T, Func <T1, TReturn> > > expression) where TReturn : class
        {
            ConstantExpression methExpression = null;
            var obj            = (expression.Body is UnaryExpression ? ((UnaryExpression)expression.Body).Operand : expression.Body);
            var callExpression = obj as MethodCallExpression;

            if (callExpression != null)
            {
                methExpression = (ConstantExpression)callExpression.Object;
            }
            var methodInfo = methExpression.Value as MethodInfo;

            var ret = new DynamicProxyOnBuilder();

            this.ProxyCalls.Set(methodInfo.GetHashCode(), ret);
            return(ret);
        }