forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmitCodeAttribute.cs
More file actions
74 lines (71 loc) · 3.06 KB
/
Copy pathEmitCodeAttribute.cs
File metadata and controls
74 lines (71 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
namespace ServiceStack
{
[Flags]
public enum Lang
{
CSharp = 1 << 0,
FSharp = 1 << 1,
Vb = 1 << 2,
TypeScript = 1 << 3,
Dart = 1 << 4,
Swift = 1 << 5,
Java = 1 << 6,
Kotlin = 1 << 7,
Python = 1 << 8,
Go = 1 << 9,
Php = 1 << 10,
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitCodeAttribute : AttributeBase
{
public Lang Lang { get; set; }
public string[] Statements { get; set; }
public EmitCodeAttribute(Lang lang, string statement) : this(lang, new[] {statement}) {}
public EmitCodeAttribute(Lang lang, string[] statements)
{
Lang = lang;
Statements = statements ?? throw new ArgumentNullException(nameof(Statements));
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitCSharp : EmitCodeAttribute
{
public EmitCSharp(params string[] statements) : base(Lang.CSharp, statements) { }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitFSharp : EmitCodeAttribute
{
public EmitFSharp(params string[] statements) : base(Lang.FSharp, statements) { }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitVb : EmitCodeAttribute
{
public EmitVb(params string[] statements) : base(Lang.Vb, statements) { }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitTypeScript : EmitCodeAttribute
{
public EmitTypeScript(params string[] statements) : base(Lang.TypeScript, statements) { }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitDart : EmitCodeAttribute
{
public EmitDart(params string[] statements) : base(Lang.Dart, statements) { }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitSwift : EmitCodeAttribute
{
public EmitSwift(params string[] statements) : base(Lang.Swift, statements) { }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitJava : EmitCodeAttribute
{
public EmitJava(params string[] statements) : base(Lang.Java, statements) { }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)]
public class EmitKotlin : EmitCodeAttribute
{
public EmitKotlin(params string[] statements) : base(Lang.Kotlin, statements) { }
}
}