Where to store constant objects that will be used in my application

前端 未结 5 1951
[愿得一人]
[愿得一人] 2021-01-23 05:00

Lets say I have an item, which has fields(properties)

  1. Location
  2. Average value
  3. Usability

And I have 10-15 items

5条回答
  •  借酒劲吻你
    2021-01-23 05:33

    What you're describing sounds like the perfect use case for T4

    You could add a T4 template to your project that reads XML data (in design-time within Visual Studio) and generates *.cs files with your static content. If you ever need to modify the data, just modify the XML file and click the Transform All Templates button in the Solution Explorer.

    Keep in mind that this will require you to recompile and redeploy the application if you need to modify those contents. If that is the case, then the solution provided by @Mortalus is the best option.

提交回复
热议问题