Add %csattributes for adding C# attributes to enum values, see docs for example.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11691 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4ebb9b0db2
commit
5eeab68e21
4 changed files with 34 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel;
|
||||
using csharp_attributesNamespace;
|
||||
|
||||
public class runme
|
||||
|
|
@ -171,6 +172,24 @@ public class runme
|
|||
if (Attribute.GetCustomAttribute(member, typeof(Eurostar2Attribute)) == null)
|
||||
throw new Exception("No attribute for " + member.Name);
|
||||
}
|
||||
// Enum value attributes
|
||||
Type walesType = typeof(MoreStations.Wales);
|
||||
{
|
||||
MemberInfo member = (MemberInfo)walesType.GetMember("Cardiff")[0];
|
||||
DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
|
||||
if (attribute == null)
|
||||
throw new Exception("No attribute for " + member.Name);
|
||||
if (attribute.Description != "Cardiff city station")
|
||||
throw new Exception("Incorrect attribute value for " + member.Name);
|
||||
}
|
||||
{
|
||||
MemberInfo member = (MemberInfo)walesType.GetMember("Swansea")[0];
|
||||
DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
|
||||
if (attribute == null)
|
||||
throw new Exception("No attribute for " + member.Name);
|
||||
if (attribute.Description != "Swansea city station")
|
||||
throw new Exception("Incorrect attribute value for " + member.Name);
|
||||
}
|
||||
// Enum csattribute typemap
|
||||
{
|
||||
Type cymrutype = typeof(Cymru);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue