상속: ISurrogateSelector
예제 #1
0
        public BinaryWireFormatter()
        {
            var context = new StreamingContext(StreamingContextStates.Other);
            var selector = new RemotingSurrogateSelector();

            _serializer = new BinaryFormatter(selector, context) { AssemblyFormat = FormatterAssemblyStyle.Simple };
            _deserializer = new BinaryFormatter(null, context) { AssemblyFormat = FormatterAssemblyStyle.Simple };
        }
 internal static MemoryStream SerializeMessage(IMessage msg)
 {
     MemoryStream serializationStream = new MemoryStream();
     RemotingSurrogateSelector selector = new RemotingSurrogateSelector();
     new BinaryFormatter { SurrogateSelector = selector, Context = new StreamingContext(StreamingContextStates.CrossAppDomain) }.Serialize(serializationStream, msg, null, false);
     serializationStream.Position = 0L;
     return serializationStream;
 }
 internal static void SerializeObject(object obj, MemoryStream stm)
 {
     BinaryFormatter formatter = new BinaryFormatter();
     RemotingSurrogateSelector selector = new RemotingSurrogateSelector();
     formatter.SurrogateSelector = selector;
     formatter.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
     formatter.Serialize(stm, obj, null, false);
 }
 internal static MemoryStream SerializeMessageParts(ArrayList argsToSerialize)
 {
     MemoryStream serializationStream = new MemoryStream();
     BinaryFormatter formatter = new BinaryFormatter();
     RemotingSurrogateSelector selector = new RemotingSurrogateSelector();
     formatter.SurrogateSelector = selector;
     formatter.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
     formatter.Serialize(serializationStream, argsToSerialize, null, false);
     serializationStream.Position = 0L;
     return serializationStream;
 }
예제 #5
0
		static RemotingServices ()
		{
			RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
			StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);
			_serializationFormatter = new BinaryFormatter (surrogateSelector, context);
			_deserializationFormatter = new BinaryFormatter (null, context);
			_serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Full;
			_deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Full;
			
			RegisterInternalChannels ();
			CreateWellKnownServerIdentity (typeof(RemoteActivator), "RemoteActivationService.rem", WellKnownObjectMode.Singleton);
			
			FieldSetterMethod = typeof(object).GetMethod ("FieldSetter", BindingFlags.NonPublic|BindingFlags.Instance);
			FieldGetterMethod = typeof(object).GetMethod ("FieldGetter", BindingFlags.NonPublic|BindingFlags.Instance);
		}
예제 #6
0
		public void Init ()
		{
			RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
			StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);

			_serializationFormatter = new BinaryFormatter (surrogateSelector, context);
			_deserializationFormatter = new BinaryFormatter (null, context);
			
			if (!_includeVersions)
			{
				_serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
				_deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
			}

			if (!_strictBinding)
			{
				_serializationFormatter.Binder = SimpleBinder.Instance;
				_deserializationFormatter.Binder = SimpleBinder.Instance;
			}
		}
예제 #7
0
		void SerializeResponse (IMessage resp)
		{
			RemotingSurrogateSelector rss = new RemotingSurrogateSelector();
			var fmt = new BinaryFormatter (rss, new StreamingContext(StreamingContextStates.Remoting));
			fmt.Serialize (_stream, resp, GetHeaders());
		}
        internal static byte[] MarshalToBuffer(Object o)
        {
            // serialize headers and args together using the binary formatter
            MemoryStream stm = new MemoryStream();
            RemotingSurrogateSelector ss = new RemotingSurrogateSelector();
            BinaryFormatter fmt = new BinaryFormatter();                
            fmt.SurrogateSelector = ss;
            fmt.Context = new StreamingContext(StreamingContextStates.Other);
            fmt.Serialize(stm, o, null, false /* No Security check */);

            return stm.GetBuffer();
        }
 internal static byte[] MarshalToBuffer(object o, bool crossRuntime)
 {
     if (crossRuntime)
     {
         if (IsTransparentProxy(o))
         {
             if ((GetRealProxy(o) is RemotingProxy) && (ChannelServices.RegisteredChannels.Length == 0))
             {
                 return null;
             }
         }
         else
         {
             MarshalByRefObject obj2 = o as MarshalByRefObject;
             if (((obj2 != null) && (ActivationServices.GetProxyAttribute(obj2.GetType()) == ActivationServices.DefaultProxyAttribute)) && (ChannelServices.RegisteredChannels.Length == 0))
             {
                 return null;
             }
         }
     }
     MemoryStream serializationStream = new MemoryStream();
     RemotingSurrogateSelector selector = new RemotingSurrogateSelector();
     new BinaryFormatter { SurrogateSelector = selector, Context = new StreamingContext(StreamingContextStates.Other) }.Serialize(serializationStream, o, null, false);
     return serializationStream.GetBuffer();
 }
