public VersionedSettingController() { //Bootstrap from Unity if (_unityContainer == null) { _unityContainer = new UnityContainer().LoadConfiguration(); //Uses the default Unity section "unity" (c.f. https://msdn.microsoft.com/en-us/library/ff660935(v=pandp.20).aspx) } _demonstrationServiceImplementation = _unityContainer.Resolve <IDemonstrationService>("demonstrationServiceImpl"); }
/// <summary> /// Bootstraps this instance. /// </summary> /// <remarks>This uses the Microsoft.Extensions.DependencyInjection IoC mechanism /// because Unity's container configuration isn't available for .NET core. /// While we could still use the main container implementation without too /// much trouble, we can't load from the App.config like we used to.</remarks> private static void Bootstrap() { _container = new ServiceCollection() .AddSingleton(typeof(ISettingProvider), new DictionarySettingProvider(1, "InitialSetting")) .AddSingleton <IDemonstrationService, DemonstrationService>() .BuildServiceProvider(); _service = _container.GetService <IDemonstrationService>(); }