|
1 | 1 | using System; |
2 | 2 |
|
3 | 3 |
|
4 | | -namespace CSharpToJavaScript.Utils |
| 4 | +namespace CSharpToJavaScript.Utils; |
| 5 | + |
| 6 | +[AttributeUsage(AttributeTargets.Class)] |
| 7 | +internal class IgnoreAttribute : Attribute |
| 8 | +{ |
| 9 | + public IgnoreAttribute() { } |
| 10 | +} |
| 11 | +[AttributeUsage(AttributeTargets.All)] |
| 12 | +public class ValueAttribute : Attribute |
5 | 13 | { |
6 | | - [AttributeUsage(AttributeTargets.Class)] |
7 | | - internal class IgnoreAttribute : Attribute |
| 14 | + public string Value { get; init; } |
| 15 | + public ValueAttribute(string value) |
8 | 16 | { |
9 | | - public IgnoreAttribute() { } |
| 17 | + Value = value; |
10 | 18 | } |
11 | | - [AttributeUsage(AttributeTargets.All)] |
12 | | - public class ValueAttribute : Attribute |
| 19 | +} |
| 20 | +[AttributeUsage(AttributeTargets.All)] |
| 21 | +public class EnumValueAttribute : Attribute |
| 22 | +{ |
| 23 | + public string Value { get; init; } |
| 24 | + public EnumValueAttribute(string value) |
13 | 25 | { |
14 | | - public string Value { get; init; } |
15 | | - public ValueAttribute(string value) |
16 | | - { |
17 | | - Value = value; |
18 | | - } |
| 26 | + Value = value; |
19 | 27 | } |
20 | | - [AttributeUsage(AttributeTargets.All)] |
21 | | - public class EnumValueAttribute : Attribute |
| 28 | +} |
| 29 | + |
| 30 | +[AttributeUsage(AttributeTargets.All)] |
| 31 | +public class ToAttribute : Attribute |
| 32 | +{ |
| 33 | + public const string None = "None"; |
| 34 | + public const string Default = "Default"; |
| 35 | + public const string ToLower = "ToLower"; |
| 36 | + public const string FirstCharToLowerCase = "FirstCharToLowerCase"; |
| 37 | + |
| 38 | + public string To { get; set; } = string.Empty; |
| 39 | + public ToAttribute(string to) |
22 | 40 | { |
23 | | - public string Value { get; init; } |
24 | | - public EnumValueAttribute(string value) |
25 | | - { |
26 | | - Value = value; |
27 | | - } |
| 41 | + To = to; |
28 | 42 | } |
29 | 43 |
|
30 | | - [AttributeUsage(AttributeTargets.All)] |
31 | | - public class ToAttribute : Attribute |
| 44 | + public string Convert(string str) |
32 | 45 | { |
33 | | - public const string None = "None"; |
34 | | - public const string Default = "Default"; |
35 | | - public const string ToLower = "ToLower"; |
36 | | - public const string FirstCharToLowerCase = "FirstCharToLowerCase"; |
37 | | - |
38 | | - public string To { get; set; } = string.Empty; |
39 | | - public ToAttribute(string to) |
| 46 | + switch (To) |
40 | 47 | { |
41 | | - To = to; |
42 | | - } |
43 | | - |
44 | | - public string Convert(string str) |
45 | | - { |
46 | | - switch (To) |
47 | | - { |
48 | | - case ToLower: |
49 | | - return str.ToLower(); |
50 | | - case FirstCharToLowerCase: |
51 | | - return str.FirstCharToLowerCase(); |
52 | | - case None: |
53 | | - return ""; |
54 | | - case Default: |
55 | | - default: |
56 | | - return str; |
57 | | - } |
| 48 | + case ToLower: |
| 49 | + return str.ToLower(); |
| 50 | + case FirstCharToLowerCase: |
| 51 | + return str.FirstCharToLowerCase(); |
| 52 | + case None: |
| 53 | + return ""; |
| 54 | + case Default: |
| 55 | + default: |
| 56 | + return str; |
58 | 57 | } |
59 | 58 | } |
60 | 59 | } |
| 60 | + |
0 commit comments