What's the difference between .shared, .metadata and .partial files in Silverlight RIA applications?
I have seen these 3 file types around, though not in the same application. What are they, what is the difference between them and are there any other special extensions开发者_开发知识库 to know about?
I try to clarify it a little bit.
A code file with the .shared extension gets "copied" to the silverlight client project during compilation. So that you can manage the code on server side, but use the same code on the client side. Here you can find a definition about the SharedCode feature in silverlight.
A code file with the .metadata extension gets normally generated by the "New Domain Service class"-Wizard in Visual Studio when you check the option "Generate associated classes for metadata". This file contains additional metadata information about a class, like ValidationAttributes for the silverlight client. Here´s you can find information about Metadata in WCF RIA Services.
A code files with the .partial extension signals only that this file contains additional partial code (implementation of partial methods, additional methods or properties) for a class. This is normally used, when you are extending a class that is autogenerated by a designer (like Entity Framework).
The only really special extension is .shared, cause theses files are especially handle on compilation. All other extension are only naming conventions for files, to signal what code is inside a file.
Sidenote: What i currently do is that when i implement an interface on a class i define the class as partial and put the interface implementation code in a other code file with the interface name as extension.
Example:
UserListViewModel.cs --> partial class UserListViewModel with the implementation of the viewmodel
UserListViewModel.INavigationAware.cs --> partial class UserListViewModel with the implementation of the INavigationAware interface for the viewmodel.
精彩评论