none
Generic cocllections get return value RRS feed

  • Question

  • Hi Guys:

    This is the available genric method

    public interface ICardReaderFacade
        {
            Task<System.Collections.Generic.List<SumUp.Sdk.Device.Facade.Dto.CardReaderInformation>> FindAllBluetoothGattAsync(CardReaderType cardReaderType, int foundDevicesTimeoutSeconds, int noDevicesTimeoutSeconds);
            Task<System.Collections.Generic.List<SumUp.Sdk.Device.Facade.Dto.SerialDeviceInformation>> FindAllUsbAsync();
        }

    And i need to get the machine details, so i'm trying this way but it seems not working for me. so oculd please tell me how to get the details?*

    //Authenticalte windows connected sumup device & get the hw details
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                var _sumUpService = new SumUpService();
                      
                var result = Task.Run(async () => { return await _sumUpService.CardReader.FindAllUsbAsync( ); }).Result;

            MessageBox.Show(result.ToString());
                
            }

           
     Thanks in advance

    BR,

    kR



    • Edited by FF_DAPI Friday, June 8, 2018 8:24 AM edited
    Thursday, June 7, 2018 1:58 PM

All replies

  • I would advise going "async all the way" by making the button click event asynchronous as well. Then you can do away with the Task code and just call your async method

    private async void Button_Click_1(object sender, RoutedEventArgs e) { // ...

    var result = await _sumUpService.CardReader.FindAllUsbAsync( );  }


    Thursday, June 7, 2018 2:03 PM
  • I have already tried this way, i'm getting the collection results but not the device details from the var result.

    Coud you please provide me more details?

    I want to fetch card ready type, id & name.

    thanks

    KR


    • Edited by FF_DAPI Thursday, June 7, 2018 2:20 PM edited
    Thursday, June 7, 2018 2:17 PM
  • The FindAllUsbAsync method returns a List of CardReaderInformation objects. So you would need to iterate around that list.

    foreach(CardReaderInformation cri in result)
    {
       // do something with the cri object
    }

    Thursday, June 7, 2018 2:24 PM

  • I've realised that the FindAllUsbAsync() method returns a List of SerialDeviceInformation objects. Refer to the ICardReaderFacade interface that you posted. (I made the mistake because your own commented out code later on seemed to think it returns a list of CardReaderInformation objects, which it doesn't)

    P.S. Your own code would be easier to read if you used the 'Insert Code Block' button when posting!

    So...

    foreach(SerialDeviceInformation sdi in result)
    {
       // do something with the sdi object
    }

    Of course, I have no way of knowing what properties a SerialDeviceInformation object has.



    • Edited by RJP1973 Thursday, June 7, 2018 2:42 PM
    Thursday, June 7, 2018 2:40 PM
  • I'm not entirely sure what you are asking now!

    From the code you provided you have a CardReader object that implements an interface ICardReaderFacade.

    Hence it has two methods: FindAllBluetoothGattAsync() that returns a list of CardReaderInformation objects and FindAllUsbAsync() that returns a list of SerialDeviceInformation objects.

    Your original question was about how to fetch the results from one of these methods. Which I think you should now be able to do.

    So...do you want to call both methods to get both lists and then correlate them somehow (e.g. by CardReaderType since that is a common property)?

    Thursday, June 7, 2018 3:00 PM
  • I'm not entirely sure what you are asking now!

    From the code you provided you have a CardReader object that implements an interface ICardReaderFacade.

    Hence it has two methods: FindAllBluetoothGattAsync() that returns a list of CardReaderInformation objects and FindAllUsbAsync() that returns a list of SerialDeviceInformation objects.

    Your original question was about how to fetch the results from one of these methods. Which I think you should now be able to do.

    So...do you want to call both methods to get both lists and then correlate them somehow (e.g. by CardReaderType since that is a common property)?

    I need to register the card using credentials which is fine.*

    Then find the usb device connected to the system; there is 1 device connected to the sysytem.

    store the cardtype, id and name in the class to dispay in the UI.

    When i debugged i can see the CardReaderInformation but i really don't know how to display and use it in the class?

    Thanks

    KR


    Thursday, June 7, 2018 5:31 PM