WriteMethodCall() приватный Метод

private WriteMethodCall ( ) : void
Результат void
        [System.Security.SecurityCritical]  // auto-generated
        internal void Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, bool fCheck)
        {
            if (graph == null)
                throw new ArgumentNullException("graph", Environment.GetResourceString("ArgumentNull_Graph"));

            if (serWriter == null)
                throw new ArgumentNullException("serWriter", Environment.GetResourceString("ArgumentNull_WithParamName", "serWriter"));
            Contract.EndContractBlock();

            SerTrace.Log(this, "Serialize Entry 2 ", graph, ((headers == null) ? " no headers " : "headers "));

            if (fCheck)
            {
                CodeAccessPermission.Demand(PermissionType.SecuritySerialization);          
            }

            this.serWriter = serWriter;
            this.headers = inHeaders;

            SerTrace.Log( this, "Serialize New SerializedTypeTable");
            serWriter.WriteBegin();
            long headerId = 0;
            Object obj;
            long objectId;
            bool isNew;
            bool bMethodCall = false;
            bool bMethodReturn = false;

#if FEATURE_REMOTING        
            // Special case IMethodCallMessage and IMethodReturnMessage for performance
            IMethodCallMessage mess = graph as IMethodCallMessage;
            if (mess != null)
            {
                bMethodCall = true;
                graph = WriteMethodCall(mess);
            }
            else
            {
                IMethodReturnMessage mr = graph as IMethodReturnMessage;
                if (mr != null)
                {
                    bMethodReturn = true;
                    graph = WriteMethodReturn(mr);
                }
            }
#endif // FEATURE_REMOTING        

            if (graph == null)
            {
                WriteSerializedStreamHeader(topId, headerId);

                if (bMethodCall)
                    serWriter.WriteMethodCall();
                else if (bMethodReturn)
                    serWriter.WriteMethodReturn();

                serWriter.WriteSerializationHeaderEnd();
                serWriter.WriteEnd();
                return;
            }

            // allocations if methodCall or methodResponse and no graph
            m_idGenerator = new ObjectIDGenerator();
            m_objectQueue = new Queue();
            m_formatterConverter = new FormatterConverter();
            serObjectInfoInit = new SerObjectInfoInit();        

            topId = InternalGetId(graph, false, null, out isNew);


            if (headers != null)
                headerId = InternalGetId(headers, false, null, out isNew);
            else
                headerId = -1;

            WriteSerializedStreamHeader(topId, headerId);


            if (bMethodCall)
                serWriter.WriteMethodCall();
            else if (bMethodReturn)
                serWriter.WriteMethodReturn();


            SerTrace.Log( this, "Serialize Schedule 0");
            // Write out SerializedStream header
            if ((headers != null) && (headers.Length > 0))
                m_objectQueue.Enqueue(headers);                 

            if (graph != null)
                m_objectQueue.Enqueue(graph);
            while ((obj = GetNext(out objectId))!=null)
            {
                SerTrace.Log( this, "Serialize GetNext ",obj);
                WriteObjectInfo objectInfo = null;

                // GetNext will return either an object or a WriteObjectInfo. 
                // A WriteObjectInfo is returned if this object was member of another object
                if (obj is WriteObjectInfo)
                {
                    SerTrace.Log( this, "Serialize GetNext recognizes WriteObjectInfo");
                    objectInfo = (WriteObjectInfo)obj;
                }
                else
                {
                    objectInfo = WriteObjectInfo.Serialize(obj, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, this, m_binder);
                    objectInfo.assemId = GetAssemblyId(objectInfo);
                }


                objectInfo.objectId = objectId;
                NameInfo typeNameInfo = TypeToNameInfo(objectInfo);
                Write(objectInfo, typeNameInfo, typeNameInfo);
                PutNameInfo(typeNameInfo);
                objectInfo.ObjectEnd();
            }

            serWriter.WriteSerializationHeaderEnd();
            serWriter.WriteEnd();

            // Invoke OnSerialized Event
            m_objectManager.RaiseOnSerializedEvent();
            
            SerTrace.Log( this, "Serialize Exit ");
        }
 internal void Serialize(object graph, Header[] inHeaders, __BinaryWriter serWriter, bool fCheck)
 {
     if (graph == null)
     {
         throw new ArgumentNullException("graph", Environment.GetResourceString("ArgumentNull_Graph"));
     }
     if (serWriter == null)
     {
         throw new ArgumentNullException("serWriter", Environment.GetResourceString("ArgumentNull_WithParamName", new object[] { "serWriter" }));
     }
     if (fCheck)
     {
         CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
     }
     this.serWriter = serWriter;
     this.headers = inHeaders;
     serWriter.WriteBegin();
     long headerId = 0L;
     bool flag2 = false;
     bool flag3 = false;
     IMethodCallMessage mcm = graph as IMethodCallMessage;
     if (mcm != null)
     {
         flag2 = true;
         graph = this.WriteMethodCall(mcm);
     }
     else
     {
         IMethodReturnMessage mrm = graph as IMethodReturnMessage;
         if (mrm != null)
         {
             flag3 = true;
             graph = this.WriteMethodReturn(mrm);
         }
     }
     if (graph == null)
     {
         this.WriteSerializedStreamHeader(this.topId, headerId);
         if (flag2)
         {
             serWriter.WriteMethodCall();
         }
         else if (flag3)
         {
             serWriter.WriteMethodReturn();
         }
         serWriter.WriteSerializationHeaderEnd();
         serWriter.WriteEnd();
     }
     else
     {
         object obj2;
         long num2;
         bool flag;
         this.m_idGenerator = new ObjectIDGenerator();
         this.m_objectQueue = new Queue();
         this.m_formatterConverter = new FormatterConverter();
         this.serObjectInfoInit = new SerObjectInfoInit();
         this.topId = this.InternalGetId(graph, false, null, out flag);
         if (this.headers != null)
         {
             headerId = this.InternalGetId(this.headers, false, null, out flag);
         }
         else
         {
             headerId = -1L;
         }
         this.WriteSerializedStreamHeader(this.topId, headerId);
         if (flag2)
         {
             serWriter.WriteMethodCall();
         }
         else if (flag3)
         {
             serWriter.WriteMethodReturn();
         }
         if ((this.headers != null) && (this.headers.Length > 0))
         {
             this.m_objectQueue.Enqueue(this.headers);
         }
         if (graph != null)
         {
             this.m_objectQueue.Enqueue(graph);
         }
         while ((obj2 = this.GetNext(out num2)) != null)
         {
             WriteObjectInfo objectInfo = null;
             if (obj2 is WriteObjectInfo)
             {
                 objectInfo = (WriteObjectInfo) obj2;
             }
             else
             {
                 objectInfo = WriteObjectInfo.Serialize(obj2, this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, this, this.m_binder);
                 objectInfo.assemId = this.GetAssemblyId(objectInfo);
             }
             objectInfo.objectId = num2;
             NameInfo memberNameInfo = this.TypeToNameInfo(objectInfo);
             this.Write(objectInfo, memberNameInfo, memberNameInfo);
             this.PutNameInfo(memberNameInfo);
             objectInfo.ObjectEnd();
         }
         serWriter.WriteSerializationHeaderEnd();
         serWriter.WriteEnd();
         this.m_objectManager.RaiseOnSerializedEvent();
     }
 }
