Exemple #1
0
        /// <summary>Gets the provider-specific information.</summary>
        /// <returns>The provider-specific information.</returns>
        /// <param name="informationType">The type of the information to return.</param>
        public XmlReader GetInformation(string informationType)
        {
            XmlReader reader = null;

            try
            {
                reader = GetDbInformation(informationType);
            }
            catch (Exception e)
            {
                // we should not be wrapping all exceptions
                if (e.IsCatchableExceptionType())
                {
                    // we don't want folks to have to know all the various types of exceptions that can
                    // occur, so we just rethrow a ProviderIncompatibleException and make whatever we caught
                    // the inner exception of it.
                    throw new ProviderIncompatibleException(Strings.EntityClient_FailedToGetInformation(informationType), e);
                }
                throw;
            }
            if (reader == null)
            {
                // if the provider returned null for the conceptual schema definition, return the default one
                if (informationType == ConceptualSchemaDefinitionVersion3 ||
                    informationType == ConceptualSchemaDefinition)
                {
                    return(DbProviderServices.GetConceptualSchemaDefinition(informationType));
                }

                throw new ProviderIncompatibleException(Strings.ProviderReturnedNullForGetDbInformation(informationType));
            }
            return(reader);
        }
Exemple #2
0
        /// <summary>Gets the provider-specific information.</summary>
        /// <returns>The provider-specific information.</returns>
        /// <param name="informationType">The type of the information to return.</param>
        public XmlReader GetInformation(string informationType)
        {
            XmlReader dbInformation;

            try
            {
                dbInformation = this.GetDbInformation(informationType);
            }
            catch (Exception ex)
            {
                if (ex.IsCatchableExceptionType())
                {
                    throw new ProviderIncompatibleException(Strings.EntityClient_FailedToGetInformation((object)informationType), ex);
                }
                throw;
            }
            if (dbInformation != null)
            {
                return(dbInformation);
            }
            if (informationType == "ConceptualSchemaDefinitionVersion3" || informationType == "ConceptualSchemaDefinition")
            {
                return(DbProviderServices.GetConceptualSchemaDefinition(informationType));
            }
            throw new ProviderIncompatibleException(Strings.ProviderReturnedNullForGetDbInformation((object)informationType));
        }
 public void GetConceptualSchemaDefinition_throws_ArgumentNullException_for_null_or_empty_resource_name()
 {
     foreach (var csdlName in new[] { null, string.Empty })
     {
         Assert.Throws <ArgumentException>(
             () => DbProviderServices.GetConceptualSchemaDefinition(csdlName));
     }
 }
 public void GetConceptualSchemaDefinition_returns_non_null_XmlReader_for_valid_resource_names()
 {
     foreach (var csdlName in new[] { "ConceptualSchemaDefinition", "ConceptualSchemaDefinitionVersion3" })
     {
         using (var reader = DbProviderServices.GetConceptualSchemaDefinition(csdlName))
         {
             Assert.NotNull(reader);
         }
     }
 }