// Given an assembly purportedly containing SqlServerTypes for spatial values, attempt to
 // create a corersponding Sql spefic DbSpatialServices value backed by types from that assembly.
 // Uses a dictionary to ensure that there is at most db spatial service per assembly.   It's important that
 // this be done in a way that ensures that the underlying SqlTypesAssembly value is also atomized,
 // since that's caching compilation.
 // Relies on SqlTypesAssembly to verify that the assembly is appropriate.
 private static bool TryGetSpatialServiceFromAssembly(Assembly assembly, out SqlSpatialServices services)
 {
     if (otherSpatialServices == null || !otherSpatialServices.TryGetValue(assembly.FullName, out services))
     {
         lock (Instance)
         {
             if (otherSpatialServices == null || !otherSpatialServices.TryGetValue(assembly.FullName, out services))
             {
                 SqlTypesAssembly sqlAssembly;
                 if (SqlTypesAssembly.TryGetSqlTypesAssembly(assembly, out sqlAssembly))
                 {
                     if (otherSpatialServices == null)
                     {
                         otherSpatialServices = new Dictionary <string, SqlSpatialServices>(1);
                     }
                     services = new SqlSpatialServices(() => sqlAssembly);
                     otherSpatialServices.Add(assembly.FullName, services);
                 }
                 else
                 {
                     services = null;
                 }
             }
         }
     }
     return(services != null);
 }
Пример #2
0
 internal static bool TryGetSqlTypesAssembly(Assembly assembly, out SqlTypesAssembly sqlAssembly)
 {
     if (IsKnownAssembly(assembly))
     {
         sqlAssembly = new SqlTypesAssembly(assembly);
         return(true);
     }
     sqlAssembly = null;
     return(false);
 }
 private static bool TryGetSqlTypesAssembly(out SqlTypesAssembly sqlTypesAssembly)
 {
     sqlTypesAssembly = SqlTypesAssembly.Latest;
     return(sqlTypesAssembly != null);
 }