Skip to content

Commit 662f087

Browse files
committed
Added TemplateBase
1 parent 991fefa commit 662f087

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace DesignPatternsInCSharp.TemplateMethod.Inheritance
2+
{
3+
public abstract class TemplateBase
4+
{
5+
private bool _importantSetting;
6+
public void Do()
7+
{
8+
BeforeDoing();
9+
Initialize();
10+
AfterDone();
11+
}
12+
13+
public virtual void BeforeDoing()
14+
{ }
15+
16+
public abstract void AfterDone();
17+
18+
private void Initialize()
19+
{
20+
_importantSetting = true;
21+
}
22+
}
23+
24+
public class TemplateChild : TemplateBase
25+
{
26+
public override void AfterDone()
27+
{
28+
// do other stuff
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)