7

I have a project which is customized for different customers, only in the UI. The code is exactly the same for all.

Right now, I copy the whole project to get a different UI for the customer (button alignment, mostly). Is it possible to swap only the UI definitions / specify which to use during build, so I do not need to copy the whole project?

Something like:

UI_cust1
UI_cust2
UI_cust3
...

Build with

UI_cust2
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Alex
  • 71
  • 1
  • you probably want to use the factory pattern – Jonesopolis Jul 28 '14 at 14:47
  • Do you mean localization: http://msdn.microsoft.com/en-us/library/ms788718.aspx ? – Leo Chapiro Jul 28 '14 at 14:49
  • 1
    Something like http://stackoverflow.com/questions/21638054/conditional-compile-in-xaml – Eugene Podskal Jul 28 '14 at 14:51
  • 5
    If the underlying code is the same why not use themes for the customers? – Dreamwalker Jul 28 '14 at 14:52
  • Do not put your signature at the end of the message nor apologize if the question sounds silly... No questions are silly but some answers do :) – Morix Dev Jul 28 '14 at 14:54
  • thanks for the responses so far, i guess factorys would not be the way to go. it is also not about localisation, it is only Button re-positioning, one customer wants the print button in the top left corner the other in bottom right, and green – Alex Jul 28 '14 at 14:54
  • 1
    In addition to Dreamwalkers comment, you might want to start reading about theming/styling [here](http://msdn.microsoft.com/en-us/library/ms745683.aspx) –  Jul 28 '14 at 14:55
  • you need to refactor your customers – Weyland Yutani Jul 28 '14 at 15:07
  • so the way to go would be multiple xaml files packaged in a ResourceDictionary and then select it based on the customer- I#ll read up on that, and thanks for pointing me in this direction, would have never looked that way. – Alex Jul 28 '14 at 15:08
  • You should use an IOC container and store the configuration in a XML file. Each configuration file maps an interface to a concrete implementation which is customer specific. In that way you can provide different configuration files for different customers. – Tim Hansson May 18 '15 at 12:43

2 Answers2

0

Can you provide a configuration provider type of class which reads values from an XML file?

You can then edit the XML per customer.

I think if you create the provider as a data source and then include a converter which takes a key as a parameter to return the specific value, you should be able to create keys for each property you want to control.

I have done similar in the past as a localisation and theming solution and it worked. I haven't got code immediately to hand unfortunately.

kidshaw
  • 3,423
  • 2
  • 16
  • 28
0

I would recommend you to make it a habit to use an IOC (Invertion of Control) container in all your projects. It forces you to use Dependency Injection, which gives you a more modular architecture.

Most IOC containers support XML files for registering dependencies. In that way you only need to change the XML configuration file for different customers. Voilà, you now have a different behavior/appearance of your application for each customer.

As a bonus, your application will be easier to test. Preferable you use TDD (Test Driven Development) while building your application, which will make the whole IOC/DI experience feel very natural.

A good IOC container to start with is AutoFac, a very simple, yet powerful container.

Tim Hansson
  • 309
  • 2
  • 16