@@ -45,12 +45,13 @@ For example:
45
45
``` csharp
46
46
47
47
/// <summary >
48
- /// Provides extension methods for operations related to the UserTypeTest enumeration.
49
- /// </summary >
48
+ /// Provides extension methods for operations related to the <see cref =" global::UnitTests.UserTypeTest" /> enumeration.
49
+ /// </summary >
50
+ [GeneratedCodeAttribute (" Supernova.Enum.Generators" , null )]
50
51
public static class UserTypeTestEnumExtensions
51
52
{
52
53
/// <summary >
53
- /// Provides a dictionary that maps <see cref =" UserTypeTest" /> values to their corresponding display names.
54
+ /// Provides a dictionary that maps <see cref =" global::UnitTests. UserTypeTest" /> values to their corresponding display names.
54
55
/// </summary >
55
56
public static readonly ImmutableDictionary <UnitTests .UserTypeTest , string > DisplayNamesDictionary = new Dictionary <UnitTests .UserTypeTest , string >
56
57
{
@@ -61,7 +62,7 @@ For example:
61
62
}.ToImmutableDictionary ();
62
63
63
64
/// <summary >
64
- /// Provides a dictionary that maps <see cref =" UserTypeTest" /> values to their corresponding descriptions.
65
+ /// Provides a dictionary that maps <see cref =" global::UnitTests. UserTypeTest" /> values to their corresponding descriptions.
65
66
/// </summary >
66
67
public static readonly ImmutableDictionary <UnitTests .UserTypeTest , string > DisplayDescriptionsDictionary = new Dictionary <UnitTests .UserTypeTest , string >
67
68
{
@@ -72,11 +73,11 @@ For example:
72
73
}.ToImmutableDictionary ();
73
74
74
75
/// <summary >
75
- /// Converts the <see cref =" UserTypeTest" /> enumeration value to its string representation.
76
+ /// Converts the <see cref =" global::UnitTests. UserTypeTest" /> enumeration value to its string representation.
76
77
/// </summary >
77
- /// <param name =" states" >The <see cref =" UserTypeTest" /> enumeration value.</param >
78
+ /// <param name =" states" >The <see cref =" global::UnitTests. UserTypeTest" /> enumeration value.</param >
78
79
/// <param name =" defaultValue" >The default value to return if the enumeration value is not recognized.</param >
79
- /// <returns >The string representation of the <see cref =" UserTypeTest" /> value.</returns >
80
+ /// <returns >The string representation of the <see cref =" global::UnitTests. UserTypeTest" /> value.</returns >
80
81
public static string ToStringFast (this UnitTests .UserTypeTest states , string defaultValue = null )
81
82
{
82
83
return states switch
@@ -89,10 +90,10 @@ For example:
89
90
}
90
91
91
92
/// <summary >
92
- /// Checks if the specified <see cref =" UserTypeTest" /> value is defined.
93
+ /// Checks if the specified <see cref =" global::UnitTests. UserTypeTest" /> value is defined.
93
94
/// </summary >
94
- /// <param name =" states" >The <see cref =" UserTypeTest" /> value to check.</param >
95
- /// <returns >True if the <see cref =" UserTypeTest" /> value is defined; otherwise, false.</returns >
95
+ /// <param name =" states" >The <see cref =" global::UnitTests. UserTypeTest" /> value to check.</param >
96
+ /// <returns >True if the <see cref =" global::UnitTests. UserTypeTest" /> value is defined; otherwise, false.</returns >
96
97
public static bool IsDefinedFast (UnitTests.UserTypeTest states )
97
98
{
98
99
return states switch
@@ -105,10 +106,10 @@ For example:
105
106
}
106
107
107
108
/// <summary >
108
- /// Checks if the specified string represents a defined <see cref =" UserTypeTest" /> value.
109
+ /// Checks if the specified string represents a defined <see cref =" global::UnitTests. UserTypeTest" /> value.
109
110
/// </summary >
110
- /// <param name =" states" >The string representing a <see cref =" UserTypeTest" /> value.</param >
111
- /// <returns >True if the string represents a defined <see cref =" UserTypeTest" /> value; otherwise, false.</returns >
111
+ /// <param name =" states" >The string representing a <see cref =" global::UnitTests. UserTypeTest" /> value.</param >
112
+ /// <returns >True if the string represents a defined <see cref =" global::UnitTests. UserTypeTest" /> value; otherwise, false.</returns >
112
113
public static bool IsDefinedFast (string states )
113
114
{
114
115
return states switch
@@ -121,11 +122,11 @@ For example:
121
122
}
122
123
123
124
/// <summary >
124
- /// Converts the <see cref =" UserTypeTest" /> enumeration value to its display string.
125
+ /// Converts the <see cref =" global::UnitTests. UserTypeTest" /> enumeration value to its display string.
125
126
/// </summary >
126
- /// <param name =" states" >The <see cref =" UserTypeTest" /> enumeration value.</param >
127
+ /// <param name =" states" >The <see cref =" global::UnitTests. UserTypeTest" /> enumeration value.</param >
127
128
/// <param name =" defaultValue" >The default value to return if the enumeration value is not recognized.</param >
128
- /// <returns >The display string of the <see cref =" UserTypeTest" /> value.</returns >
129
+ /// <returns >The display string of the <see cref =" global::UnitTests. UserTypeTest" /> value.</returns >
129
130
public static string ToDisplayFast (this UnitTests .UserTypeTest states , string defaultValue = null )
130
131
{
131
132
return states switch
@@ -138,11 +139,11 @@ For example:
138
139
}
139
140
140
141
/// <summary >
141
- /// Gets the description of the <see cref =" UserTypeTest" /> enumeration value.
142
+ /// Gets the description of the <see cref =" global::UnitTests. UserTypeTest" /> enumeration value.
142
143
/// </summary >
143
- /// <param name =" states" >The <see cref =" UserTypeTest" /> enumeration value.</param >
144
+ /// <param name =" states" >The <see cref =" global::UnitTests. UserTypeTest" /> enumeration value.</param >
144
145
/// <param name =" defaultValue" >The default value to return if the enumeration value is not recognized.</param >
145
- /// <returns >The description of the <see cref =" UserTypeTest" /> value.</returns >
146
+ /// <returns >The description of the <see cref =" global::UnitTests. UserTypeTest" /> value.</returns >
146
147
public static string ToDescriptionFast (this UnitTests .UserTypeTest states , string defaultValue = null )
147
148
{
148
149
return states switch
@@ -155,9 +156,9 @@ For example:
155
156
}
156
157
157
158
/// <summary >
158
- /// Retrieves an array of all <see cref =" UserTypeTest" /> enumeration values.
159
+ /// Retrieves an array of all <see cref =" global::UnitTests. UserTypeTest" /> enumeration values.
159
160
/// </summary >
160
- /// <returns >An array containing all <see cref =" UserTypeTest" /> enumeration values.</returns >
161
+ /// <returns >An array containing all <see cref =" global::UnitTests. UserTypeTest" /> enumeration values.</returns >
161
162
public static UnitTests .UserTypeTest [] GetValuesFast ()
162
163
{
163
164
return new []
@@ -169,9 +170,9 @@ For example:
169
170
}
170
171
171
172
/// <summary >
172
- /// Retrieves an array of strings containing the names of all <see cref =" UserTypeTest" /> enumeration values.
173
+ /// Retrieves an array of strings containing the names of all <see cref =" global::UnitTests. UserTypeTest" /> enumeration values.
173
174
/// </summary >
174
- /// <returns >An array of strings containing the names of all <see cref =" UserTypeTest" /> enumeration values.</returns >
175
+ /// <returns >An array of strings containing the names of all <see cref =" global::UnitTests. UserTypeTest" /> enumeration values.</returns >
175
176
public static string [] GetNamesFast ()
176
177
{
177
178
return new []
@@ -183,14 +184,46 @@ For example:
183
184
}
184
185
185
186
/// <summary >
186
- /// Gets the length of the <see cref =" UserTypeTest" /> enumeration.
187
+ /// Gets the length of the <see cref =" global::UnitTests. UserTypeTest" /> enumeration.
187
188
/// </summary >
188
- /// <returns >The length of the <see cref =" UserTypeTest" /> enumeration.</returns >
189
+ /// <returns >The length of the <see cref =" global::UnitTests. UserTypeTest" /> enumeration.</returns >
189
190
public static int GetLengthFast ()
190
191
{
191
192
return 3 ;
192
193
193
194
}
195
+
196
+ /// <summary >
197
+ /// Try parse a string to <see cref =" global::UnitTests.UserTypeTest" /> value.
198
+ /// </summary >
199
+ /// <param name =" states" >The string representing a <see cref =" global::UnitTests.UserTypeTest" /> value.</param >
200
+ /// <param name =" result" >The enum <see cref =" global::UnitTests.UserTypeTest" /> parse result.</param >
201
+ /// <returns >True if the string is parsed successfully; otherwise, false.</returns >
202
+ public static bool TryParseFast (string states , out UnitTests .UserTypeTest result )
203
+ {
204
+ switch (states )
205
+ {
206
+ case " Men" :
207
+ {
208
+ result = UnitTests .UserTypeTest .Men ;
209
+ return true ;
210
+ }
211
+ case " Women" :
212
+ {
213
+ result = UnitTests .UserTypeTest .Women ;
214
+ return true ;
215
+ }
216
+ case " None" :
217
+ {
218
+ result = UnitTests .UserTypeTest .None ;
219
+ return true ;
220
+ }
221
+ default : {
222
+ result = default ;
223
+ return false ;
224
+ }
225
+ }
226
+ }
194
227
}
195
228
```
196
229
@@ -211,6 +244,9 @@ var names = UserTypeTestEnumExtensions.GetNamesFast(); //string[]
211
244
var values = UserTypeTestEnumExtensions .GetValuesFast (); // UserType[]
212
245
213
246
var length = UserTypeTestEnumExtensions .GetLengthFast (); // 3
247
+
248
+ var menString = " Men" ;
249
+ var result = UserTypeTestEnumExtensions .TryParseFast (menString , out var enumValue );
214
250
```
215
251
216
252
If you had trouble using UserTypeTestEnumExtensions and the IDE did not recognize it. This is an IDE problem and you need to restart the IDE once.
0 commit comments