在Xamarin.Android Bindings中,我有一个由Java包装的接口,如下所示:
// Metadata.xml XPath interface reference: path="/api/package[@name='com.buyandlarge.core.framework']/interface[@name='IView']"
[Register ("com/buyandlarge/core/framework/IView", "", "BuyAndLarge.Core.Framework.IViewInvoker")]
public partial interface IView : global::Core.Framework.IContextProvider, global::BuyAndLarge.Core.Framework.IHitTestable {
global::Android.Views.ViewGroup.LayoutParams LayoutParams {
// Metadata.xml XPath method reference: path="/api/package[@name='com.buyandlarge.core.framework']/interface[@name='IView']/method[@name='getLayoutParams' and count(parameter)=0]"
[Register ("getLayoutParams", "()Landroid/view/ViewGroup$LayoutParams;", "GetGetLayoutParamsHandler:BuyAndLarge.Core.Framework.IViewInvoker, BuyAndLarge.Core")] get;
// Metadata.xml XPath method reference: path="/api/package[@name='com.buyandlarge.core.framework']/interface[@name='IView']/method[@name='setLayoutParams' and count(parameter)=1 and parameter[1][@type='android.view.ViewGroup.LayoutParams']]"
[Register ("setLayoutParams", "(Landroid/view/ViewGroup$LayoutParams;)V", "GetSetLayoutParams_Landroid_view_ViewGroup_LayoutParams_Handler:BuyAndLarge.Core.Framework.IViewInvoker, BuyAndLarge.Core")] set;
}
}
继承global::Android.Views.View
的各种类实现此接口。出于某些奇怪的原因,Xamarin的Android.Views.View实现具有定义为public virtual ViewGroup.LayoutParams LayoutParameters { get; set; }
的属性,所以我在代码中得到了数百个'Foo类型没有实现IView.LayoutParams'错误。
我想使用metadata.xml将IView.LayoutParams重命名为IView.LayoutParameters,但不确定语法。
我试过这个:
<attr path="/api/package[@name='com.buyandlarge.core.framework']/interface[@name='IView']/method[@name='getLayoutParams' and count(parameter)=0]" name="managedName">LayoutParameters</attr>
<attr path="/api/package[@name='com.buyandlarge.core.framework']/interface[@name='IView']/method[@name='setLayoutParams' and count(parameter)=1 and parameter[1][@type='android.view.ViewGroup.LayoutParams']]" name="managedName">LayoutParameters</attr>
但没有成功......任何想法?
答案 0 :(得分:0)
使用name =&#34; propertyName&#34;您可以更改接口或类的生成属性。元数据变为
<!-- Rename IView.LayoutParams to LayoutParameters to be consistent with Android base classes -->
<attr path="/api/package[@name='com.buyandlarge.core.framework']/interface[@name='IView']/method[@name='getLayoutParams' and count(parameter)=0]"
name="propertyName">LayoutParameters</attr>
<attr path="/api/package[@name='com.buyandlarge.core.framework']/interface[@name='IView']/method[@name='setLayoutParams' and count(parameter)=1 and parameter[1][@type='android.view.ViewGroup.LayoutParams']]"
name="propertyName">LayoutParameters</attr>
该属性已重命名,并且该日期已保存^ _ ^