Beispiel #1
0
        // Create the binary formatter with compat hacks for particular versions if needed
        private static BinaryFormatter CreateFormatter(Version ver, bool secure)
        {
            BinaryFormatter     ret    = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.File));
            SerializationBinder binder = null;

            if (ver.Major == 1)
            {
                if (ver.Minor < 3)
                {
                    binder = new FixSerializationFrom12();
                }
                else if (ver.Minor == 3)
                {
                    binder = new FixSerializationFrom13();
                }
            }

            if (secure)
            {
                binder          = new SecurityBinder(binder);
                ret.FilterLevel = TypeFilterLevel.Low;
            }

            ret.Binder = binder;

            return(ret);
        }
Beispiel #2
0
 public static COMRegistry Load(string path)
 {
     using (FileStream stm = File.OpenRead(path))
     {
         BinaryFormatter     formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.File));
         SerializationBinder binder    = new SecurityBinder(null);
         formatter.FilterLevel = TypeFilterLevel.Low;
         return((COMRegistry)formatter.Deserialize(stm));
     }
 }
Beispiel #3
0
 public static COMRegistry Load(string path)
 {
     using (FileStream stm = File.OpenRead(path))
     {
         BinaryFormatter formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.File));
         SerializationBinder binder = new SecurityBinder(null);
         formatter.FilterLevel = TypeFilterLevel.Low;
         return (COMRegistry) formatter.Deserialize(stm);
     }
 }