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
namespace Utilities.Data | |
{ | |
public static class Extensions | |
{ | |
public static string ToJson(this Object obj) | |
{ | |
return (new JavaScriptSerializer()).Serialize(obj); | |
} | |
} |
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
public interface IBusinessLogicService | |
{ | |
int DoSomething(int x); | |
} | |
public class MainLogicService : IBusinessLogicService | |
{ | |
public int DoSomething(int x) | |
{ | |
return 1 + x; |
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
public class SubContext | |
{ | |
private readonly IUnityContainer _childContainer; | |
public SubContext(IUnityContainer container) | |
{ | |
_childContainer = container.CreateChildContainer(); | |
_childContainer.RegisterType<IBusinessLogicService, AltLogicService>(); | |
} |
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
public enum ServiceTypes { Main, Alt }; | |
public interface IConfig | |
{ | |
ServiceTypes ServiceSetting { get; set; } | |
} | |
public class Config : IConfig | |
{ | |
public ServiceTypes ServiceSetting { get; set; } |
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
public class ClientConfigLoop | |
{ | |
private readonly IClientConfigRepo _configRepo; | |
private readonly InterfaceFactory _interfaceFactory; | |
public ClientConfigLoop(IClientConfigRepo configRepo, InterfaceFactory interfaceFactory) | |
{ | |
_interfaceFactory = interfaceFactory; | |
_configRepo = configRepo; | |
} |
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
public class DependencyResolver : IDependencyResolver | |
{ | |
private readonly SessionContainerManager _containerManager; | |
public DependencyResolver(SessionContainerManager containerManager) | |
{ | |
_containerManager = containerManager; | |
} | |
protected IUnityContainer ChildContainer |
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
public class SessionContainerManager | |
{ | |
private const string HttpContextKey = "Container"; | |
private readonly IUnityContainer _container; | |
public SessionContainerManager(IUnityContainer container) | |
{ | |
_container = container; | |
} |
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
public class ExtensionLoader | |
{ | |
private readonly IUnityContainer _container; | |
private readonly IClientConfigRepo _configRepo; | |
public ExtensionLoader(IUnityContainer container, IClientConfigRepo configRepo) | |
{ | |
_configRepo = configRepo; | |
_container = container; | |
} |
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
public class ControllerFactory : DefaultControllerFactory | |
{ | |
private readonly IUnityContainer _container; | |
private readonly SessionContainerManager _containerManager; | |
public ControllerFactory(IUnityContainer container, SessionContainerManager containerManager) | |
{ | |
_containerManager = containerManager; | |
_container = container; | |
} |
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
public class Bootstrapper | |
{ | |
public static IUnityContainer Initialise() | |
{ | |
var container = BuildUnityContainer(); | |
var containerManager = new SessionContainerManager(container); | |
var dependencyResolver = new DependencyResolver(containerManager); | |
var controllerFactory = new ControllerFactory(container, containerManager); | |
DependencyResolver.SetResolver(dependencyResolver); |
OlderNewer