GetExtraProperties() static private method

static private GetExtraProperties ( IDictionary properties, string internalKeys ) : object[]
properties IDictionary
internalKeys string
return object[]
コード例 #1
0
        public static void WriteMethodResponse(BinaryWriter writer, object obj, Header[] headers, ISurrogateSelector surrogateSelector, StreamingContext context, FormatterAssemblyStyle assemblyFormat, FormatterTypeStyle typeFormat)
        {
            IMethodReturnMessage methodReturnMessage = (IMethodReturnMessage)obj;

            writer.Write(22);
            string[] array = MethodReturnDictionary.InternalReturnKeys;
            int      num   = 0;
            object   obj2  = null;

            object[]      array2      = null;
            MethodFlags   methodFlags = MethodFlags.ExcludeLogicalCallContext;
            ReturnTypeTag returnTypeTag;

            if (methodReturnMessage.Exception != null)
            {
                returnTypeTag = (ReturnTypeTag)34;
                array         = MethodReturnDictionary.InternalExceptionKeys;
                num           = 1;
            }
            else if (methodReturnMessage.ReturnValue == null)
            {
                returnTypeTag = ReturnTypeTag.Null;
            }
            else if (MessageFormatter.IsMethodPrimitive(methodReturnMessage.ReturnValue.GetType()))
            {
                returnTypeTag = ReturnTypeTag.PrimitiveType;
            }
            else
            {
                returnTypeTag = ReturnTypeTag.ObjectType;
                num++;
            }
            if (methodReturnMessage.LogicalCallContext != null && methodReturnMessage.LogicalCallContext.HasInfo)
            {
                methodFlags = MethodFlags.IncludesLogicalCallContext;
                num++;
            }
            if (methodReturnMessage.Properties.Count > array.Length && (byte)(returnTypeTag & ReturnTypeTag.Exception) == 0)
            {
                array2 = MessageFormatter.GetExtraProperties(methodReturnMessage.Properties, array);
                num++;
            }
            MethodFlags methodFlags2;

            if (methodReturnMessage.OutArgCount == 0)
            {
                methodFlags2 = MethodFlags.NoArguments;
            }
            else if (MessageFormatter.AllTypesArePrimitive(methodReturnMessage.Args))
            {
                methodFlags2 = MethodFlags.PrimitiveArguments;
            }
            else if (num == 0)
            {
                methodFlags2 = MethodFlags.ArgumentsInSimpleArray;
            }
            else
            {
                methodFlags2 = MethodFlags.ArgumentsInMultiArray;
                num++;
            }
            writer.Write((byte)(methodFlags | methodFlags2));
            writer.Write((byte)returnTypeTag);
            writer.Write(0);
            writer.Write(0);
            if (returnTypeTag == ReturnTypeTag.PrimitiveType)
            {
                writer.Write(BinaryCommon.GetTypeCode(methodReturnMessage.ReturnValue.GetType()));
                ObjectWriter.WritePrimitiveValue(writer, methodReturnMessage.ReturnValue);
            }
            if (methodFlags2 == MethodFlags.PrimitiveArguments)
            {
                writer.Write((uint)methodReturnMessage.ArgCount);
                for (int i = 0; i < methodReturnMessage.ArgCount; i++)
                {
                    object arg = methodReturnMessage.GetArg(i);
                    if (arg != null)
                    {
                        writer.Write(BinaryCommon.GetTypeCode(arg.GetType()));
                        ObjectWriter.WritePrimitiveValue(writer, arg);
                    }
                    else
                    {
                        writer.Write(17);
                    }
                }
            }
            if (num > 0)
            {
                object[] array3 = new object[num];
                int      num2   = 0;
                if ((byte)(returnTypeTag & ReturnTypeTag.Exception) != 0)
                {
                    array3[num2++] = methodReturnMessage.Exception;
                }
                if (methodFlags2 == MethodFlags.ArgumentsInMultiArray)
                {
                    array3[num2++] = methodReturnMessage.Args;
                }
                if (returnTypeTag == ReturnTypeTag.ObjectType)
                {
                    array3[num2++] = methodReturnMessage.ReturnValue;
                }
                if (methodFlags == MethodFlags.IncludesLogicalCallContext)
                {
                    array3[num2++] = methodReturnMessage.LogicalCallContext;
                }
                if (array2 != null)
                {
                    array3[num2++] = array2;
                }
                obj2 = array3;
            }
            else if ((methodFlags2 & MethodFlags.ArgumentsInSimpleArray) > (MethodFlags)0)
            {
                obj2 = methodReturnMessage.Args;
            }
            if (obj2 != null)
            {
                ObjectWriter objectWriter = new ObjectWriter(surrogateSelector, context, assemblyFormat, typeFormat);
                objectWriter.WriteObjectGraph(writer, obj2, headers);
            }
            else
            {
                writer.Write(11);
            }
        }
