I've a portable class library which targets followings:
.NET + Silverlight + WinRT + WinPhone + Android + iOS
The "System.ComponentModel.DataAnnotations" namesapce does not exists in WinPhone
So I've no access to that namespace in my codes
How can I solve this problem as like as "microsoft bcl portability pack"
This package provides access to attributes and classes such as "CallerMemberNameAttribute" but at runtime it will map those classes to their equivalent implementation if exists.
from "http://www.nuget.org/packages/Microsoft.Bcl/":
These types are "unified" to their later version equivalent. For example, when running on .NET Framework 4.5, IProgress from this package will be seen by the runtime as the same type as the one already available in the platform.
You should be able to do this using the "Bait and Switch" PCL technique.
In this case you would create a portable implementation of the data annotation attributes, and on platforms that support the "real" versions, "switch" to a library that type-forwards to those versions. See also this answer: https://stackoverflow.com/a/16046668/1509
If you do this, it would be great if you could publish it as an OSS project and a package on NuGet so that others can benefit from it. This is a fairly common request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With