I am sure this is a very strange requirement, but it does.
We have a client configuration code that is represented by C # classes, which we compile into a class library. Creating these configuration classes is currently a monkey job that I would like to assign to someone other than the developer. Therefore, we are creating the Configurator website, which a business analyst can use to create valid C # classes by filling out a form with the appropriate parameters selected.
What is the best way to create a C # class from a template on an MVC website? Note that I am not talking here about dynamically creating and executing a class at runtime: we essentially generate a text file that simply contains C # code that will be included in a completely different project.
This is a very difficult topic for Google! Parameters that have appeared so far ...
- just use a tokenized text file and replace the values with String.Format
- somehow use Razor as a template engine (but not sure how, and this is not the html that we generate)
- use T4 templates somehow (at least I know that it was used to create C #, but not sure how to execute at runtime)
Any ideas on how best to approach this?
/. , , , .. .
public class AreaRiskTemplate: AreaRiskTemplateBase
{
public override string EntityName { get { return "risk"; } }
public override string EntityNamePlural { get { return "risks"; } }
public override string EntityNameArticle { get { return "a"; } }
public override string CGovItemRefPrefix { get { return "R"; } }
public override void SetFieldDefinitions()
{
FieldDefinitions.Level1.IsImplemented = true;
FieldDefinitions.Level1.Label = "Category";
FieldDefinitions.Level1.IsVisibleInGrid = true;
FieldDefinitions.Level2.IsImplemented = true;
FieldDefinitions.Level2.Label = "Team";
FieldDefinitions.Level2.IsVisibleInGrid = true;
FieldDefinitions.Description.IsImplemented = true;
FieldDefinitions.Description.Label = "Description";
FieldDefinitions.Description.IsVisibleInGrid = true;
}
public override ModelStateDictionary Validate()
{
var msd = new ModelStateDictionary();
msd.Merge(base.Validate());
return msd;
}
public override List<string> Level1Options
{
get
{
return new List<string>
{
"Organisational",
"Financial",
"Operational",
"External",
"IT"
};
}
}
}
: T4 http://msdn.microsoft.com/en-us/library/ee844259(v=vs.100).aspx ( ). .