'NFC-Reader by USB in Xamarin.Forms for UWP

I am currently trying to equip a project with the USB NFC reader ACR122U. The project is a Xamarin.Forms project with the goal of a UWP application. I've already found a sample Windows.Forms project, but the differences between Windows.Forms and Xamarin.Forms are massive. Can someone help me? Below you can see my attempt to take over the sample project basically one to one on xamarin.forms.

using System;
using System.Text;
using Xamarin.Forms;


namespace NfcReader
{
    public partial class Form1 : ContentPage
    {
        private static MyACR122U acr122u = new MyACR122U();

        public Form1()
        {
            InitializeComponent();
            acr122u.Init(false, 50, 4, 4, 200);
            acr122u.CardInserted += Acr122u_CardInserted;
            acr122u.CardRemoved += Acr12u_CardRemoved;
            Console.ReadLine();
        }

        private static void Acr122u_CardInserted(PCSC.ICardReader reader)
        {
            Console.WriteLine("NFC tag placed on reader");
            acr122u.ReadID = BitConverter.ToString(acr122u.GetUID(reader)).Replace("-", "");
            Console.WriteLine("Unique ID: " + acr122u.ReadID);
            string data = "BLABLUBB";
            Console.WriteLine("Write data to NFC tag: " + data);
            bool ret = acr122u.WriteData(reader, Encoding.UTF8.GetBytes(data));
            Console.WriteLine("Write result: " + (ret ? "Sucess" : "Failed"));
            Console.WriteLine("Read data from tag: " + Encoding.UTF8.GetString(acr122u.ReadData(reader)));
        }

        private static void Acr12u_CardRemoved()
        {
            Console.WriteLine("NFC tag removed.");
        }
    }
}

Here you can see the MyACR122U class:

using Sydesoft.NfcDevice;

namespace NfcReader
{
    internal class MyACR122U : ACR122U
    {
        private string readId;
        public string ReadID
        {
            get { return readId; }
            set { readId = value; }
        }

        public MyACR122U()
        { }
    }
}

I have used the NuGet-Paket NFC-ACR122U.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source