コード例 #2
0
        public static void WriteMethodCall(BinaryWriter writer, object obj, Header[] headers, ISurrogateSelector surrogateSelector, StreamingContext context, FormatterAssemblyStyle assemblyFormat, FormatterTypeStyle typeFormat)
        {
            IMethodCallMessage methodCallMessage = (IMethodCallMessage)obj;

            writer.Write(21);
            int    num  = 0;
            object obj2 = null;

            object[]    array = null;
            MethodFlags methodFlags;

            if (methodCallMessage.LogicalCallContext != null && methodCallMessage.LogicalCallContext.HasInfo)
            {
                methodFlags = MethodFlags.IncludesLogicalCallContext;
                num++;
            }
            else
            {
                methodFlags = MethodFlags.ExcludeLogicalCallContext;
            }
            if (RemotingServices.IsMethodOverloaded(methodCallMessage))
            {
                num++;
                methodFlags |= MethodFlags.IncludesSignature;
            }
            if (methodCallMessage.Properties.Count > MethodCallDictionary.InternalKeys.Length)
            {
                array = MessageFormatter.GetExtraProperties(methodCallMessage.Properties, MethodCallDictionary.InternalKeys);
                num++;
            }
            if (methodCallMessage.MethodBase.IsGenericMethod)
            {
                num++;
                methodFlags |= MethodFlags.GenericArguments;
            }
            if (methodCallMessage.ArgCount == 0)
            {
                methodFlags |= MethodFlags.NoArguments;
            }
            else if (MessageFormatter.AllTypesArePrimitive(methodCallMessage.Args))
            {
                methodFlags |= MethodFlags.PrimitiveArguments;
            }
            else if (num == 0)
            {
                methodFlags |= MethodFlags.ArgumentsInSimpleArray;
            }
            else
            {
                methodFlags |= MethodFlags.ArgumentsInMultiArray;
                num++;
            }
            writer.Write((int)methodFlags);
            writer.Write(18);
            writer.Write(methodCallMessage.MethodName);
            writer.Write(18);
            writer.Write(methodCallMessage.TypeName);
            if ((methodFlags & MethodFlags.PrimitiveArguments) > (MethodFlags)0)
            {
                writer.Write((uint)methodCallMessage.Args.Length);
                for (int i = 0; i < methodCallMessage.ArgCount; i++)
                {
                    object arg = methodCallMessage.GetArg(i);
                    if (arg != null)
                    {
                        writer.Write(BinaryCommon.GetTypeCode(arg.GetType()));
                        ObjectWriter.WritePrimitiveValue(writer, arg);
                    }
                    else
                    {
                        writer.Write(17);
                    }
                }
            }
            if (num > 0)
            {
                object[] array2 = new object[num];
                int      num2   = 0;
                if ((methodFlags & MethodFlags.ArgumentsInMultiArray) > (MethodFlags)0)
                {
                    array2[num2++] = methodCallMessage.Args;
                }
                if ((methodFlags & MethodFlags.GenericArguments) > (MethodFlags)0)
                {
                    array2[num2++] = methodCallMessage.MethodBase.GetGenericArguments();
                }
                if ((methodFlags & MethodFlags.IncludesSignature) > (MethodFlags)0)
                {
                    array2[num2++] = methodCallMessage.MethodSignature;
                }
                if ((methodFlags & MethodFlags.IncludesLogicalCallContext) > (MethodFlags)0)
                {
                    array2[num2++] = methodCallMessage.LogicalCallContext;
                }
                if (array != null)
                {
                    array2[num2++] = array;
                }
                obj2 = array2;
            }
            else if ((methodFlags & MethodFlags.ArgumentsInSimpleArray) > (MethodFlags)0)
            {
                obj2 = methodCallMessage.Args;
            }
            if (obj2 != null)
            {
                ObjectWriter objectWriter = new ObjectWriter(surrogateSelector, context, assemblyFormat, typeFormat);
                objectWriter.WriteObjectGraph(writer, obj2, headers);
            }
            else
            {
                writer.Write(11);
            }
        }