@@ -465,44 +465,52 @@ private async Task PreviewGeneratedCode()
465
465
} )
466
466
. OrderBy ( x => x . FileName )
467
467
. ToList ( ) ) ;
468
- var operations = ModelMetadata . Operations . Select ( x =>
469
- {
470
- return
471
- $ """ [M2VMPropertyOrFieldOperationInfo(TargetTypeFQType = { x . TargetTypeTypeofInfo . Sample } , TargetMemberName = " { x . TargetMemberName } ", TargetOperation = { GetOperation ( x . TargetOperation ) } )] """ ;
472
-
473
- string GetOperation ( PropertyOrFieldOperationKind operationKind )
468
+ var count = 0 ;
469
+ var all = ModelMetadata . Replaces . Concat < M2VMPropertyOrFieldOperationBase > ( ModelMetadata . Operations )
470
+ . OrderBy ( x => x . TargetTypeFQType )
471
+ . ThenBy ( x => x . TargetMemberName )
472
+ . ThenByDescending ( x => x is M2VMPropertyOrFieldOperationInfo )
473
+ . Select ( x =>
474
474
{
475
- string [ ] str =
476
- [
477
- operationKind . HasFlag ( PropertyOrFieldOperationKind . IgnoreProperty )
478
- ? "PropertyOrFieldOperationKind.IgnoreProperty"
479
- : "" ,
480
- operationKind . HasFlag ( PropertyOrFieldOperationKind . DoNotReplaceTargetType )
481
- ? "PropertyOrFieldOperationKind.DoNotReplaceTargetType"
482
- : "" ,
483
- operationKind . HasFlag ( PropertyOrFieldOperationKind . IncludePropertyOrField )
484
- ? "PropertyOrFieldOperationKind.IncludePropertyOrField"
485
- : "" ,
486
- operationKind . HasFlag ( PropertyOrFieldOperationKind . TypeIsNotNullable )
487
- ? "PropertyOrFieldOperationKind.TypeIsNotNullable"
488
- : "" ,
489
- operationKind . HasFlag ( PropertyOrFieldOperationKind . TypeIsNullable )
490
- ? "PropertyOrFieldOperationKind.TypeIsNullable"
491
- : ""
492
- ] ;
493
- StringBuilder builder = new ( ) ;
494
- var distinct = str . Where ( y => ! string . IsNullOrEmpty ( y ) ) . ToList ( ) ;
495
- builder . Append ( distinct . FirstOrDefault ( ) ) ;
496
- foreach ( var item in distinct . Skip ( 1 ) ) builder . Append ( " | " + item ) ;
497
-
498
- return builder . ToString ( ) ;
499
- }
500
- } ) ;
501
- var replaces = ModelMetadata . Replaces . Select ( x =>
502
- $ """ [M2VMReplaceGenerationInfo(TargetTypeFQType = { x . TargetTypeTypeofInfo . Sample } , TargetMemberName = "{ x . TargetMemberName } ", ReplaceFQType = { x . ReplaceTypeTypeofInfo . Sample } )]""" ) ;
475
+ if ( x is M2VMPropertyOrFieldOperationInfo info )
476
+ {
477
+ return
478
+ $ """ [M2VMPropertyOrFieldOperationInfo(TargetTypeFQType = { info . TargetTypeTypeofInfo . Sample } , TargetMemberName = "{ info . TargetMemberName } ", TargetOperation = { GetOperation ( info . TargetOperation ) } )]""" ;
479
+
480
+ string GetOperation ( PropertyOrFieldOperationKind operationKind )
481
+ {
482
+ string [ ] str =
483
+ [
484
+ operationKind . HasFlag ( PropertyOrFieldOperationKind . IgnoreProperty )
485
+ ? "PropertyOrFieldOperationKind.IgnoreProperty"
486
+ : "" ,
487
+ operationKind . HasFlag ( PropertyOrFieldOperationKind . DoNotReplaceTargetType )
488
+ ? "PropertyOrFieldOperationKind.DoNotReplaceTargetType"
489
+ : "" ,
490
+ operationKind . HasFlag ( PropertyOrFieldOperationKind . IncludePropertyOrField )
491
+ ? "PropertyOrFieldOperationKind.IncludePropertyOrField"
492
+ : "" ,
493
+ operationKind . HasFlag ( PropertyOrFieldOperationKind . TypeIsNotNullable )
494
+ ? "PropertyOrFieldOperationKind.TypeIsNotNullable"
495
+ : "" ,
496
+ operationKind . HasFlag ( PropertyOrFieldOperationKind . TypeIsNullable )
497
+ ? "PropertyOrFieldOperationKind.TypeIsNullable"
498
+ : ""
499
+ ] ;
500
+ StringBuilder builder = new ( ) ;
501
+ var distinct = str . Where ( y => ! string . IsNullOrEmpty ( y ) ) . ToList ( ) ;
502
+ builder . Append ( distinct . FirstOrDefault ( ) ) ;
503
+ foreach ( var item in distinct . Skip ( 1 ) ) builder . Append ( " | " + item ) ;
504
+
505
+ return builder . ToString ( ) ;
506
+ }
507
+ }
508
+
509
+ return
510
+ $ """ [M2VMReplaceGenerationInfo(TargetTypeFQType = { x . TargetTypeTypeofInfo . Sample } , TargetMemberName = "{ x . TargetMemberName } ", ReplaceFQType = { ( x as M2VMReplaceGenerationInfo ) ! . ReplaceTypeTypeofInfo . Sample } )]""" ;
511
+ } ) ;
503
512
var rootCode = await Task . Run ( ( ) => $ """
504
- { string . Join ( "\n " , operations ) }
505
- { string . Join ( "\n " , replaces ) }
513
+ { string . Join ( "\n " , all ) }
506
514
public partial class { ModelMetadata . ClassName } ;
507
515
""" ) ;
508
516
SummaryGeneratedBorderMdDocument = await Task . Run ( ( ) => Markdown . Parse (
@@ -567,7 +575,7 @@ private void ConfirmBatchModify()
567
575
[ ReactiveCommand ]
568
576
private void CancelCurrentSelection ( )
569
577
{
570
- foreach ( var metadataTdgItemViewModel in _selection )
578
+ foreach ( var metadataTdgItemViewModel in _selection . ToList ( ) )
571
579
metadataTdgItemViewModel . IsSelected = false ;
572
580
}
573
581
0 commit comments