For platform-specific functionality in PCL, the obvious answer (other than failure) is to inject some type of dependency or use a service locator. Your example, in my opinion, is a good use of DI in general, even ignoring the actual limitations of PCL - you are really connecting to a different behavior.
The ala RX “enlightenment platform” is another approach (a good overview of all of these approaches here ), where the PCL loads additional assemblies through reflection.
In any case, you will increase the number of projects. I think that there is an argument that the maximum possible use of PCL and the separation of platform functionality into separate small fragments is cleaner than a large shared library that is associated with several projects, where the difference between general and # if-conditional code is less obvious.
Regarding the question “can you say if (platform == WP7)”, your PCL cannot contain conditional code, although the PCL can target a subset of platforms, all of which contain the required functionality.
source share