Created
November 30, 2010 03:06
-
-
Save cammerman/721076 to your computer and use it in GitHub Desktop.
Autofac Blog Post Samples
This file contains hidden or 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
| interface IComparisonWindow { /* ... */ } | |
| class ComparisonWindow : IComparisonWindow { /* ... */ } | |
| enum EComparisonSide | |
| { | |
| Left, | |
| Right | |
| } |
This file contains hidden or 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
| builder | |
| .RegisterType<ComparisonWindow>() | |
| .As<IComparisonWindow>() | |
| .InstancePerMatchingLifetimeScope(EComparisonSide.Left) | |
| builder | |
| .RegisterType<ComparisonWindow>() | |
| .As<IComparisonWindow>() | |
| .InstancePerMatchingLifetimeScope(EComparisonSide.Right); |
This file contains hidden or 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
| interface IAlertDialog { /* ... */ } | |
| class AlertDialog : IAlertDialog { /* ... */ } |
This file contains hidden or 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
| builder | |
| .RegisterType<AlertDialog>() | |
| .As<IAlertDialog>() | |
| .InstancePerDependency(); |
This file contains hidden or 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
| interface IDifferenceMap { /* ... */ } | |
| class DifferenceMap : IDifferenceMap { /* ... */ } |
This file contains hidden or 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
| builder | |
| .RegisterType<DifferenceMap>() | |
| .As<IDifferenceMap>() | |
| .InstancePerLifetimeScope(); |
This file contains hidden or 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
| class IoCBootstrap | |
| { | |
| public virtual IContainer MainContainer | |
| { | |
| get; | |
| protected set; | |
| } | |
| public virtual IContainer LeftContainer | |
| { | |
| get; | |
| protected set; | |
| } | |
| public virtual IContainer RightContainer | |
| { | |
| get; | |
| protected set; | |
| } | |
| protected virtual ContainerBuilder Builder | |
| { | |
| get; | |
| private set; | |
| } | |
| public void RegisterComponents() | |
| { | |
| Builder = new ContainerBuilder(); | |
| /* Registration code */ | |
| } | |
| public void BuildResolvers() | |
| { | |
| MainContainer = Builder.Build(); | |
| LeftContainer = MainContainer.BeginLifetimeScope(EComparisonSide.Left); | |
| RightContainer = MainContainer.BeginLifetimeScope(EComparisonSide.Right); | |
| } | |
| } |
This file contains hidden or 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
| interface IFileAccess { /* ... */ } | |
| class FileAccess : IFileAccess { /* ... */ } |
This file contains hidden or 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
| var builder = ContainerBuilder(); | |
| builder | |
| .RegisterType<Repository>() | |
| .As<IRepository>() | |
| .SingleInstance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment