コード例 #1
0
ファイル: Program.cs プロジェクト: chickenstick/Arowana
        //private static void TestSerialization()
        //{
        //    AccountCollection collection = GetTestCollection();
        //    Console.WriteLine(collection);

        //    ActionList actionList = new ActionList(new BitSerializer(), new ActionBase[0]);
        //    string serialized = actionList.DoActions(collection);
        //    AccountCollection collection1 = actionList.ReverseActions<AccountCollection>(serialized);
        //    Console.WriteLine(collection1);
        //}

        //private static void TestEncryption()
        //{
        //    AccountCollection collection = GetTestCollection();
        //    Console.WriteLine(collection);

        //    ConfigurationSettings configSettings = new ConfigurationSettings();
        //    DataCryptoBase crypto = new RijndaelDataCrypto(configSettings.Password, configSettings.Salt, configSettings.IV);
        //    EncryptionAction encryptionAction = new EncryptionAction(crypto);
        //    ActionList actionList = new ActionList(new BitSerializer(), encryptionAction);
        //    string serialized = actionList.DoActions(collection);
        //    AccountCollection collection1 = actionList.ReverseActions<AccountCollection>(serialized);
        //    Console.WriteLine(collection1);
        //}

        //private static void TestEncryptionAndCompression()
        //{
        //    AccountCollection collection = GetTestCollection();
        //    Console.WriteLine(collection);

        //    ConfigurationSettings configSettings = new ConfigurationSettings();
        //    DataCryptoBase crypto = new RijndaelDataCrypto(configSettings.Password, configSettings.Salt, configSettings.IV);
        //    EncryptionAction encryptionAction = new EncryptionAction(crypto);
        //    ActionList actionList = new ActionList(new BitSerializer(), encryptionAction, new CompressionAction());
        //    string serialized = actionList.DoActions(collection);
        //    AccountCollection collection1 = actionList.ReverseActions<AccountCollection>(serialized);
        //    Console.WriteLine(collection1);
        //}

        private static void TestFileSave()
        {
            AccountCollection collection = GetTestCollection();

            Console.WriteLine(collection);

            IFactory   factory    = new DefaultFactory("smellyourbeans", "FartedInPublic69", "jfdg8jlFJH89lkJsdf9jm8n*y6(*^jlkfdj");
            ActionList actionList = factory.GetActionList();
            IStorage   storage    = factory.GetStorage();

            string serialized = actionList.DoActions(collection);

            storage.StoreData("file.dat", serialized);

            string            fromFile    = storage.RetrieveData("file.dat");
            AccountCollection collection1 = actionList.ReverseActions <AccountCollection>(fromFile);

            Console.WriteLine(collection1);
        }