PageRenderTime 57ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/V1/CORE-APPFABRIC/Infrastructure.CrossCutting.IoC/IoCFactory.cs

#
C# | 96 lines | 54 code | 17 blank | 25 comment | 0 complexity | 091368bcab9dfe4600fa62c5b6afa643 MD5 | raw file
  1. // Microsoft Developer & Platform Evangelism
  2. //===================================================================================
  3. // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  4. // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
  5. // OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  6. //===================================================================================
  7. // Copyright (c) Microsoft Corporation. All Rights Reserved.
  8. // This code is released under the terms of the MS-LPL license,
  9. // http://microsoftnlayerapp.codeplex.com/license
  10. //===================================================================================
  11. using System;
  12. using Microsoft.Practices.Unity;
  13. using Microsoft.Samples.NLayerApp.Application.MainModule.BankingManagement;
  14. using Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement;
  15. using Microsoft.Samples.NLayerApp.Application.MainModule.SalesManagement;
  16. using Microsoft.Samples.NLayerApp.Domain.MainModule.BankAccounts;
  17. using Microsoft.Samples.NLayerApp.Domain.MainModule.Countries;
  18. using Microsoft.Samples.NLayerApp.Domain.MainModule.Customers;
  19. using Microsoft.Samples.NLayerApp.Domain.MainModule.Orders;
  20. using Microsoft.Samples.NLayerApp.Domain.MainModule.Products;
  21. using Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.Caching;
  22. using Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.IoC.Resources;
  23. using Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.IoC.Unity;
  24. using Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.IoC.Unity.LifetimeManagers;
  25. using Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.Logging;
  26. using Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.NetFramework.Caching;
  27. using Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.NetFramework.Logging;
  28. using Microsoft.Samples.NLayerApp.Infrastructure.Data.MainModule.Repositories;
  29. using Microsoft.Samples.NLayerApp.Infrastructure.Data.MainModule.UnitOfWork;
  30. using Microsoft.Samples.NLayerApp.Infrastructure.Data.MainModule.Mock;
  31. using System.Configuration;
  32. namespace Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.IoC
  33. {
  34. /// <summary>
  35. /// IServiceFactory implementation
  36. /// </summary>
  37. public sealed class IoCFactory
  38. {
  39. #region Singleton
  40. static readonly IoCFactory instance = new IoCFactory();
  41. /// <summary>
  42. /// Get singleton instance of IoCFactory
  43. /// </summary>
  44. public static IoCFactory Instance
  45. {
  46. get
  47. {
  48. return instance;
  49. }
  50. }
  51. #endregion
  52. #region Members
  53. IContainer _CurrentContainer;
  54. /// <summary>
  55. /// Get current configured IContainer
  56. /// <remarks>
  57. /// At this moment only IoCUnityContainer existss
  58. /// </remarks>
  59. /// </summary>
  60. public IContainer CurrentContainer
  61. {
  62. get
  63. {
  64. return _CurrentContainer;
  65. }
  66. }
  67. #endregion
  68. #region Constructor
  69. /// <summary>
  70. /// Only for singleton pattern, remove before field init IL anotation
  71. /// </summary>
  72. static IoCFactory() { }
  73. IoCFactory()
  74. {
  75. _CurrentContainer = new IoCUnityContainer();
  76. }
  77. #endregion
  78. }
  79. }