void SerializeCall(IMessage call) { RemotingSurrogateSelector rss = new RemotingSurrogateSelector(); var fmt = new BinaryFormatter(rss, new StreamingContext(StreamingContextStates.Remoting)); fmt.Serialize(_stream, call, GetHeaders()); }
public static T DeepClone <T>(this T obj, bool ignoreCustomSerialization = false) { ISurrogateSelector surrogate = null; var formatter = new BinarySerializationFormatter(BinarySerializationOptions.RecursiveSerializationAsFallback | BinarySerializationOptions.CompactSerializationOfStructures | BinarySerializationOptions.IgnoreTypeForwardedFromAttribute); #if NETFRAMEWORK if (RemotingServices.IsTransparentProxy(obj)) { surrogate = new RemotingSurrogateSelector(); } else #endif if (ignoreCustomSerialization) { formatter.Options |= BinarySerializationOptions.IgnoreSerializationMethods | BinarySerializationOptions.IgnoreIObjectReference | BinarySerializationOptions.IgnoreIBinarySerializable; surrogate = new CustomSerializerSurrogateSelector { IgnoreISerializable = true, IgnoreNonSerializedAttribute = true }; } formatter.SurrogateSelector = surrogate; using (var stream = new MemoryStream()) { formatter.SerializeToStream(stream, obj); stream.Position = 0L; #if NETFRAMEWORK if (surrogate is RemotingSurrogateSelector) { formatter.SurrogateSelector = null; } #endif return((T)formatter.DeserializeFromStream(stream)); } }
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 #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; } }
void SerializeResponse(IMessage resp) { RemotingSurrogateSelector rss = new RemotingSurrogateSelector(); IRemotingFormatter fmt = new SoapFormatter(rss, new StreamingContext(StreamingContextStates.Remoting)); fmt.Serialize(_stream, resp, GetHeaders()); }
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) { Throw.ArgumentNullException(Argument.info); } BinarySerializationFormatter serializer = new BinarySerializationFormatter(); ISurrogateSelector surrogate = null; #if NETFRAMEWORK // ReSharper disable once LocalVariableHidesMember - intended, in non-Framework platforms the field is used. bool byFields = this.byFields; if (RemotingServices.IsTransparentProxy(obj)) { surrogate = new RemotingSurrogateSelector(); byFields = false; } else #endif if (byFields) { serializer.Options |= BinarySerializationOptions.IgnoreSerializationMethods | BinarySerializationOptions.IgnoreIObjectReference | BinarySerializationOptions.IgnoreIBinarySerializable; surrogate = new CustomSerializerSurrogateSelector { IgnoreISerializable = true, IgnoreNonSerializedAttribute = true }; } serializer.SurrogateSelector = surrogate; info.AddValue(nameof(isWeak), isWeak); info.AddValue(nameof(byFields), byFields); info.AddValue("data", serializer.Serialize(obj)); }
public void GetReady() { StreamingContext context = new StreamingContext(StreamingContextStates.All); _surrogate = new RemotingSurrogateSelector(); _soapFormatter = new SoapFormatter(_surrogate, context); _soapFormatterDeserializer = new SoapFormatter(null, context); }
[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
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); }
public BinaryWireFormatter() { StreamingContext context = new StreamingContext(StreamingContextStates.Other); RemotingSurrogateSelector selector = new RemotingSurrogateSelector(); _serializer = new BinaryFormatter(selector, context); _serializer.AssemblyFormat = FormatterAssemblyStyle.Simple; _deserializer = new BinaryFormatter(null, context); _deserializer.AssemblyFormat = FormatterAssemblyStyle.Simple; }
public void Init() { RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector(); StreamingContext context = new StreamingContext(StreamingContextStates.Remoting, null); _serializationFormatter = CreateFormatter(surrogateSelector, context); _deserializationFormatter = CreateFormatter(null, context); _serializationFormatter.FilterLevel = _filterLevel; _deserializationFormatter.FilterLevel = _filterLevel; }
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 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); }
[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
} // 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
[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); }
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); }
public void Init() { RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector(); StreamingContext context = new StreamingContext(StreamingContextStates.Remoting, null); _serializationFormatter = new BinaryFormatter(surrogateSelector, context).Safe(); _deserializationFormatter = new BinaryFormatter(null, context).Safe(); _serializationFormatter.FilterLevel = _filterLevel; _deserializationFormatter.FilterLevel = _filterLevel; if (!_includeVersions || !_strictBinding) { _serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple; _deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple; } }
internal static BinaryFormatter CreateBinaryFormatter(bool serialize, bool includeVersionsOrStrictBinding) { BinaryFormatter formatter = new BinaryFormatter(); if (serialize) { RemotingSurrogateSelector selector = new RemotingSurrogateSelector(); formatter.SurrogateSelector = selector; } else { formatter.SurrogateSelector = null; } formatter.Context = new StreamingContext(StreamingContextStates.Other); formatter.AssemblyFormat = includeVersionsOrStrictBinding ? FormatterAssemblyStyle.Full : FormatterAssemblyStyle.Simple; return(formatter); }
internal static SoapFormatter CreateSoapFormatter(bool serialize, bool includeVersions) { SoapFormatter formatter = new SoapFormatter(); if (serialize) { RemotingSurrogateSelector selector = new RemotingSurrogateSelector(); formatter.SurrogateSelector = selector; selector.UseSoapFormat(); } else { formatter.SurrogateSelector = null; } formatter.Context = new StreamingContext(StreamingContextStates.Other); formatter.AssemblyFormat = includeVersions ? FormatterAssemblyStyle.Full : FormatterAssemblyStyle.Simple; return(formatter); }
public void Init() { RemotingSurrogateSelector remotingSurrogateSelector = new RemotingSurrogateSelector(); StreamingContext streamingContext = new StreamingContext(StreamingContextStates.Remoting, null); this._serializationFormatter = new BinaryFormatter(remotingSurrogateSelector, streamingContext); this._deserializationFormatter = new BinaryFormatter(null, streamingContext); if (!this._includeVersions) { this._serializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple; this._deserializationFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple; } if (!this._strictBinding) { this._serializationFormatter.Binder = SimpleBinder.Instance; this._deserializationFormatter.Binder = SimpleBinder.Instance; } }
// -------------- 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); }
internal static MemoryStream SerializeMessage(IMessage msg) { MemoryStream memoryStream1 = new MemoryStream(); RemotingSurrogateSelector surrogateSelector = new RemotingSurrogateSelector(); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.SurrogateSelector = (ISurrogateSelector)surrogateSelector; StreamingContext streamingContext = new StreamingContext(StreamingContextStates.CrossAppDomain); binaryFormatter.Context = streamingContext; MemoryStream memoryStream2 = memoryStream1; IMessage message = msg; // ISSUE: variable of the null type __Null local = null; int num = 0; binaryFormatter.Serialize((Stream)memoryStream2, (object)message, (Header[])local, num != 0); memoryStream1.Position = 0L; return(memoryStream1); }
private BinaryFormatter CreateFormatter(bool serialize) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Context = new StreamingContext(StreamingContextStates.Other); formatter.AssemblyFormat = FormatterAssemblyStyle.Full; if (!serialize) { formatter.SurrogateSelector = new AdoNetFastSerializerSurrogate(); } else { ISurrogateSelector surrogateSelector = new RemotingSurrogateSelector(); surrogateSelector.ChainSelector(new AdoNetFastSerializerSurrogate()); formatter.SurrogateSelector = surrogateSelector; } return(formatter); }