示例#1
0
        public static void WritePreferences(Preference _PrefToBlob)
        {
            //TODO: Move serialization to FileBinIO to avoid duplicating code on multiple objects
            MemoryStream    memorystream = new MemoryStream();
            BinaryFormatter bf           = new BinaryFormatter();

            bf.Serialize(memorystream, _PrefToBlob);
            byte[] BlobData = memorystream.ToArray();

            FileBinIO.WriteBin(BlobData, "Pref");
        }
        public static void WriteWalletData(WalletData _WalletDataToBlob, string _walletName)
        {
            //TODO: Move serialization to FileBinIO to avoid duplicating code on multiple objects
            MemoryStream    memorystream = new MemoryStream();
            BinaryFormatter bf           = new BinaryFormatter();

            bf.Serialize(memorystream, _WalletDataToBlob);
            byte[] BlobData = memorystream.ToArray();

            FileBinIO.WriteBin(BlobData, _walletName);
        }
        public static WalletData ReadBlobToWalletData(string _walletName)
        {
            //Read from bin
            //TODO: Move deserialization to FileBinIO to avoid duplicating code on multiple objects
            byte[] BlobData = FileBinIO.ReadBin(AppDomain.CurrentDomain.BaseDirectory + @"bin\\WalletData\\" + _walletName + ".bin");

            MemoryStream    memorystreamd     = new MemoryStream(BlobData);
            BinaryFormatter bfd               = new BinaryFormatter();
            WalletData      deserializedBlock = bfd.Deserialize(memorystreamd) as WalletData;

            memorystreamd.Close();

            return(deserializedBlock);
        }
示例#4
0
        public static Preference ReadBlobToPreferences()
        {
            //TODO: Move deserialization to FileBinIO to avoid duplicating code on multiple objects
            if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"bin\\WalletData\\Pref.bin"))
            {
                //Return empty object
                return(new Preference());
            }

            byte[] BlobData = FileBinIO.ReadBin(AppDomain.CurrentDomain.BaseDirectory + @"bin\\WalletData\\Pref.bin");

            MemoryStream    memorystreamd = new MemoryStream(BlobData);
            BinaryFormatter bfd           = new BinaryFormatter();
            Preference      prefData      = bfd.Deserialize(memorystreamd) as Preference;

            memorystreamd.Close();

            return(prefData);
        }