by Jeff Handley via Jeff Handley on 11/16/2010 9:39:49 PM
I was one of the developers that ported the System.ComponentModel.DataAnnotations assembly to Silverlight. Every once in awhile, someone asks me if the Silverlight version of the assembly is a subset of what is in .NET. The answer is Yes, but there are some caveats, and I’m honestly tired of regurgitating the detailed answer. With this blog post in place, I can now simply point people to a URL for the answer. This is what we call DRY.
I’m sure that it goes without saying that the implementation details of the two assemblies differ. In the .NET version, we have TypeDescriptor at our disposal, and it’s used to gather metadata about types and members. In Silverlight, TypeDescriptor doesn’t exist, so raw Reflection is used in its place. Moreover, .NET offers the MetadataTypeAttribute to allow metadata to be loaded from another type--Silverlight doesn’t support that either, so again the implementations differ rather significantly. There are other reasons for implementation differences too, but it suffices to say that underneath the public API, the differences are manifold.
Type / Member
.NET
Silverlight
Notes
AssociatedMetadataTypeTypeDescriptionProvider
Yes
No
AssociationAttribute
AssociationAttribute.TypeId
Due to Attribute difference
ConcurrencyCheckAttribute
CustomValidationAttribute
CustomValidationAttribute.TypeId
DataType
DataTypeAttribute
DataTypeAttribute.IsValid(Object)
Internal in Silverlight
DisplayAttribute
DisplayColumnAttribute
DisplayColumnAttribute.HtmlEncode
EditableAttribute
EnumDataTypeAttribute
EnumDataTypeAttribute.IsValid(Object)
FilterUIHintAttribute
FilterUIHintAttribute.TypeId
IValidatableObject
KeyAttribute
MetadataTypeAttribute
RangeAttribute
RangeAttribute.IsValid(Object)
RegularExpressionAttribute
RegularExpressionAttribute.IsValid(Object)
RequiredAttribute
RequiredAttribute.IsValid(Object)
ScaffoldColumnAttribute
ScaffoldTableAttribute
StringLengthAttribute
StringLengthAttribute.IsValid(Object)
TimestampAttribute
UIHintAttribute
UIHintAttribute.TypeId
ValidationAttribute
ValidationAttribute.IsValid(Object)
ValidationAttribute.Validate(Object, String)
ValidationContext
ValidationContext.ServiceContainer
ValidationException
ValidationException.ctor(SerializationInfo, StreamingContext)
ValidationResult
Sealed in Silverlight, not in .NET
ValidationResult.ToString
Overridden in Silverlight, not in .NET
Validator
Original Post: Is Silverlight's DataAnnotations a Subset of .NET's?
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.