/// <summary>
        /// Sets the <see cref="IBusinessObjectProvider"/> to be associated with the <see cref="BusinessObjectProviderAttribute"/> type specified.
        /// </summary>
        /// <param name="businessObjectProviderAttributeType">
        /// A <see cref="Type"/> derived from <see cref="BusinessObjectProviderAttribute"/>. Must not be <see langword="null" />.
        /// </param>
        /// <param name="provider">
        /// The <see cref="IBusinessObjectProvider"/> instance to be associated with the <paramref name="businessObjectProviderAttributeType"/>.
        /// Pass <see langword="null"/> to remove the association.
        /// </param>
        public static void SetProvider(Type businessObjectProviderAttributeType, IBusinessObjectProvider provider)
        {
            ArgumentUtility.CheckNotNullAndTypeIsAssignableFrom(
                "businessObjectProviderAttributeType", businessObjectProviderAttributeType, typeof(BusinessObjectProviderAttribute));

            if (provider != null)
            {
                BusinessObjectProviderAttribute attribute = CreateBusinessObjectProviderAttribute(businessObjectProviderAttributeType);
                if (!TypeExtensions.CanAscribeTo(provider.GetType(), attribute.BusinessObjectProviderType))
                {
                    throw new ArgumentException(
                              "The provider is not compatible with the provider-type required by the businessObjectProviderAttributeType's instantiation.", "provider");
                }

                if (provider is BusinessObjectProvider)
                {
                    ((BusinessObjectProvider)provider)._providerAttribute = attribute;
                }
            }

            s_businessObjectProviderStore.Remove(businessObjectProviderAttributeType);
            if (provider != null)
            {
                s_businessObjectProviderStore.Add(businessObjectProviderAttributeType, provider);
            }
        }
        private static IBusinessObjectProvider CreateBusinessObjectProviderFromAttribute(Type businessObjectProviderAttributeType)
        {
            BusinessObjectProviderAttribute attribute = CreateBusinessObjectProviderAttribute(businessObjectProviderAttributeType);
            IBusinessObjectProvider         provider  = CreateBusinessObjectProvider(attribute.BusinessObjectProviderType);

            if (provider is BusinessObjectProvider)
            {
                ((BusinessObjectProvider)provider)._providerAttribute = attribute;
            }

            return(provider);
        }