Generate properties programmatically

前端 未结 7 854
难免孤独
难免孤独 2021-01-04 17:47

I want to load a properties file (it\'s a .csv file having on each line a name and associated numeric value) and then access those property values like so: FileLoader

7条回答
  •  余生分开走
    2021-01-04 18:46

    Code generation like this can be done in several different ways.

    • Visual Studio has T4 templates.
    • You can use external tools like My Generation (it is geared towards ORM code generations, not sure it supports CSV).
    • Or roll out your own code to read the file and write out such classes (to be created with a .generated.cs suffix).

提交回复
热议问题