Étiquettes

, , , , , ,

Today we have a several type of devices and the number is growing. So, we have to develop our application several times. A way to add functionality to our applications without difficult is to use a derivation of the  Abstract Design Pattern : Template Method. In this tutorial we learn how  to add functionality to several  applications and make them  use  the same Architecture but  details vary depending on the context. Our contexts are Windows Phone, Surface and XBOX data displaying  behaviors We will use a Portable class Library that hold the shared functionnalities.

  • Add a new file
  • choose  Portable class Library
  • Click OK

1

  • Check the targeted framworks and click OK

2

  • Create a ScreenBase Class as follow

3

  • Create a PhoneScreenService class as follow

4

GetData, FormatData and RenderContent are protected because TabletScreenServicePhoneScreenService will be use as base classes

  • Create a TabletScreenService class as follow
  • 5
  • To test it create a console application and référence our Portable Class Library as follow.
  • 6
  • Press F5 to run application, so you can see that the behaviour is different between windows Phone and Surface tablet.7Our sample is finish but in a real world application, we must reference our portable class library in both windows Phone client, surface client, XBOX client and sower. and  implement business logic for each client,

Regards