예제 #10
0
		public void Init ()
		{
			RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
			StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);

#if !TARGET_JVM
			_serializationFormatter = new BinaryFormatter (surrogateSelector, context);
			_deserializationFormatter = new BinaryFormatter (null, context);
#else
			_serializationFormatter = (BinaryFormatter) vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter (surrogateSelector, context, false);
			_deserializationFormatter = (BinaryFormatter) vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter (null, context, false);
#endif
			
			_serializationFormatter.FilterLevel = _filterLevel;
			_deserializationFormatter.FilterLevel = _filterLevel;
			
			if (!_includeVersions)
			{
				_serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
				_deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
			}

			if (!_strictBinding)
			{
				_serializationFormatter.Binder = ChannelCore.SimpleBinder;
				_deserializationFormatter.Binder = ChannelCore.SimpleBinder;
			}
		}
		public void GetReady() {
			StreamingContext context = new StreamingContext(StreamingContextStates.All);
			_surrogate = new RemotingSurrogateSelector();
			_soapFormatter = new SoapFormatter(_surrogate, context);
			_soapFormatterDeserializer = new SoapFormatter(null, context);
		}
예제 #12
0
        // -------------- ISerializable Interface ------------------------------
        /// <summary>
        /// Serialises the information
        /// </summary>
        /// <param name="info">Standard <c>SerializationInfo</c> object</param>
        /// <param name="context">Standard <c>StreamingContext</c> object</param>
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            BinaryFormatter bf = new BinaryFormatter();
            RemotingSurrogateSelector rss = new RemotingSurrogateSelector();
            bf.SurrogateSelector = rss;
            bf.Context = new StreamingContext(StreamingContextStates.Other);
            bf.AssemblyFormat = FormatterAssemblyStyle.Full;

            MemoryStream ms = new MemoryStream();
            bf.Serialize(ms,msg,null);

            info.AddValue("type", type);
            info.AddValue("stream", ms);
            info.AddValue("source", source);
            info.AddValue("objectUri", objectUri);
        }
 [System.Security.SecurityCritical]  // auto-generated
 internal MessageSurrogate(RemotingSurrogateSelector ss)
 {
     _ss = ss;
 }
예제 #14
0
 [System.Security.SecurityCritical]  // auto-generated
 internal static void SerializeObject(Object obj, MemoryStream stm)
 {
     BinaryFormatter fmt = new BinaryFormatter();       
     RemotingSurrogateSelector ss = new RemotingSurrogateSelector();
     fmt.SurrogateSelector = ss;            
     fmt.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
     fmt.Serialize(stm, obj, null, false /* No Security check */);
 } // SerializeMessageParts 
예제 #15
0
		public void Init ()
		{
			RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
			StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);

			_serializationFormatter = new BinaryFormatter (surrogateSelector, context);
			_deserializationFormatter = new BinaryFormatter (null, context);
			
#if NET_1_1
			_serializationFormatter.FilterLevel = _filterLevel;
			_deserializationFormatter.FilterLevel = _filterLevel;
#endif
			
			if (!_includeVersions)
			{
				_serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
				_deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
			}

			if (!_strictBinding)
			{
				_serializationFormatter.Binder = ChannelCore.SimpleBinder;
				_deserializationFormatter.Binder = ChannelCore.SimpleBinder;
			}
		}
예제 #16
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static MemoryStream SerializeMessage(IMessage msg)
        {
            MemoryStream stm = new MemoryStream();
            RemotingSurrogateSelector ss = new RemotingSurrogateSelector();
            BinaryFormatter fmt = new BinaryFormatter();                
            fmt.SurrogateSelector = ss;
            fmt.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
            fmt.Serialize(stm, msg, null, false /* No Security check */);
    
            // Reset the stream so that Deserialize happens correctly
            stm.Position = 0;

            return stm;
        }
예제 #17
0
        } // SerializeMessageParts 

        // called from MessageSmuggler classes
        internal static MemoryStream SerializeObject(Object obj)
        {
            MemoryStream stm = new MemoryStream();
            
            BinaryFormatter fmt = new BinaryFormatter();       
            RemotingSurrogateSelector ss = new RemotingSurrogateSelector();
            fmt.SurrogateSelector = ss;            
            fmt.Context = new StreamingContext(StreamingContextStates.Other);
            fmt.Serialize(stm, obj, null, false /* No Security check */);
            
            stm.Position = 0;
            return stm;
        } // SerializeMessageParts 
 internal SoapMessageSurrogate(RemotingSurrogateSelector ss)
 {
     this._ss = ss;
 }
