Xamarin形成系统API的某些部分不可用(Xamarin Forms certain parts of System APIs not available)

编程入门 行业动态 更新时间:2024-10-23 08:28:00
Xamarin形成系统API的某些部分不可用(Xamarin Forms certain parts of System APIs not available)

我正在尝试使用这种方法: https : //developer.xamarin.com/api/member/System.Type.GetInterfaces()/喜欢这样:

public MainPage(Type type) { if (type.GetInterfaces().contains("Form")) { // go on

但是我的Xamarin Studio不能识别GetInterfaces方法,为什么?

I'm trying to use this method: https://developer.xamarin.com/api/member/System.Type.GetInterfaces()/ like this:

public MainPage(Type type) { if (type.GetInterfaces().contains("Form")) { // go on

But my Xamarin Studio does not recognize the GetInterfaces method, why?

最满意答案

这听起来像你正在使用PCL Xamarin Forms项目。 我建议你在这里阅读更多关于这方面的内容,或者观看互联网上的一些有用的视频(例如这个讨论不同PCL配置文件的视频),但基本上PCL项目试图允许在所有平台上提供许多通用API。 这意味着如果某个平台不支持GetInterfaces()或者如果Forms团队尚未实现该API,则它将不会从Forms项目中获得。

Xamarin Forms的好处在于,如果需要,您仍然可以访问所有本机API。 为此,您可以创建一个接口并使用Xamarin Forms Dependency Service( 链接 ),这可能允许您从Forms项目访问该API。

如果你需要一个如何做到这一点的例子,请让我知道。

It sounds like you are using a PCL Xamarin Forms project. I suggest you read more about that here or watch some of the helpful videos around the internet (like this one, which talks about different PCL Profiles) but basically and PCL project attempts to allow many of the common APIs available on all platforms. This means that if a certain platform does not support GetInterfaces() or if the Forms team has not implemented that API yet, it will not be available to your from the Forms project.

The nice thing about Xamarin Forms is that you can still access all native APIs if you need to. To do this you would create an interface and use Xamarin Forms Dependency Service (link) which would probably allow you to access that API from your Forms project.

If you need an example of how to do that, just let me know.

更多推荐

本文发布于:2023-04-29 02:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334554.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不可用   系统   API   Xamarin   APIs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!