public virtual void AddFacility(String key, IFacility facility) { if (key == null) { throw new ArgumentNullException("key"); } if (facility == null) { throw new ArgumentNullException("facility"); } facility.Init(this, ConfigurationStore.GetFacilityConfiguration(key)); facilities.Add(facility); }
public virtual IKernel AddFacility(string key, IFacility facility) { if (facility == null) { throw new ArgumentNullException(nameof(facility)); } var facilityType = facility.GetType(); if (facilities.Any(f => f.GetType() == facilityType)) { throw new ArgumentException( $"Facility of type '{facilityType.FullName}' has already been registered with the container. Only one facility of a given type can exist in the container."); } facilities.Add(facility); facility.Init(this, ConfigurationStore.GetFacilityConfiguration(key)); return(this); }