Exemplo n.º 1
0
 ///<summary>
 /// Initialize the global inversion of control reference with the <paramref name="sectionName"/>.
 /// <see cref="IoC"/> allows us to drop in a different inversion of control container
 /// that will vary between different companies' implementations of the gateway and agent.
 ///</summary>
 ///<param name="sectionName">The container to use as the resolver</param>
 ///<returns>Returns a reference to the resolver so it can be used in method chaining.</returns>
 ///<exception cref="ArgumentNullException">Throw if <paramref name="sectionName"/> was null</exception>
 public static IDependencyResolver Initialize(string sectionName)
 {
     try
     {
         IocContainerSection  section   = IocContainerSection.Load(sectionName);
         IDependencyContainer container = section.CreateContainer();
         return(container.RegisterFromConfig());
     }
     catch (Exception ex)
     {
         EventLogHelper.WriteError("While initializing container", ex.ToString());
         throw;
     }
 }