Пример #3
0
        internal void Serialize(object graph, Header[] inHeaders, __BinaryWriter serWriter, bool fCheck)
        {
            if (graph == null)
            {
                throw new ArgumentNullException("graph", Environment.GetResourceString("ArgumentNull_Graph"));
            }
            if (serWriter == null)
            {
                throw new ArgumentNullException("serWriter", Environment.GetResourceString("ArgumentNull_WithParamName", new object[] { "serWriter" }));
            }
            if (fCheck)
            {
                CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
            }
            this.serWriter = serWriter;
            this.headers   = inHeaders;
            serWriter.WriteBegin();
            long headerId          = 0L;
            bool flag2             = false;
            bool flag3             = false;
            IMethodCallMessage mcm = graph as IMethodCallMessage;

            if (mcm != null)
            {
                flag2 = true;
                graph = this.WriteMethodCall(mcm);
            }
            else
            {
                IMethodReturnMessage mrm = graph as IMethodReturnMessage;
                if (mrm != null)
                {
                    flag3 = true;
                    graph = this.WriteMethodReturn(mrm);
                }
            }
            if (graph == null)
            {
                this.WriteSerializedStreamHeader(this.topId, headerId);
                if (flag2)
                {
                    serWriter.WriteMethodCall();
                }
                else if (flag3)
                {
                    serWriter.WriteMethodReturn();
                }
                serWriter.WriteSerializationHeaderEnd();
                serWriter.WriteEnd();
            }
            else
            {
                object obj2;
                long   num2;
                bool   flag;
                this.m_idGenerator        = new ObjectIDGenerator();
                this.m_objectQueue        = new Queue();
                this.m_formatterConverter = new FormatterConverter();
                this.serObjectInfoInit    = new SerObjectInfoInit();
                this.topId = this.InternalGetId(graph, false, null, out flag);
                if (this.headers != null)
                {
                    headerId = this.InternalGetId(this.headers, false, null, out flag);
                }
                else
                {
                    headerId = -1L;
                }
                this.WriteSerializedStreamHeader(this.topId, headerId);
                if (flag2)
                {
                    serWriter.WriteMethodCall();
                }
                else if (flag3)
                {
                    serWriter.WriteMethodReturn();
                }
                if ((this.headers != null) && (this.headers.Length > 0))
                {
                    this.m_objectQueue.Enqueue(this.headers);
                }
                if (graph != null)
                {
                    this.m_objectQueue.Enqueue(graph);
                }
                while ((obj2 = this.GetNext(out num2)) != null)
                {
                    WriteObjectInfo objectInfo = null;
                    if (obj2 is WriteObjectInfo)
                    {
                        objectInfo = (WriteObjectInfo)obj2;
                    }
                    else
                    {
                        objectInfo         = WriteObjectInfo.Serialize(obj2, this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, this, this.m_binder);
                        objectInfo.assemId = this.GetAssemblyId(objectInfo);
                    }
                    objectInfo.objectId = num2;
                    NameInfo memberNameInfo = this.TypeToNameInfo(objectInfo);
                    this.Write(objectInfo, memberNameInfo, memberNameInfo);
                    this.PutNameInfo(memberNameInfo);
                    objectInfo.ObjectEnd();
                }
                serWriter.WriteSerializationHeaderEnd();
                serWriter.WriteEnd();
                this.m_objectManager.RaiseOnSerializedEvent();
            }
        }
