Ejemplo n.º 1
0
        public ControllerActionMeta(string actionFullName, Type controllerType, MethodInfo methodInfo)
        {
            ActionFullName = actionFullName;
            ControllerType = controllerType;
            TargetMethod   = methodInfo;
            Parametergs    = methodInfo.GetParameters();

            DisposableArgsIndex = GetDisposableArgsIndex(Parametergs);

            TcpNoDelay = Attribute.IsDefined(methodInfo, typeof(TcpNoDelayAttribute));

            var protobufAttrib = methodInfo.GetCustomAttribute <ProducesProtoBufAttribute>();

            if (protobufAttrib != null)
            {
                SerializerDelegate = ExtensionMethods.SerializeObjectProtobuf;
                ProducesEncoding   = ProducesProtoBufAttribute.Encoding;
            }
            else
            {
                // Сериализатор по умолчанию — Json.
                SerializerDelegate = ExtensionMethods.SerializeObjectJson;
                ProducesEncoding   = KnownEncoding.JsonEncoding;
            }

            FastInvokeDelegate = DynamicMethodFactory.CreateMethodCall(methodInfo, skipConvertion: true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Dynamic Method.
        /// </summary>
        public static object InvokeFast(this MethodInfo methodInfo, object instance, object[] args, bool skipConvertion = true)
        {
            Func <object, object[], object> func = _methodsDict.GetOrAdd(methodInfo, m => DynamicMethodFactory.CreateMethodCall(m, skipConvertion));
            object result = func.Invoke(instance, args);

            return(result);
        }