I have some problem with finding whole class text using RegEx in C#. I need whole structure, including "public class ..." to last parenthesis, because it will be compiled as dynamic code (using CSharpCodeProvider object).
Here is sample code of my class:
[Worker("Structure")]
public class DataSourceStructure
{
DataSet mainData = new DataSet();
DataTable worker = new DataTable("Worker");
DataTable year = new DataTable("Year");
public DataSet MainSource
{
get
{
worker.Columns.Add("Name");
worker.Columns.Add("MonthSallary");
worker.Columns.Add("DateOfBirth");
worker.Columns.Add("WorkDescription");
worker.Columns.Add("Sex");
worker.Columns.Add("Worker_Id", typeof(int));
year.Columns.Add("YearOfEmployment");
year.Columns.Add("Worker_Id", typeof(int));
mainData.Tables.Add(worker);
mainData.Tables.Add(year);
DataRelation rel = new DataRelation("Worker_Year", mainData.Tables["Worker"].Columns["Worker_Id"], mainData.Tables["Year"].Columns["Worker_Id"], true);
mainData.Relations.Add(rel);
return mainData;
}
set
{
mainData = value;
}
}
}
I tried some ways described on StackOverflow (for example: Using RegEx to balance match parenthesis), but it doesn't work for me... or I don't know how to rebuild it correctly. ;/
Thanks in advance for every help.