/// <summary> /// Evaluates if a specified type was registered in the container. /// </summary> /// <param name="container">The container to check if the type was registered in.</param> /// <param name="type">The type to check if it was registered.</param> /// <returns><see langword="true" /> if the <paramref name="type"/> was registered with the container.</returns> /// <remarks> /// In order to use this extension, you must first call <see cref="UnityContainerExtensions.AddNewExtension{TExtension}"/> /// and specify <see cref="UnityContainerExtension"/> as the extension type. /// </remarks> public static bool IsTypeRegistered(IUnityContainer container, Type type) { PrismUnityExtension extension = container.Configure <PrismUnityExtension>(); if (extension == null) { //Extension was not added to the container. return(false); } IBuildKeyMappingPolicy policy = extension.Context.Policies.Get <IBuildKeyMappingPolicy>(new NamedTypeBuildKey(type)); return(policy != null); }
/// <summary> /// Returns whether a specified type has a type mapping registered in the container. /// </summary> /// <param name="container">The <see cref="IUnityContainer"/> to check for the type mapping.</param> /// <param name="type">The type to check if there is a type mapping for.</param> /// <returns><see langword="true"/> if there is a type mapping registered for <paramref name="type"/>.</returns> /// <remarks>In order to use this extension method, you first need to add the /// <see cref="IUnityContainer"/> extension to the <see cref="UnityBootstrapperExtension"/>. /// </remarks> public static bool IsTypeRegistered(this IUnityContainer container, Type type) { return(PrismUnityExtension.IsTypeRegistered(container, type)); }