@@ -61,7 +61,7 @@ class TypeHandlerRegistry
6161 [ CanBeNull ]
6262 internal Dictionary < Type , TypeHandler > ArrayHandlerByType { get ; set ; }
6363
64- AvailablePostgresTypes _postgresTypes ;
64+ internal AvailablePostgresTypes PostgresTypes { get ; private set ; }
6565
6666 /// <summary>
6767 /// A counter that is updated when this registry activates its global mappings.
@@ -117,14 +117,14 @@ internal static async Task Setup(NpgsqlConnector connector, NpgsqlTimeout timeou
117117 if ( ! BackendTypeCache . TryGetValue ( connector . ConnectionString , out var types ) )
118118 types = BackendTypeCache [ connector . ConnectionString ] = await LoadBackendTypes ( connector , timeout , async ) ;
119119
120- connector . TypeHandlerRegistry . _postgresTypes = types ;
120+ connector . TypeHandlerRegistry . PostgresTypes = types ;
121121 connector . TypeHandlerRegistry . ActivateGlobalMappings ( ) ;
122122 }
123123
124124 TypeHandlerRegistry ( NpgsqlConnector connector )
125125 {
126126 Connector = connector ;
127- _postgresTypes = EmptyPostgresTypes ;
127+ PostgresTypes = EmptyPostgresTypes ;
128128 UnrecognizedTypeHandler = new UnknownTypeHandler ( this ) ;
129129 ByOID = new Dictionary < uint , TypeHandler > ( ) ;
130130 ByDbType = new Dictionary < DbType , TypeHandler > ( ) ;
@@ -393,8 +393,8 @@ PostgresCompositeType GetCompositeType(string pgName)
393393 {
394394 // First check if the composite type definition has already been loaded from the database
395395 if ( pgName . IndexOf ( '.' ) == - 1
396- ? _postgresTypes . ByName . TryGetValue ( pgName , out var postgresType )
397- : _postgresTypes . ByFullName . TryGetValue ( pgName , out postgresType ) )
396+ ? PostgresTypes . ByName . TryGetValue ( pgName , out var postgresType )
397+ : PostgresTypes . ByFullName . TryGetValue ( pgName , out postgresType ) )
398398 {
399399 var asComposite = postgresType as PostgresCompositeType ;
400400 if ( asComposite == null )
@@ -449,7 +449,7 @@ PostgresCompositeType GetCompositeType(string pgName)
449449 fields . Add ( new RawCompositeField { PgName = reader . GetString ( 0 ) , TypeOID = reader . GetFieldValue < uint > ( 1 ) } ) ;
450450
451451 var compositeType = new PostgresCompositeType ( ns , name , oid , fields ) ;
452- compositeType . AddTo ( _postgresTypes ) ;
452+ compositeType . AddTo ( PostgresTypes ) ;
453453
454454 reader . NextResult ( ) ; // Load the array type
455455
@@ -459,7 +459,7 @@ PostgresCompositeType GetCompositeType(string pgName)
459459 var arrayName = reader . GetString ( 1 ) ;
460460 var arrayOID = reader . GetFieldValue < uint > ( 2 ) ;
461461
462- new PostgresArrayType ( arrayNs , arrayName , arrayOID , compositeType ) . AddTo ( _postgresTypes ) ;
462+ new PostgresArrayType ( arrayNs , arrayName , arrayOID , compositeType ) . AddTo ( PostgresTypes ) ;
463463 } else
464464 Log . Warn ( $ "Could not find array type corresponding to composite { pgName } ") ;
465465
@@ -487,7 +487,7 @@ internal bool TryGetByOID(uint oid, out TypeHandler handler)
487487 {
488488 if ( ByOID . TryGetValue ( oid , out handler ) )
489489 return true ;
490- if ( ! _postgresTypes . ByOID . TryGetValue ( oid , out var postgresType ) )
490+ if ( ! PostgresTypes . ByOID . TryGetValue ( oid , out var postgresType ) )
491491 return false ;
492492
493493 handler = postgresType . Activate ( this ) ;
@@ -525,7 +525,7 @@ internal bool TryGetByOID(uint oid, out TypeHandler handler)
525525 throw new InvalidCastException ( $ "When specifying NpgsqlDbType.{ nameof ( NpgsqlDbType . Enum ) } , { nameof ( NpgsqlParameter . SpecificType ) } must be specified as well") ;
526526
527527 // Base, range or array of base/range
528- if ( _postgresTypes . ByNpgsqlDbType . TryGetValue ( npgsqlDbType , out var postgresType ) )
528+ if ( PostgresTypes . ByNpgsqlDbType . TryGetValue ( npgsqlDbType , out var postgresType ) )
529529 return postgresType . Activate ( this ) ;
530530
531531 // We don't have a backend type for this NpgsqlDbType. This could be because it's not yet supported by
@@ -543,7 +543,7 @@ internal TypeHandler this[DbType dbType]
543543 {
544544 if ( ByDbType . TryGetValue ( dbType , out var handler ) )
545545 return handler ;
546- if ( _postgresTypes . ByDbType . TryGetValue ( dbType , out var postgresType ) )
546+ if ( PostgresTypes . ByDbType . TryGetValue ( dbType , out var postgresType ) )
547547 return postgresType . Activate ( this ) ;
548548 throw new NotSupportedException ( "This DbType is not supported in Npgsql: " + dbType ) ;
549549 }
@@ -582,7 +582,7 @@ internal TypeHandler this[Type type]
582582 return handler ;
583583
584584 // Try to find the backend type by a simple lookup on the given CLR type, this will handle base types.
585- if ( _postgresTypes . ByClrType . TryGetValue ( type , out var postgresType ) )
585+ if ( PostgresTypes . ByClrType . TryGetValue ( type , out var postgresType ) )
586586 return postgresType . Activate ( this ) ;
587587
588588 // Try to see if it is an array type
@@ -605,13 +605,13 @@ internal TypeHandler this[Type type]
605605 // Special check for byte[] - bytea not array of int2
606606 if ( type == typeof ( byte [ ] ) )
607607 {
608- if ( ! _postgresTypes . ByClrType . TryGetValue ( typeof ( byte [ ] ) , out var byteaPostgresType ) )
608+ if ( ! PostgresTypes . ByClrType . TryGetValue ( typeof ( byte [ ] ) , out var byteaPostgresType ) )
609609 throw new NpgsqlException ( "The PostgreSQL 'bytea' type is missing" ) ;
610610 return byteaPostgresType . Activate ( this ) ;
611611 }
612612
613613 // Get the elements backend type and activate its array backend type
614- if ( ! _postgresTypes . ByClrType . TryGetValue ( arrayElementType , out var elementPostgresType ) )
614+ if ( ! PostgresTypes . ByClrType . TryGetValue ( arrayElementType , out var elementPostgresType ) )
615615 {
616616 if ( arrayElementType . GetTypeInfo ( ) . IsEnum )
617617 throw new NotSupportedException ( $ "The CLR enum type { arrayElementType . Name } must be mapped with Npgsql before usage, please refer to the documentation.") ;
@@ -628,7 +628,7 @@ internal TypeHandler this[Type type]
628628 // Range type which hasn't yet been set up
629629 if ( type . GetTypeInfo ( ) . IsGenericType && type . GetGenericTypeDefinition ( ) == typeof ( NpgsqlRange < > ) )
630630 {
631- if ( ! _postgresTypes . ByClrType . TryGetValue ( type . GetGenericArguments ( ) [ 0 ] , out var subtypePostgresType ) ||
631+ if ( ! PostgresTypes . ByClrType . TryGetValue ( type . GetGenericArguments ( ) [ 0 ] , out var subtypePostgresType ) ||
632632 subtypePostgresType . Range == null )
633633 {
634634 throw new NpgsqlException ( $ "The .NET range type { type . Name } isn't supported in your PostgreSQL, use CREATE TYPE AS RANGE") ;
@@ -854,15 +854,15 @@ PostgresType GetBackendTypeByName(string pgName)
854854 if ( i == - 1 )
855855 {
856856 // No dot, this is a partial type name
857- if ( ! _postgresTypes . ByName . TryGetValue ( pgName , out postgresType ) )
857+ if ( ! PostgresTypes . ByName . TryGetValue ( pgName , out postgresType ) )
858858 throw new NpgsqlException ( $ "A PostgreSQL type with the name { pgName } was not found in the database") ;
859859 if ( postgresType == null )
860860 throw new NpgsqlException ( $ "More than one PostgreSQL type was found with the name { pgName } , please specify a full name including schema") ;
861861 return postgresType ;
862862 }
863863
864864 // Full type name with namespace
865- if ( ! _postgresTypes . ByFullName . TryGetValue ( pgName , out postgresType ) )
865+ if ( ! PostgresTypes . ByFullName . TryGetValue ( pgName , out postgresType ) )
866866 throw new Exception ( $ "A PostgreSQL type with the name { pgName } was not found in the database") ;
867867 return postgresType ;
868868 }
0 commit comments