Project

Profile

Help

How to connect?
Download (1.57 KB) Statistics
| Branch: | Tag: | Revision:

he / tags / 9.6.0.7 / hen / csource / samples / Spec.cs @ aa733b18

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Reflection;
6

    
7

    
8
namespace TestRunner
9
{
10
    [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
11
    public class EnumAttr : Attribute
12
    {
13

    
14
        public EnumAttr() { }
15

    
16
    }
17

    
18
    public static class EnumExtension
19
    {
20
        public static EnumAttr GetAttr(this Enum value)
21
        {
22
            Type type = value.GetType();
23
            FieldInfo fieldInfo = type.GetField(value.ToString());
24
            var atts = (EnumAttr[])fieldInfo.GetCustomAttributes(typeof(EnumAttr), false);
25
            return atts.Length > 0 ? atts[0] : null;
26
        }
27
    }
28

    
29

    
30
    public class SpecAttr : EnumAttr
31
    {
32
        public string version;
33
        public string fname;
34
        public string sname;
35
        public string svname;
36

    
37
        public SpecAttr(String l, String na, String sn, String sv)
38
        {
39
            version = l;
40
            fname = na;
41
            sname = sn;
42
            svname = sv;
43
        }
44
    }
45

    
46

    
47

    
48
    public enum Spec
49
    {
50
        [SpecAttr("2.0", "XPath2.0", "XP", "XP20")]
51
        XP20,
52
        [SpecAttr("3.0", "XPath3.0", "XP", "XP30")]
53
        XP30,
54
        [SpecAttr("1.0", "XQuery1.0", "XQ", "XQ10")]
55
        XQ10,
56
        [SpecAttr("3.0", "XQuery3.0", "XQ", "XQ30")]
57
        XQ30,
58
        [SpecAttr("1.0", "XSLT1.0", "XT", "XT10")]
59
        XT10,
60
        [SpecAttr("2.0", "XSLT2.0", "XT", "XT20")]
61
        XT20,
62
        [SpecAttr("3.0", "XSLT3.0", "XT", "XT30")]
63
        XT30,
64
        [SpecAttr("0", "null", "n", "null")]
65
        NULL,
66

    
67
    }
68

    
69

    
70
}
(13-13/24)