Android Xamarin Bindings: Enum in class constructur

Viewed 183

I try to create a binding for an Android SDK from third party. A lot of parameters are int constants, that normally should be mapped to Enums in C#. I found examples, how to do this for methods and this works.

Now I have some classes, where the constructor accepts this constant ints, which I want to switch to Enums. Can someone give me a working example?

Here is the Java example of the usage code:

Printer printer = new Printer(Printer.MODEL_1, Printer.LANG_1, this);

I want to see the following in C# (Xamarin.Android):

var printer = new Printer(PrinterSeries.Model1, PrinterLanguage.Lang1, this);

The Enum is already mapped:

<enum-field-mappings>
  <mapping jni-class="com/epson/epos2/printer/Printer" clr-enum-type="Com.Epson.Epos2.PrinterSeries">
    <field jni-name="TM_M10" clr-name="M10" value="0" />
    <field jni-name="TM_M30" clr-name="M30" value="1" />
    <field jni-name="TM_P20" clr-name="P20" value="2" />
    ...
  </mapping>
</enum-field-mappings>
0 Answers
Related