Static void main (){
// Create proxy and request a service
// Proxy = new proxy ();
// Proxy. Request ();
// Wait for user
Generationstaticpage P = new generationstaticpage ();
String pagecontent = P. generationpage ();
Console. Write (pagecontent );
Console. Read ();
}
Public class generationstaticpage
{
# Region attributes
Public String membername
{
Get
{
Return "vodgo ";
}
Set
{
//
}
}
Public String meetingname
{
Get
{
Return "productor page ";
}
Set
{
//
}
}
Public String roomname
{
Get
{
Return "24-1 ";
}
Set
{
//
}
}
Public String begintime
{
Get
{
Return "12:01:29 ";
}
Set
{
//
}
}
# Endregion
Public String generationpage ()
{
// read the template content (write the method yourself)
string content = "Hello ,#? Membername? # Attend the meeting :#? Meetingname? #. Location :#? Roomname? #. Time :#? Begintime? #. ";
stringbuilder builder = new stringbuilder (content);
string pattern = @"#\? (? 'Properties' \ s + ?) \? # ";
return RegEx. Replace (content, pattern, new matchevaluator (regexmatchevaluation), regexoptions. explicitcapture);
}
Private string regexmatchevaluation (match)
{
// Get the property name (named group of the RegEx)
String propertyname = match. Groups ["property"]. value;
// Try to get a property handle from the Business Object
Propertyinfo Pi = This. GetType (). getproperty (propertyname );
// Do not replace anything if no such property exists
If (Pi = NULL)
{
Return match. value;
}
// Return the property value
Object propertyvalue = pi. getvalue (this, null );
If (propertyvalue! = NULL)
{
Return propertyvalue. tostring ();
}
Else
{
Return string. empty;
}
}
}
Compare template content:
Hi ,#? Membername? # Attend the meeting :#? Meetingname? #. Location :#? Roomname? #. Time :#? Begintime? #.
Running result:
Hello, vodgo. Please attend the meeting: productor page. Location: 24-1. Time: 2007-12-1 12:01:29.