Esempio n. 1
0
        internal static DbProviderServices GetProviderServices(DbProviderFactory factory)
        {
            EDesignUtil.CheckArgumentNull(factory, "factory");

            // Special case SQL client so that it will work with System.Data from .NET 4.0 even without
            // a binding redirect.
            if (factory is SqlClientFactory)
            {
                return(SqlProviderServices.Instance);
            }

            IServiceProvider serviceProvider = factory as IServiceProvider;

            if (serviceProvider == null)
            {
                throw MetadataUtil.ProviderIncompatible(System.Data.Entity.Design.Strings.EntityClient_DoesNotImplementIServiceProvider(
                                                            factory.GetType().ToString()));
            }

            DbProviderServices providerServices = serviceProvider.GetService(typeof(DbProviderServices)) as DbProviderServices;

            if (providerServices == null)
            {
                throw MetadataUtil.ProviderIncompatible(
                          System.Data.Entity.Design.Strings.EntityClient_ReturnedNullOnProviderMethod(
                              "GetService",
                              factory.GetType().ToString()));
            }
            return(providerServices);
        }
Esempio n. 2
0
        internal static string MembersToCommaSeparatedString(IEnumerable members)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");
            MetadataUtil.ToCommaSeparatedString(builder, members);
            builder.Append("}");
            return(builder.ToString());
        }
Esempio n. 3
0
 private void WriteExtendedPropertyAttributes(MetadataItem item)
 {
     foreach (MetadataProperty property in item.MetadataProperties.Where(p => p.PropertyKind == PropertyKind.Extended))
     {
         string xmlNamespace, attributeName;
         if (MetadataUtil.TrySplitExtendedMetadataPropertyName(property.Name, out xmlNamespace, out attributeName))
         {
             _writer.WriteAttributeString(attributeName, xmlNamespace, property.Value.ToString());
         }
     }
 }