@@ -147,104 +147,104 @@ RecordDeclarationSyntax foreignKeyDto
147147 result . AddProperty ( $ "_{ repo . Item2 } ") . SetType ( repo . Item1 ) . WithReadonlyValue ( ) ;
148148 }
149149
150- if ( foreignRepos . Any ( ) )
150+ //if (foreignRepos.Any())
151+ //{
152+ //Generate GetFull methode
151153 {
152- //Generate GetFull methode
153- {
154- var getMethode = baseRepo . GetMethodsWithAttributes < GetAttribute > ( repos ) . First ( ) ;
155- var getMethodeFull = baseManager
156- . GetMethodsWithAttributes < GetFullAttribute > ( managers )
157- . First ( ) ;
158- result
159- . AddMethod ( ApiUrls . GetFull , Accessibility . Public )
160- . Override ( )
161- . WithReturnTypeTask ( "object" )
162- . MakeAsync ( )
163- . AddParameter (
164- "Guid" ,
165- $ "{ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } "
166- )
167- . WithBody ( x =>
154+ var getMethode = baseRepo . GetMethodsWithAttributes < GetAttribute > ( repos ) . First ( ) ;
155+ var getMethodeFull = baseManager
156+ . GetMethodsWithAttributes < GetFullAttribute > ( managers )
157+ . First ( ) ;
158+ result
159+ . AddMethod ( ApiUrls . GetFull , Accessibility . Public )
160+ . Override ( )
161+ . WithReturnTypeTask ( "object" )
162+ . MakeAsync ( )
163+ . AddParameter (
164+ "Guid" ,
165+ $ "{ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } "
166+ )
167+ . WithBody ( x =>
168+ {
169+ x . AppendLine (
170+ $ "{ dto . GetFullModelName ( ) } { dto . GetFullModelName ( ) } = new ();"
171+ ) ;
172+ x . AppendLine (
173+ $ "var { dto . GetName ( ) . GetParameterName ( ) } = await { getMethode . GetName ( ) } ({ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } );"
174+ ) ;
175+ x . AppendLine (
176+ $ "{ dto . GetFullModelName ( ) } .{ dto . GetName ( ) . GetParameterName ( ) } = { dto . GetName ( ) . GetParameterName ( ) } ;"
177+ ) ;
178+ foreach ( var repo in foreignRepos )
168179 {
169- x . AppendLine (
170- $ "{ dto . GetFullModelName ( ) } { dto . GetFullModelName ( ) } = new ();"
171- ) ;
172- x . AppendLine (
173- $ "var { dto . GetName ( ) . GetParameterName ( ) } = await { getMethode . GetName ( ) } ({ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } );"
174- ) ;
175- x . AppendLine (
176- $ "{ dto . GetFullModelName ( ) } .{ dto . GetName ( ) . GetParameterName ( ) } = { dto . GetName ( ) . GetParameterName ( ) } ;"
177- ) ;
178- foreach ( var repo in foreignRepos )
180+ bool isNull = repo . propertySymbol . GetPropertyType ( ) . Contains ( "?" ) ;
181+ string managerParametervalue = isNull
182+ ? repo . propertySymbol . GetPropertyName ( ) + ".Value"
183+ : repo . propertySymbol . GetPropertyName ( ) ;
184+ string returnLine =
185+ $ "{ dto . GetFullModelName ( ) } .{ repo . propertySymbol . GetFullModelNameFromProperty ( ) } = ({ repo . foreignKeyDto . GetFullModelName ( ) } )await _{ repo . repoName } .{ getMethodeFull . GetName ( ) } ({ dto . GetName ( ) . GetParameterName ( ) } .{ managerParametervalue } );";
186+ if ( isNull )
179187 {
180- bool isNull = repo . propertySymbol . GetPropertyType ( ) . Contains ( "?" ) ;
181- string managerParametervalue = isNull
182- ? repo . propertySymbol . GetPropertyName ( ) + ".Value"
183- : repo . propertySymbol . GetPropertyName ( ) ;
184- string returnLine =
185- $ "{ dto . GetFullModelName ( ) } .{ repo . propertySymbol . GetFullModelNameFromProperty ( ) } = ({ repo . foreignKeyDto . GetFullModelName ( ) } )await _{ repo . repoName } .{ getMethodeFull . GetName ( ) } ({ dto . GetName ( ) . GetParameterName ( ) } .{ managerParametervalue } );";
186- if ( isNull )
187- {
188- x . If (
189- $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } .HasValue"
190- )
191- . WithBody ( x =>
192- {
193- x . AppendLine ( returnLine ) ;
194- } )
195- . EndIf ( ) ;
196- }
197- else
198- {
199- x . If (
200- $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } != default"
201- )
202- . WithBody ( x =>
203- {
204- x . AppendLine ( returnLine ) ;
205- } )
206- . EndIf ( ) ;
207- }
188+ x . If (
189+ $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } .HasValue"
190+ )
191+ . WithBody ( x =>
192+ {
193+ x . AppendLine ( returnLine ) ;
194+ } )
195+ . EndIf ( ) ;
208196 }
197+ else
198+ {
199+ x . If (
200+ $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } != default"
201+ )
202+ . WithBody ( x =>
203+ {
204+ x . AppendLine ( returnLine ) ;
205+ } )
206+ . EndIf ( ) ;
207+ }
208+ }
209209
210- x . AppendLine ( $ "return { dto . GetFullModelName ( ) } ;") ;
211- } )
212- . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
213- }
210+ x . AppendLine ( $ "return { dto . GetFullModelName ( ) } ;") ;
211+ } )
212+ . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
213+ }
214214
215- {
216- string returnName = dto . GetFullModelName ( ) . GetParameterName ( ) + "s" ;
217- //Generate GetAllFull methode
218- var getAllMethode = baseRepo
219- . GetMethodsWithAttributes < GetAllAttribute > ( repos )
220- . First ( ) ;
221- result
222- . AddMethod ( ApiUrls . GetAllFull , Accessibility . Public )
223- . Override ( )
224- . WithReturnTypeTaskList ( "object" )
225- . MakeAsync ( )
226- . WithBody ( x =>
227- {
228- x . AppendLine ( $ "List<object> { returnName } = new ();") ;
229- x . AppendLine (
230- $ "var { dto . GetName ( ) . GetParameterName ( ) } s = await { getAllMethode . GetName ( ) } ();"
231- ) ;
232- x . ForEach (
233- $ "var { dto . GetName ( ) . GetParameterName ( ) } ",
234- $ "{ dto . GetName ( ) . GetParameterName ( ) } s"
235- )
236- . WithBody ( x =>
237- {
238- x . AppendLine (
239- $ "{ returnName } .Add(await { ApiUrls . GetFull } ({ dto . GetName ( ) . GetParameterName ( ) } .{ dto . GetIdPropertyMethodeName ( baseDtos ) } ));"
240- ) ;
241- } ) ;
215+ {
216+ string returnName = dto . GetFullModelName ( ) . GetParameterName ( ) + "s" ;
217+ //Generate GetAllFull methode
218+ var getAllMethode = baseRepo
219+ . GetMethodsWithAttributes < GetAllAttribute > ( repos )
220+ . First ( ) ;
221+ result
222+ . AddMethod ( ApiUrls . GetAllFull , Accessibility . Public )
223+ . Override ( )
224+ . WithReturnTypeTaskList ( "object" )
225+ . MakeAsync ( )
226+ . WithBody ( x =>
227+ {
228+ x . AppendLine ( $ "List<object> { returnName } = new ();") ;
229+ x . AppendLine (
230+ $ "var { dto . GetName ( ) . GetParameterName ( ) } s = await { getAllMethode . GetName ( ) } ();"
231+ ) ;
232+ x . ForEach (
233+ $ "var { dto . GetName ( ) . GetParameterName ( ) } ",
234+ $ "{ dto . GetName ( ) . GetParameterName ( ) } s"
235+ )
236+ . WithBody ( x =>
237+ {
238+ x . AppendLine (
239+ $ "{ returnName } .Add(await { ApiUrls . GetFull } ({ dto . GetName ( ) . GetParameterName ( ) } .{ dto . GetIdPropertyMethodeName ( baseDtos ) } ));"
240+ ) ;
241+ } ) ;
242242
243- x . AppendLine ( $ "return { returnName } ;") ;
244- } )
245- . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
246- }
243+ x . AppendLine ( $ "return { returnName } ;") ;
244+ } )
245+ . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
247246 }
247+ //}
248248
249249 //Add abstract methods
250250 result
0 commit comments