Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
authored and
unknown
committed
Apr 15, 2009
1 parent
9a86a35
commit 954dea3
Showing
7 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace ApplicationControllerExample.App | ||
{ | ||
public interface IMainView | ||
{ | ||
MainPresenter Presenter { get; set; } | ||
void Run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using ApplicationControllerExample.AppController; | ||
|
||
namespace ApplicationControllerExample.App | ||
{ | ||
|
||
public class MainPresenter | ||
{ | ||
|
||
private IMainView View { get; set; } | ||
private IApplicationController AppController { get; set; } | ||
|
||
public MainPresenter(IMainView mainView, IApplicationController appController) | ||
{ | ||
View = mainView; | ||
AppController = appController; | ||
View.Presenter = this; | ||
} | ||
|
||
public void Run() | ||
{ | ||
View.Run(); | ||
} | ||
|
||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
ApplicationControllerExample/AppController/ApplicationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using ApplicationControllerExample.App; | ||
using StructureMap; | ||
|
||
namespace ApplicationControllerExample.AppController | ||
{ | ||
|
||
public class ApplicationController : IApplicationController | ||
{ | ||
|
||
private IContainer Container { get; set; } | ||
|
||
public ApplicationController(IContainer container) | ||
{ | ||
Container = container; | ||
} | ||
|
||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
ApplicationControllerExample/AppController/IApplicationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ApplicationControllerExample.AppController | ||
{ | ||
public interface IApplicationController | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Windows.Forms; | ||
using StructureMap; | ||
|
||
namespace ApplicationControllerExample | ||
{ | ||
public class BootStrapper | ||
{ | ||
|
||
private IContainer Container { get; set; } | ||
|
||
public BootStrapper(IContainer container) | ||
{ | ||
Container = container; | ||
} | ||
|
||
public ApplicationContext GetAppContext() | ||
{ | ||
Container.Configure(c => c.AddRegistry<DefaultRegistry>()); | ||
return Container.GetInstance<ApplicationContext>(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Windows.Forms; | ||
using ApplicationControllerExample.App; | ||
using ApplicationControllerExample.AppController; | ||
using ApplicationControllerExample.View; | ||
using StructureMap.Configuration.DSL; | ||
|
||
namespace ApplicationControllerExample | ||
{ | ||
|
||
public class DefaultRegistry : Registry | ||
{ | ||
|
||
public DefaultRegistry() | ||
{ | ||
ForRequestedType<ApplicationContext>() | ||
.TheDefault.Is.OfConcreteType<ExampleContext>(); | ||
|
||
ForRequestedType<IApplicationController>() | ||
.TheDefault.Is.OfConcreteType<ApplicationController>(); | ||
|
||
ForRequestedType<IMainView>() | ||
.TheDefault.Is.OfConcreteType<Form1>(); | ||
|
||
ForRequestedType<MainPresenter>() | ||
.TheDefault.Is.OfConcreteType<MainPresenter>(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Windows.Forms; | ||
using ApplicationControllerExample.App; | ||
using ApplicationControllerExample.AppController; | ||
using ApplicationControllerExample.View; | ||
using StructureMap; | ||
|
||
namespace ApplicationControllerExample | ||
{ | ||
|
||
public class ExampleContext : ApplicationContext | ||
{ | ||
|
||
private IApplicationController AppController { get; set; } | ||
private IContainer Container { get; set; } | ||
|
||
public ExampleContext(IApplicationController appController, IContainer container) | ||
{ | ||
AppController = appController; | ||
Container = container; | ||
MainForm = GetMainForm(); | ||
} | ||
|
||
private Form GetMainForm() | ||
{ | ||
Form1 mainForm = new Form1(); | ||
new MainPresenter(mainForm, AppController); | ||
return mainForm; | ||
} | ||
|
||
} | ||
|
||
} |