@@ -49,6 +49,7 @@ private static void GenerateRelayCommandWithOutParameterValues(
49
49
rc . CommandName ,
50
50
rc . MethodName ,
51
51
rc . CanExecuteName ,
52
+ rc . InvertCanExecute ,
52
53
rc . UsePropertyForCanExecute ) ;
53
54
builder . AppendLine ( cmd ) ;
54
55
}
@@ -64,6 +65,7 @@ private static void GenerateRelayCommandWithOutParameterValues(
64
65
rc . CommandName ,
65
66
$ "{ rc . MethodName } (CancellationToken.None)",
66
67
rc . CanExecuteName ,
68
+ rc . InvertCanExecute ,
67
69
isLambda : true ) ;
68
70
builder . AppendLine ( cmd ) ;
69
71
}
@@ -76,6 +78,7 @@ private static void GenerateRelayCommandWithOutParameterValues(
76
78
rc . CommandName ,
77
79
rc . MethodName ,
78
80
rc . CanExecuteName ,
81
+ rc . InvertCanExecute ,
79
82
rc . UsePropertyForCanExecute ) ;
80
83
builder . AppendLine ( cmd ) ;
81
84
}
@@ -90,7 +93,7 @@ private static void GenerateRelayCommandWithOutParameterValues(
90
93
$ "{ implementationType } { tupleGeneric } ",
91
94
rc . CommandName ,
92
95
$ "x => { rc . MethodName } ({ constructorParametersMulti } )",
93
- rc . CanExecuteName is null ? null : $ "x => { rc . CanExecuteName } ") ;
96
+ rc . CanExecuteName is null ? null : rc . InvertCanExecute ? $ "x => ! { rc . CanExecuteName } " : $ "x => { rc . CanExecuteName } ") ;
94
97
builder . AppendLine ( cmd ) ;
95
98
}
96
99
else
@@ -100,7 +103,7 @@ private static void GenerateRelayCommandWithOutParameterValues(
100
103
$ "{ implementationType } { tupleGeneric } ",
101
104
rc . CommandName ,
102
105
$ "x => { rc . MethodName } ({ constructorParametersMulti } )",
103
- rc . CanExecuteName is null ? null : $ "x => { rc . CanExecuteName } ({ filteredConstructorParameters } )") ;
106
+ rc . CanExecuteName is null ? null : rc . InvertCanExecute ? $ "x => ! { rc . CanExecuteName } ( { filteredConstructorParameters } )" : $ "x => { rc . CanExecuteName } ({ filteredConstructorParameters } )") ;
104
107
builder . AppendLine ( cmd ) ;
105
108
}
106
109
}
@@ -143,7 +146,7 @@ private static void GenerateRelayCommandWithParameterValues(
143
146
implementationType ,
144
147
rc . CommandName ,
145
148
$ "() => { rc . MethodName } ({ constructorParameters } )",
146
- $ "{ rc . CanExecuteName } ") ;
149
+ rc . InvertCanExecute ? $ "! { rc . CanExecuteName } " : $ "{ rc . CanExecuteName } ") ;
147
150
builder . AppendLine ( cmd ) ;
148
151
}
149
152
else
@@ -153,7 +156,7 @@ private static void GenerateRelayCommandWithParameterValues(
153
156
implementationType ,
154
157
rc . CommandName ,
155
158
$ "() => { rc . MethodName } ({ constructorParameters } )",
156
- $ "{ rc . CanExecuteName } ({ constructorParameters } )") ;
159
+ rc . InvertCanExecute ? $ "! { rc . CanExecuteName } ( { constructorParameters } )" : $ "{ rc . CanExecuteName } ({ constructorParameters } )") ;
157
160
builder . AppendLine ( cmd ) ;
158
161
}
159
162
}
@@ -197,6 +200,7 @@ private static string GenerateCommandLine(
197
200
string commandName ,
198
201
string constructorParameters ,
199
202
string ? canExecuteName = null ,
203
+ bool invertCanExecute = false ,
200
204
bool usePropertyForCanExecute = false ,
201
205
bool isLambda = false )
202
206
{
@@ -209,16 +213,22 @@ private static string GenerateCommandLine(
209
213
{
210
214
if ( interfaceType . Contains ( '<' ) )
211
215
{
212
- commandInstance += $ ", _ => { canExecuteName } ";
216
+ commandInstance += invertCanExecute
217
+ ? $ ", _ => !{ canExecuteName } "
218
+ : $ ", _ => { canExecuteName } ";
213
219
}
214
220
else
215
221
{
216
- commandInstance += $ ", () => { canExecuteName } ";
222
+ commandInstance += invertCanExecute
223
+ ? $ ", () => !{ canExecuteName } "
224
+ : $ ", () => { canExecuteName } ";
217
225
}
218
226
}
219
227
else
220
228
{
221
- commandInstance += $ ", { canExecuteName } ";
229
+ commandInstance += invertCanExecute
230
+ ? $ ", !{ canExecuteName } "
231
+ : $ ", { canExecuteName } ";
222
232
}
223
233
}
224
234
0 commit comments