我正在尝试绑定 mapsforge JAR。在这个库的 Overlay 类中有许多通用集合。Overlay 类实现 Java.Util.IList 和接口 Java.Util.IList 想要这样实现
"Mapsforge.Android.Maps.OverlayNs.OverlayList" does not implement "Java.Util.IList.AddAll(int, System.Collections.ICollection)" 8 23 MapForgeDroid
所以,我创建了 Metadata.xml Mapsforge.Android Mapsforge.Android.Maps.OverlayNs
<!-- Return Java.Lang.Object in OverlayManager so that we match interface. -->
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='ArrayCircleOverlay']/method[@name='createCircle']" name="managedReturn">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='ArrayItemizedOverlay']/method[@name='createItem']" name="managedReturn">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='ArrayWayOverlay']/method[@name='createWay']" name="managedReturn">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='ArrayItemizedOverlay']/method[@name='getThreadName']" name="visibility">protected</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='ArrayCircleOverlay']/method[@name='getThreadName']" name="visibility">protected</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='ArrayWayOverlay']/method[@name='getThreadName']" name="visibility">protected</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='add' and count(parameter)=1]/parameter[@name='p0']" name="managedType">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='add' and count(parameter)=2]/parameter[@name='p1']" name="managedType">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='retainAll']/parameter[@name='p0']" name="managedType">System.Collections.ICollection</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='removeAll']/parameter[@name='p0']" name="managedType">System.Collections.ICollection</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='containsAll']/parameter[@name='p0']" name="managedType">System.Collections.ICollection</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='addAll' and count(parameter)=1]/parameter[@name='p0']" name="managedType">System.Collections.ICollection</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='addAll' and count(parameter)=2]/parameter[@name='p1']" name="managedType">System.Collections.ICollection</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='set']/parameter[@name='p1']" name="managedType">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='set']" name="managedReturn">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='remove' and count(parameter)=1 and parameter[1][@type='int']]" name="managedReturn">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.overlay']/class[@name='OverlayList']/method[@name='subList']" name="managedReturn">System.Collections.IList</attr>
<attr path="/api/package[@name='org.mapsforge.android.maps.mapgenerator']/class[@name='MapGeneratorJob']/method[@name='compareTo']/parameter[@name='p0']" name="managedType">Java.Lang.Object</attr>
<attr path="/api/package[@name='org.mapsforge.core']/class[@name='GeoPoint']/method[@name='compareTo']/parameter[@name='p0']" name="managedType">Java.Lang.Object</attr>
</metadata>
但是出现了许多新错误——所有方法都需要泛型集合:
error CS1502: The best overloaded method match for "Mapsforge.Android.Maps.OverlayNs.OverlayList.AddAll(int, System.Collections.ICollection)" has some invalid arguments
error CS1503: Argument "2": cannot convert from "System.Collections.Generic.ICollection<Mapsforge.Android.Maps.OverlayNs.Overlay>" to "System.Collections.ICollection"
error CS1502: The best overloaded method match for "Mapsforge.Android.Maps.OverlayNs.OverlayList.AddAll(System.Collections.ICollection)" has some invalid arguments
error CS1503: Argument "1": cannot convert from "System.Collections.Generic.ICollection<Mapsforge.Android.Maps.OverlayNs.Overlay>" to "System.Collections.ICollection"
error CS1502: The best overloaded method match for "Mapsforge.Android.Maps.OverlayNs.OverlayList.ContainsAll(System.Collections.ICollection)" has some invalid arguments
error CS1503: Argument "1": cannot convert from "System.Collections.Generic.ICollection<object>" to "System.Collections.ICollection"
error CS1502: The best overloaded method match for "Mapsforge.Android.Maps.OverlayNs.OverlayList.RemoveAll(System.Collections.ICollection)" has some invalid arguments
error CS1503: Argument "1": cannot convert from "System.Collections.Generic.ICollection<object>" to "System.Collections.ICollection"
error CS1502: The best overloaded method match for "Mapsforge.Android.Maps.OverlayNs.OverlayList.RetainAll(System.Collections.ICollection)" has some invalid arguments
error CS1503: Argument "1": cannot convert from "System.Collections.Generic.ICollection<object>" to "System.Collections.ICollection"
error CS0266: Cannot implicitly convert type "System.Collections.Generic.IList<Mapsforge.Android.Maps.OverlayNs.Overlay>" to "System.Collections.IList".
error CS0266: Cannot implicitly convert type "System.Collections.Generic.IList<Mapsforge.Android.Maps.OverlayNs.Overlay>" to "System.Collections.IList".
如果我将类型从 System.Collections.ICollection 更改为 System.Collections.Generic.ICollection 它会生成“未实现”错误。我能做些什么来解决这个问题?