예제 #19
0
        } // CreateSoapFormatter


        internal static BinaryFormatter CreateBinaryFormatter(bool serialize, 
                                                              bool includeVersionsOrStrictBinding)
        {
            BinaryFormatter remotingFormatter = new BinaryFormatter();

            if (serialize)
            {
                RemotingSurrogateSelector rss = new RemotingSurrogateSelector();
                remotingFormatter.SurrogateSelector = rss;
            }
            else
            {
                remotingFormatter.SurrogateSelector = null;
            }

            remotingFormatter.Context = new StreamingContext(StreamingContextStates.Other);

            remotingFormatter.AssemblyFormat = 
                includeVersionsOrStrictBinding ? 
                    FormatterAssemblyStyle.Full :
                    FormatterAssemblyStyle.Simple;  
            
            return remotingFormatter;
        } // CreateBinaryFormatter
예제 #20
0
        } // GetSoapHeaders



        internal static SoapFormatter CreateSoapFormatter(bool serialize, bool includeVersions)
        {            
            SoapFormatter remotingFormatter = new SoapFormatter();

            if (serialize)
            {
                RemotingSurrogateSelector rss = new RemotingSurrogateSelector();
                remotingFormatter.SurrogateSelector = rss;
                rss.UseSoapFormat();
            }
            else
                remotingFormatter.SurrogateSelector = null;

            remotingFormatter.Context = new StreamingContext(StreamingContextStates.Other);

            remotingFormatter.AssemblyFormat = 
                includeVersions ? 
                    FormatterAssemblyStyle.Full :
                    FormatterAssemblyStyle.Simple;

            return remotingFormatter;
        } // CreateSoapFormatter
예제 #21
0
 [System.Security.SecurityCritical]  // auto-generated
 internal static MemoryStream SerializeMessageParts(ArrayList argsToSerialize)
 {
     MemoryStream stm = new MemoryStream();
     
     BinaryFormatter fmt = new BinaryFormatter();       
     RemotingSurrogateSelector ss = new RemotingSurrogateSelector();
     fmt.SurrogateSelector = ss;            
     fmt.Context = new StreamingContext(StreamingContextStates.CrossAppDomain);
     fmt.Serialize(stm, argsToSerialize, null, false /* No Security check */);
     
     stm.Position = 0;
     return stm;
 } // SerializeMessageParts 
예제 #22
0
		void SerializeCall (IMessage call)
		{
			RemotingSurrogateSelector rss = new RemotingSurrogateSelector();
			IRemotingFormatter fmt = new SoapFormatter (rss, new StreamingContext(StreamingContextStates.Remoting));
			fmt.Serialize (_stream, call, GetHeaders());
		}
예제 #23
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static byte[] MarshalToBuffer(Object o, bool crossRuntime) 
        { 
            if (crossRuntime)
            { 
                // Making a call on a MBRO cross-process or cross-runtime likely fails in most common
                // scenarios. We check for signs that Remoting is really expected by the user.
                if (RemotingServices.IsTransparentProxy(o))
                { 
                    if (RemotingServices.GetRealProxy(o) is RemotingProxy)
                    { 
                        // the object uses a default proxy - it means that Remoting may not be expected 
                        if (ChannelServices.RegisteredChannels.Length == 0)
                        { 
                            return null;
                        }
                    }
                } 
                else
                { 
                    MarshalByRefObject mbro = o as MarshalByRefObject; 
                    if (mbro != null)
                    { 
                        ProxyAttribute proxyAttr = ActivationServices.GetProxyAttribute(mbro.GetType());
                        if (proxyAttr == ActivationServices.DefaultProxyAttribute)
                        {
                            // the object does not use a custom proxy - it means that Remoting may not be expected 
                            if (ChannelServices.RegisteredChannels.Length == 0)
                            { 
                                return null; 
                            }
                        } 
                    }
                }
            }
 
            // serialize headers and args together using the binary formatter
            MemoryStream stm = new MemoryStream(); 
            RemotingSurrogateSelector ss = new RemotingSurrogateSelector(); 
            BinaryFormatter fmt = new BinaryFormatter();
            fmt.SurrogateSelector = ss; 
            fmt.Context = new StreamingContext(StreamingContextStates.Other);
            fmt.Serialize(stm, o, null, false /* No Security check */);

            return stm.GetBuffer(); 
        }
 internal SoapMessageSurrogate(RemotingSurrogateSelector ss)
 {
     this._ss = ss;
 }
예제 #25
0
 internal MessageSurrogate(RemotingSurrogateSelector ss)
 {
     _ss = ss;
 }
예제 #26
0
		public void Init ()
		{
			RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector ();
			StreamingContext context = new StreamingContext (StreamingContextStates.Remoting, null);

			_serializationFormatter = CreateFormatter (surrogateSelector, context);
			_deserializationFormatter = CreateFormatter (null, context);

#if NET_1_1
			_serializationFormatter.FilterLevel = _filterLevel;
			_deserializationFormatter.FilterLevel = _filterLevel;
#endif
		}