Reputation: 145
Don't judge me, but I have an object with over 100 properties, most of them string. Is there anyway to automatically add them to the code, without extensive typing? I have them all in a text file with correct casing. I looked for plug ins, but couldn't find any (maybe using wrong keywords?)
Upvotes: 0
Views: 105
Reputation: 4515
Notepad++ can do it quite easily.
(.*)
public string \1 {get;set;}
And voilà:
Note that this should work with any editor that handle regex (as stated by @Klamsi in the comments section)
Upvotes: 2
Reputation: 354
I am assuming your file looks like:
Property
SomeOtherProperty
Test
The easiest way would be to use a CSV -> C# Model generator
Change it to be comma separated, you can do this with C#:
var path = @"C:\Path\To\Your\File.txt";
var text = File.ReadAllText(path);
text = text.Replace(Environment.NewLine, ",");
File.WriteAllText(path, text);
Open the file and copy its contents to your clipboard.
Now open the C# Class from CSV tool.
Paste the contents and voila you have a C# model!
Upvotes: 3