public virtual void GetObjectData(Object obj, SerializationInfo info, StreamingContext context) { if (obj == null) { throw new ArgumentNullException("obj"); } if (info == null) { throw new ArgumentNullException("info"); } bool returnMessage = false; bool constructionMessage = false; IMethodMessage msg = obj as IMethodMessage; if (null != msg) { IDictionaryEnumerator de = msg.Properties.GetEnumerator(); if (msg is IMethodCallMessage) { if (obj is IConstructionCallMessage) { constructionMessage = true; } info.SetType(constructionMessage ? _constructionCallType : _methodCallType); } else { IMethodReturnMessage mrm = msg as IMethodReturnMessage; if (null != mrm) { returnMessage = true; info.SetType((obj is IConstructionReturnMessage) ? _constructionResponseType : _methodResponseType); if (((IMethodReturnMessage)msg).Exception != null) { info.AddValue("__fault", ((IMethodReturnMessage)msg).Exception, _exceptionType); } } else { throw new RemotingException(Environment.GetResourceString("Remoting_InvalidMsg")); } } while (de.MoveNext()) { if ((obj == _ss.GetRootObject()) && (_ss.Filter != null) && _ss.Filter((String)de.Key, de.Value)) { continue; } if (de.Value != null) { String key = de.Key.ToString(); if (key.Equals("__CallContext")) { // If the CallContext has only the call Id, then there is no need to put the entire // LogicalCallContext type on the wire LogicalCallContext lcc = (LogicalCallContext)de.Value; if (lcc.HasInfo) { info.AddValue(key, lcc); } else { info.AddValue(key, lcc.RemotingData.LogicalCallID); } } else if (key.Equals("__MethodSignature")) { // If the method is not overloaded, the method signature does not need to go on the wire // note - IsMethodOverloaded does not work well with constructors if (constructionMessage || RemotingServices.IsMethodOverloaded(msg)) { info.AddValue(key, de.Value); continue; } Message.DebugOut("MessageSurrogate::GetObjectData. Method not overloaded, so no MethodSignature \n"); } else { returnMessage = returnMessage; info.AddValue(key, de.Value); } } else { info.AddValue(de.Key.ToString(), de.Value, _objectType); } } } else { throw new RemotingException(Environment.GetResourceString("Remoting_InvalidMsg")); } }
[System.Security.SecurityCritical] // auto-generated_required public virtual void GetObjectData(Object obj, SerializationInfo info, StreamingContext context) { if (obj == null) { throw new ArgumentNullException("obj"); } if (info == null) { throw new ArgumentNullException("info"); } Contract.EndContractBlock(); bool returnMessage = false; bool constructionMessage = false; IMethodMessage msg = obj as IMethodMessage; if (null != msg) { IDictionaryEnumerator de = msg.Properties.GetEnumerator(); if (msg is IMethodCallMessage) { if (obj is IConstructionCallMessage) { constructionMessage = true; } info.SetType(constructionMessage ? _constructionCallType : _methodCallType); } else { IMethodReturnMessage mrm = msg as IMethodReturnMessage; if (null != mrm) { returnMessage = true; info.SetType((obj is IConstructionReturnMessage) ? _constructionResponseType : _methodResponseType); if (((IMethodReturnMessage)msg).Exception != null) { info.AddValue("__fault", ((IMethodReturnMessage)msg).Exception, _exceptionType); } } else { throw new RemotingException(Environment.GetResourceString("Remoting_InvalidMsg")); } } while (de.MoveNext()) { if ((obj == _ss.GetRootObject()) && (_ss.Filter != null) && _ss.Filter((String)de.Key, de.Value)) { continue; } if (de.Value != null) { String key = de.Key.ToString(); if (key.Equals("__CallContext")) { // If the CallContext has only the call Id, then there is no need to put the entire // LogicalCallContext type on the wire LogicalCallContext lcc = (LogicalCallContext)de.Value; if (lcc.HasInfo) { info.AddValue(key, lcc); } else { info.AddValue(key, lcc.RemotingData.LogicalCallID); } } else if (key.Equals("__MethodSignature")) { // If the method is not overloaded, the method signature does not need to go on the wire // note - IsMethodOverloaded does not work well with constructors if (constructionMessage || RemotingServices.IsMethodOverloaded(msg)) { info.AddValue(key, de.Value); continue; } Message.DebugOut("MessageSurrogate::GetObjectData. Method not overloaded, so no MethodSignature \n"); } else { #if false /* If the streaming context says this is a x-domain call, then there is no * need to include the following fields in the return message. Right now I am not sure * how to identify a cross-domain streaming context - Ashok */ if (returnMessage && (key.Equals("__Uri") || key.Equals("__MethodName") || key.Equals("__TypeName"))) { continue; } else #endif #pragma warning disable 1717 // assignment to self returnMessage = returnMessage; #pragma warning restore 1717 info.AddValue(key, de.Value); } } else { info.AddValue(de.Key.ToString(), de.Value, _objectType); } } } else { throw new RemotingException(Environment.GetResourceString("Remoting_InvalidMsg")); } }