Пример #4
0
        internal void Serialize(object graph, Header[] inHeaders, __BinaryWriter serWriter, bool fCheck)
        {
            if (graph == null)
            {
                throw new ArgumentNullException("graph", Environment.GetResourceString("ArgumentNull_Graph"));
            }
            if (serWriter == null)
            {
                throw new ArgumentNullException("serWriter", Environment.GetResourceString("ArgumentNull_WithParamName", (object)"serWriter"));
            }
            if (fCheck)
            {
                CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
            }
            this.serWriter = serWriter;
            this.headers   = inHeaders;
            serWriter.WriteBegin();
            long headerId          = 0;
            bool flag1             = false;
            bool flag2             = false;
            IMethodCallMessage mcm = graph as IMethodCallMessage;

            if (mcm != null)
            {
                flag1 = true;
                graph = (object)this.WriteMethodCall(mcm);
            }
            else
            {
                IMethodReturnMessage mrm = graph as IMethodReturnMessage;
                if (mrm != null)
                {
                    flag2 = true;
                    graph = (object)this.WriteMethodReturn(mrm);
                }
            }
            if (graph == null)
            {
                this.WriteSerializedStreamHeader(this.topId, headerId);
                if (flag1)
                {
                    serWriter.WriteMethodCall();
                }
                else if (flag2)
                {
                    serWriter.WriteMethodReturn();
                }
                serWriter.WriteSerializationHeaderEnd();
                serWriter.WriteEnd();
            }
            else
            {
                this.m_idGenerator        = new ObjectIDGenerator();
                this.m_objectQueue        = new Queue();
                this.m_formatterConverter = (IFormatterConverter) new FormatterConverter();
                this.serObjectInfoInit    = new SerObjectInfoInit();
                bool isNew;
                this.topId = this.InternalGetId(graph, false, (Type)null, out isNew);
                this.WriteSerializedStreamHeader(this.topId, this.headers == null ? -1L : this.InternalGetId((object)this.headers, false, (Type)null, out isNew));
                if (flag1)
                {
                    serWriter.WriteMethodCall();
                }
                else if (flag2)
                {
                    serWriter.WriteMethodReturn();
                }
                if (this.headers != null && this.headers.Length != 0)
                {
                    this.m_objectQueue.Enqueue((object)this.headers);
                }
                if (graph != null)
                {
                    this.m_objectQueue.Enqueue(graph);
                }
                object next;
                long   objID;
                while ((next = this.GetNext(out objID)) != null)
                {
                    WriteObjectInfo objectInfo1;
                    if (next is WriteObjectInfo)
                    {
                        objectInfo1 = (WriteObjectInfo)next;
                    }
                    else
                    {
                        objectInfo1         = WriteObjectInfo.Serialize(next, this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, this, this.m_binder);
                        objectInfo1.assemId = this.GetAssemblyId(objectInfo1);
                    }
                    objectInfo1.objectId = objID;
                    NameInfo        nameInfo1   = this.TypeToNameInfo(objectInfo1);
                    WriteObjectInfo objectInfo2 = objectInfo1;
                    NameInfo        nameInfo2   = nameInfo1;
                    this.Write(objectInfo2, nameInfo2, nameInfo2);
                    this.PutNameInfo(nameInfo1);
                    objectInfo1.ObjectEnd();
                }
                serWriter.WriteSerializationHeaderEnd();
                serWriter.WriteEnd();
                this.m_objectManager.RaiseOnSerializedEvent();
            }
        }