blob: d0ef6353f4a8f57d67a6d4fd5ddc0861ec6cdd32 (
plain)
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
75
76
77
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
using System;
using System.Reflection;
using System.Collections;
using System.Runtime.CompilerServices;
[assembly: SingleAttribute<int>()]
[assembly: SingleAttribute<bool>()]
[assembly: MultiAttribute<int>()]
[assembly: MultiAttribute<int>(1)]
[assembly: MultiAttribute<int>(Value = 2)]
[assembly: MultiAttribute<bool>()]
[assembly: MultiAttribute<bool>(true)]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false)]
public class SingleAttribute<T> : Attribute
{
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true)]
public class MultiAttribute<T> : Attribute
{
public T Value { get; set; }
public MultiAttribute()
{
}
public MultiAttribute(T value)
{
Value = value;
}
}
public enum MyEnum
{
Ctor,
Property
}
[SingleAttribute<int>()]
[SingleAttribute<bool>()]
[MultiAttribute<int>()]
[MultiAttribute<int>(1)]
[MultiAttribute<int>(Value = 2)]
[MultiAttribute<bool>()]
[MultiAttribute<bool>(true)]
[MultiAttribute<bool>(Value = true)]
[MultiAttribute<bool?>()]
[MultiAttribute<string>("Ctor")]
[MultiAttribute<string>(Value = "Property")]
[MultiAttribute<Type>(typeof(Class))]
[MultiAttribute<Type>(Value = typeof(Class.Derive))]
[MultiAttribute<MyEnum>(MyEnum.Ctor)]
[MultiAttribute<MyEnum>(Value = MyEnum.Property)]
public class Class
{
public class Derive : Class
{
}
[SingleAttribute<int>()]
[SingleAttribute<bool>()]
[MultiAttribute<int>()]
[MultiAttribute<int>(1)]
[MultiAttribute<int>(Value = 2)]
[MultiAttribute<bool>()]
[MultiAttribute<bool>(true)]
public int Property { get; set; }
}
|