Exemplo n.º 1
0
        private async Task GetLedger(ErrorPromptDelegate errorPrompt = null)
        {
            var devices = new List <DeviceInformation>();

            var collection = WindowsHidDevice.GetConnectedDeviceInformations();

            foreach (var ids in WellKnownLedgerWallets)
            {
                if (ids.ProductId == null)
                {
                    devices.AddRange(collection.Where(c => c.VendorId == ids.VendorId));
                }
                else
                {
                    devices.AddRange(collection.Where(c => c.VendorId == ids.VendorId && c.ProductId == ids.ProductId));
                }
            }

            var retVal = devices
                         .FirstOrDefault(d =>
                                         _UsageSpecification == null ||
                                         _UsageSpecification.Length == 0 ||
                                         _UsageSpecification.Any(u => d.UsagePage == u.UsagePage && d.Usage == u.Usage));

            var ledgerHidDevice = new WindowsHidDevice(retVal);
            await ledgerHidDevice.InitializeAsync();

            _LedgerManager = new LedgerManager(ledgerHidDevice, null, Prompt);
        }
Exemplo n.º 2
0
 public LedgerManager(IHandlesRequest ledgerManagerTransport, ICoinUtility coinUtility, ErrorPromptDelegate errorPrompt)
 {
     ErrorPrompt    = errorPrompt;
     RequestHandler = ledgerManagerTransport;
     CoinUtility    = coinUtility ?? new DefaultCoinUtility();
     SetCoinNumber(0);
 }
Exemplo n.º 3
0
 public LedgerManagerBroker(int?pollInterval, ICoinUtility coinUtility, ErrorPromptDelegate errorPromptDelegate, ILedgerManagerFactory ledgerManagerFactory)
 {
     CoinUtility          = coinUtility;
     PollInterval         = pollInterval;
     ErrorPromptDelegate  = errorPromptDelegate;
     LedgerManagerFactory = ledgerManagerFactory;
 }
Exemplo n.º 4
0
        public LedgerManager(IDevice ledgerHidDevice, ICoinUtility coinUtility, ErrorPromptDelegate errorPrompt)
        {
            ErrorPrompt = errorPrompt;

            LedgerHidDevice = ledgerHidDevice;

            CoinUtility = coinUtility ?? new DefaultCoinUtility();

            SetCoinNumber(0);
        }
Exemplo n.º 5
0
        public LedgerManager(IHidDevice ledgerHidDevice, ICoinUtility coinUtility, ErrorPromptDelegate errorPrompt)
        {
            ErrorPrompt = errorPrompt;

            LedgerHidDevice = ledgerHidDevice;
            CoinUtility     = coinUtility;

            if (CoinUtility == null)
            {
                CoinUtility = new DefaultCoinUtility();
            }

            SetCoinNumber(0);
        }
Exemplo n.º 6
0
 public IManagesLedger GetNewLedgerManager(IDevice ledgerHidDevice, ICoinUtility coinUtility, ErrorPromptDelegate errorPrompt)
 {
     return(new LedgerManager(MockLedgerManagerTransport, null, _PromptDelegate));
 }
Exemplo n.º 7
0
 public MockLedgerManagerFactory(ErrorPromptDelegate promptDelegate)
 {
     _PromptDelegate = promptDelegate;
 }
 public IManagesLedger GetNewLedgerManager(IDevice ledgerHidDevice, ICoinUtility coinUtility, ErrorPromptDelegate errorPrompt)
 {
     return(new LedgerManager(new LedgerManagerTransport(ledgerHidDevice), coinUtility, errorPrompt));
 }
Exemplo n.º 9
0
        private async Task GetLedgerBase(ErrorPromptDelegate errorPrompt = null)
        {
            var ledgerManagerBroker = new LedgerManagerBroker(3000, null, Prompt);

            _LedgerManager = await ledgerManagerBroker.WaitForFirstDeviceAsync();
        }
Exemplo n.º 10
0
 protected static void StartBroker(ErrorPromptDelegate errorPrompt, ILedgerManagerFactory ledgerManagerFactory)
 {
     _LedgerManagerBroker = new LedgerManagerBroker(3000, null, Prompt, ledgerManagerFactory);
     _LedgerManagerBroker.Start();
 }
Exemplo n.º 11
0
 public LedgerManagerBroker(int?pollInterval, ICoinUtility coinUtility, ErrorPromptDelegate errorPromptDelegate)
 {
     CoinUtility         = coinUtility;
     PollInterval        = pollInterval;
     ErrorPromptDelegate = errorPromptDelegate;
 }