33public class InstantAPIsBuilder < D > where D : DbContext
44{
55
6- private HashSet < WebApplicationExtensions . TypeTable > _Config = new ( ) ;
6+ private HashSet < InstantAPIsOptions . Table > _Config = new ( ) ;
77 private Type _ContextType = typeof ( D ) ;
88 private D _TheContext ;
9- private readonly HashSet < TableApiMapping > _IncludedTables = new ( ) ;
9+ private readonly HashSet < InstantAPIsOptions . Table > _IncludedTables = new ( ) ;
1010 private readonly List < string > _ExcludedTables = new ( ) ;
1111 private const string DEFAULT_URI = "/api/" ;
1212
@@ -43,13 +43,13 @@ public InstantAPIsBuilder<D> IncludeTable<T>(Func<D, DbSet<T>> entitySelector, A
4343 }
4444 else
4545 {
46- baseUrl = String . Concat ( DEFAULT_URI , property . Name ) ;
46+ baseUrl = string . Concat ( DEFAULT_URI , property . Name ) ;
4747 }
4848
49- var tableApiMapping = new TableApiMapping ( property . Name , methodsToGenerate , baseUrl ) ;
49+ var tableApiMapping = new InstantAPIsOptions . Table ( property . Name , new Uri ( baseUrl ) , typeof ( T ) ) { ApiMethodsToGenerate = methodsToGenerate } ;
5050 _IncludedTables . Add ( tableApiMapping ) ;
5151
52- if ( _ExcludedTables . Contains ( tableApiMapping . TableName ) ) _ExcludedTables . Remove ( tableApiMapping . TableName ) ;
52+ if ( _ExcludedTables . Contains ( tableApiMapping . Name ) ) _ExcludedTables . Remove ( tableApiMapping . Name ) ;
5353 _IncludedTables . Add ( tableApiMapping ) ;
5454
5555 return this ;
@@ -67,7 +67,7 @@ public InstantAPIsBuilder<D> ExcludeTable<T>(Func<D, DbSet<T>> entitySelector) w
6767 var theSetType = entitySelector ( _TheContext ) . GetType ( ) . BaseType ;
6868 var property = _ContextType . GetProperties ( ) . First ( p => p . PropertyType == theSetType ) ;
6969
70- if ( _IncludedTables . Select ( t => t . TableName ) . Contains ( property . Name ) ) _IncludedTables . Remove ( _IncludedTables . First ( t => t . TableName == property . Name ) ) ;
70+ if ( _IncludedTables . Select ( t => t . Name ) . Contains ( property . Name ) ) _IncludedTables . Remove ( _IncludedTables . First ( t => t . Name == property . Name ) ) ;
7171 _ExcludedTables . Add ( property . Name ) ;
7272
7373 return this ;
@@ -78,26 +78,18 @@ private void BuildTables()
7878 {
7979
8080 var tables = WebApplicationExtensions . GetDbTablesForContext < D > ( ) . ToArray ( ) ;
81- WebApplicationExtensions . TypeTable [ ] ? outTables ;
81+ InstantAPIsOptions . Table [ ] ? outTables ;
8282
8383 // Add the Included tables
8484 if ( _IncludedTables . Any ( ) )
8585 {
86- outTables = tables . Where ( t => _IncludedTables . Any ( i => i . TableName . Equals ( t . Name , StringComparison . InvariantCultureIgnoreCase ) ) )
87- . Select ( t => new WebApplicationExtensions . TypeTable
86+ outTables = tables . Where ( t => _IncludedTables . Any ( i => i . Name . Equals ( t . Name , StringComparison . InvariantCultureIgnoreCase ) ) )
87+ . Select ( t => new InstantAPIsOptions . Table ( t . Name , new Uri ( _IncludedTables . First ( i => i . Name . Equals ( t . Name , StringComparison . InvariantCultureIgnoreCase ) ) . BaseUrl . ToString ( ) , UriKind . Relative ) , t . InstanceType )
8888 {
89- Name = t . Name ,
90- InstanceType = t . InstanceType ,
91- ApiMethodsToGenerate = _IncludedTables . First ( i => i . TableName . Equals ( t . Name , StringComparison . InvariantCultureIgnoreCase ) ) . MethodsToGenerate ,
92- BaseUrl = new Uri ( _IncludedTables . First ( i => i . TableName . Equals ( t . Name , StringComparison . InvariantCultureIgnoreCase ) ) . BaseUrl , UriKind . Relative )
89+ ApiMethodsToGenerate = _IncludedTables . First ( i => i . Name . Equals ( t . Name , StringComparison . InvariantCultureIgnoreCase ) ) . ApiMethodsToGenerate
9390 } ) . ToArray ( ) ;
9491 } else {
95- outTables = tables . Select ( t => new WebApplicationExtensions . TypeTable
96- {
97- Name = t . Name ,
98- InstanceType = t . InstanceType ,
99- BaseUrl = new Uri ( DEFAULT_URI + t . Name , uriKind : UriKind . Relative )
100- } ) . ToArray ( ) ;
92+ outTables = tables . Select ( t => new InstantAPIsOptions . Table ( t . Name , new Uri ( DEFAULT_URI + t . Name , uriKind : UriKind . Relative ) , t . InstanceType ) ) . ToArray ( ) ;
10193 }
10294
10395 // Exit now if no tables were excluded
@@ -118,7 +110,7 @@ private void BuildTables()
118110
119111#endregion
120112
121- internal HashSet < WebApplicationExtensions . TypeTable > Build ( )
113+ internal HashSet < InstantAPIsOptions . Table > Build ( )
122114 {
123115
124116 BuildTables ( ) ;
0 commit comments