.netsilverlightmulti-targeting

#IF Silverlight for interfaces


I have a multitargeted domain project (SL and .Net 4.0) and with problem with Color and so on I was using #if SILVERLIGHT constructs, but now I need to have for a SL project using my domain project few classes implementing INotifyDataErrorInfo which is not implemented on .Net 4.0 site and I will never use it.

I would be gratefull for advice how to make something like this

public class MyDomainClass: INotifyPropertyChanged, #IF Silverlight INotifyDataErrorInfo
{

Solution

  • Assuming you can use the partial keyword in silverlight:

    public partial class MyDomainClass: INotifyPropertyChanged 
    {
     // implement everything on INotifyPropertChanged 
    }
    
    
    #IF Silverlight 
    public partial class MyDomainClass:INotifyDataErrorInfo 
    {
         // implement everything on INotifyDataErrorInfo 
         // if needed using the stuff from the 'shared' class
    }
    #ENDIF