/// <summary> /// Deserializes the binary representation of an object. /// </summary> /// <param name="buffer">binary representation of the object</param> /// <returns>deserialized object</returns> static public object FromByteBuffer(byte[] buffer, string cacheContext, System.Runtime.Serialization.SerializationBinder binder = null) { using (MemoryStream stream = new MemoryStream(buffer)) { return(Deserialize(stream, cacheContext, binder)); } }
/// <summary> /// Deserializes an object from the specified stream. /// </summary> /// <param name="stream">specified stream</param> /// <returns>deserialized object</returns> static public object Deserialize(Stream stream, string cacheContext, System.Runtime.Serialization.SerializationBinder binder = null) { using (CompactBinaryReader reader = new CompactBinaryReader(stream)) { reader.Context.Binder = binder; return(Deserialize(reader, cacheContext, false)); } }
internal XmlObjectSerializerReadContextComplex(NetDataContractSerializer serializer) : base(serializer) { mode = SerializationMode.SharedType; preserveObjectReferences = true; binder = serializer.Binder; surrogateSelector = serializer.SurrogateSelector; assemblyFormat = serializer.AssemblyFormat; }
internal XmlObjectSerializerWriteContextComplex(NetDataContractSerializer serializer, Hashtable surrogateDataContracts) : base(serializer) { mode = SerializationMode.SharedType; preserveObjectReferences = true; streamingContext = serializer.Context; binder = serializer.Binder; surrogateSelector = serializer.SurrogateSelector; this.surrogateDataContracts = surrogateDataContracts; }
public static T BinaryLoad <T>(string fileName, System.Runtime.Serialization.SerializationBinder binder) { BinaryFormatter bf = new BinaryFormatter(); bf.Binder = binder; using (System.IO.Stream fs = System.IO.File.OpenRead(fileName)) { T result = (T)bf.Deserialize(fs); return(result); } }
public static T Read <T>(string fileName, System.Runtime.Serialization.SerializationBinder binder = null) { if (File.Exists(fileName)) { var s = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple, ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, //ConstructorHandlingFallback = CtorFallback, Binder = binder }; return((T)JsonConvert.DeserializeObject(File.ReadAllText(fileName), typeof(T), s)); } return(default(T)); }