Exemplo n.º 1
0
        public WalletStorage(IWalletStorage storage)
        {
            _storage = storage;

            WalletCreateCallback                = WalletCreateHandler;
            WalletOpenCallback                  = WalletOpenHandler;
            WalletCloseCallback                 = WalletCloseHandler;
            WalletDeleteCallback                = WalletDeleteHandler;
            WalletAddRecordCallback             = WalletAddRecordHandler;
            WalletUpdateRecordValueCallback     = WalletUpdateRecordValueHandler;
            WalletUpdateRecordTagsCallback      = WalletUpdateRecordTagsHandler;
            WalletAddRecordTagsCallback         = WalletAddRecordTagsHandler;
            WalletDeleteRecordTagsCallback      = WalletDeleteRecordTagsHandler;
            WalletDeleteRecordCallback          = WalletDeleteRecordHandler;
            WalletGetRecordCallback             = WalletGetRecordHandler;
            WalletGetRecordIdCallback           = WalletGetRecordIdHandler;
            WalletGetRecordTypeCallback         = WalletGetRecordTypeHandler;
            WalletGetRecordValueCallback        = WalletGetRecordValueHandler;
            WalletGetRecordTagsCallback         = WalletGetRecordTagsHandler;
            WalletFreeRecordCallback            = WalletFreeRecordHandler;
            WalletGetStorageMetadataCallback    = WalletGetStorageMetadataHandler;
            WalletSetStorageMetadataCallback    = WalletSetStorageMetadataHandler;
            WalletFreeStorageMetadataCallback   = WalletFreeStorageMetadataHandler;
            WalletSearchRecordsCallback         = WalletSearchRecordsHandler;
            WalletSearchAllRecordsCallback      = WalletSearchAllRecordsHandler;
            WalletGetSearchTotalCountCallback   = WalletGetSearchTotalCountHandler;
            WalletFetchSearchNextRecordCallback = WalletFetchSearchNextRecordHandler;
            WalletFreeSearchCallback            = WalletFreeSearchHandler;
        }
Exemplo n.º 2
0
        public static Wallet CreateWallet(IWalletStorage defaultStorage)
        {
            var wallet = new Wallet();

            wallet.defaultStorage = defaultStorage;

            wallet.ResetCurrency();

            return(wallet);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Register custom wallet storage implementation.
        /// </summary>
        /// <param name="storageType">Storage type name.</param>
        /// <param name="storage">Storage implementation instance</param>
        /// <returns></returns>
        public static Task RegisterWalletStorageAsync(string storageType, IWalletStorage storage)
        {
            if (string.IsNullOrEmpty(storageType))
            {
                throw new ArgumentNullException(nameof(storageType));
            }
            if (storage == null)
            {
                throw new ArgumentNullException(nameof(storage));
            }

            var taskCompletionSource = new TaskCompletionSource <bool>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var walletStorage = new WalletStorage(storage);

            RegisteredWalletStores.Add(walletStorage);

            var result = NativeMethods.indy_register_wallet_storage(
                commandHandle,
                storageType,
                walletStorage.WalletCreateCallback,
                walletStorage.WalletOpenCallback,
                walletStorage.WalletCloseCallback,
                walletStorage.WalletDeleteCallback,
                walletStorage.WalletAddRecordCallback,
                walletStorage.WalletUpdateRecordValueCallback,
                walletStorage.WalletUpdateRecordTagsCallback,
                walletStorage.WalletAddRecordTagsCallback,
                walletStorage.WalletDeleteRecordTagsCallback,
                walletStorage.WalletDeleteRecordCallback,
                walletStorage.WalletGetRecordCallback,
                walletStorage.WalletGetRecordIdCallback,
                walletStorage.WalletGetRecordTypeCallback,
                walletStorage.WalletGetRecordValueCallback,
                walletStorage.WalletGetRecordTagsCallback,
                walletStorage.WalletFreeRecordCallback,
                walletStorage.WalletGetStorageMetadataCallback,
                walletStorage.WalletSetStorageMetadataCallback,
                walletStorage.WalletFreeStorageMetadataCallback,
                walletStorage.WalletSearchRecordsCallback,
                walletStorage.WalletSearchAllRecordsCallback,
                walletStorage.WalletGetSearchTotalCountCallback,
                walletStorage.WalletFetchSearchNextRecordCallback,
                walletStorage.WalletFreeSearchCallback,
                Utils.TaskCompletingNoValueCallback);

            Utils.CheckResult(result);

            return(taskCompletionSource.Task);
        }
 public WalletService(IWalletStorage walletStorage, IECBClient ecbClient)
 {
     _walletStorage = walletStorage;
     _ecbClient     = ecbClient;
 }
Exemplo n.º 5
0
 public void ResetCurrency(IWalletStorage storage)
 {
     currency.Clear();
     storage.Load(currency);
 }
Exemplo n.º 6
0
 public void SaveCurrency(IWalletStorage storage)
 {
     storage.Save(currency);
 }