protected override T OnConvertFromStorage(Type valueType, string storageValue)
 {
     using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(storageValue)))
     {
         BinaryFormatter             formatter = new BinaryFormatter();
         SerializationFallbackBinder binder    = new SerializationFallbackBinder();
         binder.SetNextRequiredBaseType(typeof(T));
         formatter.Binder = binder;
         return((T)formatter.Deserialize(stream));
     }
 }
Beispiel #2
0
 protected TResult CloneCore <TResult>() where TResult : ReferenceValue
 {
     using (SegmentedMemoryStream stream = new SegmentedMemoryStream())
     {
         SerializationFallbackBinder binder = new SerializationFallbackBinder();
         binder.SetNextRequiredBaseType(typeof(TResult));
         BinaryFormatter formatter1 = new BinaryFormatter {
             Binder = binder
         };
         formatter1.Serialize(stream, this);
         stream.Seek(0L, SeekOrigin.Begin);
         GC.KeepAlive(this);
         return((TResult)formatter1.Deserialize(stream));
     }
 }