/// <summary> /// Registers a type in the container only if that type was not already registered. /// </summary> /// <param name="fromType">The registration type.</param> /// <param name="toType">The type implementing the registration type.</param> /// <param name="scope">Scope of the registered type.</param> /// <returns> /// The <see cref="IContainerAdapter"/> with the newly registered element. /// </returns> public IContainerAdapter RegisterTypeIfMissing(Type fromType, Type toType, ContainerRegistrationScope scope) { if (Container.IsRegistered(fromType)) { ContainerAdapterExtensions.TypeMappingAlreadyRegistered(Logger, fromType); } else { RegisterType(fromType, toType, scope); } return(this); }
public IContainerAdapter RegisterTypeIfMissing <TFrom, TTo>(ContainerRegistrationScope scope) where TTo : TFrom { if (Container.IsRegistered <TFrom>()) { Logger.Log( string.Format( CultureInfo.InvariantCulture, "Type is already registered: {0}", typeof(TFrom).Name), Category.Warn, Priority.Medium); ContainerAdapterExtensions.TypeMappingAlreadyRegistered <TFrom>(Logger); } else { RegisterType <TFrom, TTo>(scope); } return(this); }