Exemple #1
0
        /// <summary>
        /// Invokes a method remotely, and returns the result
        /// </summary>
        /// <returns>The result of the remote invocation.</returns>
        /// <param name="handle">The remote instance handle, or zero for null.</param>
        /// <param name="method">The method to invoke remotely.</param>
        /// <param name="arguments">The values given to the method when invoked.</param>
        /// <param name="isWrite">If set to <c>true</c> this is a write field or property request.</param>
        public Task <object> InvokeRemoteMethodAsync(long handle, System.Reflection.MemberInfo method, object[] arguments, bool isWrite)
        {
            var methodstring = m_typeSerializer.GetShortDefinition(method);
            var type         = m_typeSerializer.GetShortTypeName(method.DeclaringType);

            Type[] methodtypes;
            if (method is System.Reflection.MethodInfo)
            {
                var mi = method as System.Reflection.MethodInfo;
                methodtypes = mi.GetParameters().Select(x => x.ParameterType).ToArray();
            }
            else if (method is System.Reflection.ConstructorInfo)
            {
                var ci = method as System.Reflection.ConstructorInfo;
                methodtypes = ci.GetParameters().Select(x => x.ParameterType).ToArray();
            }
            else if (method is System.Reflection.FieldInfo)
            {
                if (isWrite)
                {
                    methodtypes = new Type[] { ((System.Reflection.FieldInfo)method).FieldType }
                }
                ;
                else
                {
                    methodtypes = new Type[0];
                }
            }
            else if (method is System.Reflection.PropertyInfo)
            {
                var pi         = method as System.Reflection.PropertyInfo;
                var indexTypes = pi.GetIndexParameters().Select(x => x.ParameterType);
                if (isWrite)
                {
                    indexTypes = new Type[] { pi.PropertyType }
                }