简体   繁体   English

monodroid中的DataAnnotations

[英]DataAnnotations in monodroid

I have some models in a core library I'd like to share with a MonoDroid project, but System.ComponentModel.DataAnnotations is not available to the monodroid target. 我在核心库中有一些模型,我想与MonoDroid项目共享,但是对于monodroid目标, System.ComponentModel.DataAnnotations不可用。 I tried grabbing the code for System.ComponentModel.DataAnnotations from the mono source and compiling the source code into the project but ended up going into a rabbit hole trying to get it to compile with all it's dependencies. 我尝试从单一来源获取System.ComponentModel.DataAnnotations的代码并将源代码编译到项目中,但最终进入了一个兔子洞,试图让它与所有它的依赖项一起编译。

Anyone have any suggestions or steps on how I can include that namespace in Xamarin monodroid and monotouch projects? 任何人都有关于如何在Xamarin monodroid和monotouch项目中包含该命名空间的任何建议或步骤?

If not, maybe a suggestion on how I can include my model class library in my xamarin projects without build errors. 如果没有,可能会建议如何在我的xamarin项目中包含我的模型类库而不会出现构建错误。

Soner, it would appear they are still not available at the moment in Xamarin. Soner,看来他们目前在Xamarin仍然无法使用。 However, I did not have any issue using DataContract , and DataMember annotations in my Portable Class Libraries. 但是,我的可移植类库中使用DataContract和DataMember注释没有任何问题。 If your not using PCL's I highly recommend it for any code sharing scenarios anyways. 如果您不使用PCL,我强烈推荐它用于任何代码共享方案。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM