/// <summary> /// Registers the specified <see cref="TypeRegistration"/> for delayed processing. /// </summary> /// <param name="action">The type registration to register.</param> /// <returns><see langword="true" /> if specified registration was successfully added; /// otherwise, <see langword="false" />.</returns> public bool Register(TypeRegistration action) { this.EnsureNotLocked(); ArgumentValidator.EnsureArgumentNotNull(action, "action"); if (actionSet.Contains(action)) { return(false); } actionSet.Add(action); actions.Add(action); return(true); }
/// <summary> /// Processes the specified registration in the specified registration context. /// </summary> /// <param name="registry">The type registry.</param> /// <param name="registration">The action.</param> public virtual void Process(TypeRegistry registry, TypeRegistration registration) { var types = registration.Type == null ? FindTypes(registration.Assembly, BaseType, (type, typeFilter) => IsAcceptable(registration, type)) : EnumerableUtils.One(registration.Type).Where(t => IsAcceptable(registration, t)); foreach (var type in types) { Process(registry, registration, type); } }
/// <summary> /// Determines whether the specified type is acceptable for registration. /// </summary> /// <param name="registration">The currently processed registration.</param> /// <param name="type">The type to check.</param> /// <returns> /// <see langword="true"/> if the specified type is acceptable for registration; /// otherwise, <see langword="false"/>. /// </returns> protected virtual bool IsAcceptable(TypeRegistration registration, Type type) { string ns = registration.Namespace; return(type.IsSubclassOf(BaseType) && (ns.IsNullOrEmpty() || (type.FullName.IndexOf(ns + ".", StringComparison.InvariantCulture) >= 0))); }
/// <summary> /// Processes the single type registration. /// </summary> /// <param name="registry">The type registry.</param> /// <param name="registration">The registration.</param> /// <param name="type">The type.</param> protected virtual void Process(TypeRegistry registry, TypeRegistration registration, Type type) { registry.Register(type); }