예제 #1
0
        /// <summary>
        /// Add an enum to the service for the given enum type annotated with the KRPCEnum attribute.
        /// Returns the name of the enumeration.
        /// </summary>
        public string AddEnum(Type enumType)
        {
            TypeUtils.ValidateKRPCEnum(enumType);
            var name = enumType.Name;

            if (Enumerations.ContainsKey(name))
            {
                throw new ServiceException("Service " + Name + " contains duplicate enumerations " + name);
            }
            var values = new List <EnumerationValueSignature> ();

            foreach (FieldInfo field in enumType.GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                values.Add(new EnumerationValueSignature(Name, name, field.Name, (int)field.GetRawConstantValue(), field.GetDocumentation()));
            }
            Enumerations [name] = new EnumerationSignature(Name, name, values, enumType.GetDocumentation());
            return(name);
        }
예제 #2
0
 /// <summary>
 /// Add an enum to the service for the given enum type annotated with the KRPCEnum attribute.
 /// Returns the name of the enumeration.
 /// </summary>
 public string AddEnum (Type enumType)
 {
     TypeUtils.ValidateKRPCEnum (enumType);
     var name = enumType.Name;
     if (Enumerations.ContainsKey (name))
         throw new ServiceException ("Service " + Name + " contains duplicate enumerations " + name);
     var values = new List<EnumerationValueSignature> ();
     foreach (FieldInfo field in enumType.GetFields(BindingFlags.Public | BindingFlags.Static)) {
         values.Add (new EnumerationValueSignature (Name, name, field.Name, (int)field.GetRawConstantValue (), field.GetDocumentation ()));
     }
     Enumerations [name] = new EnumerationSignature (Name, name, values, enumType.GetDocumentation ());
     return name;
 }
예제 #3
0
 void CheckDocumentation (EnumerationSignature enm)
 {
     CheckDocumentation (enm.FullyQualifiedName, enm.Documentation);
     foreach (var enmValue in enm.Values)
         CheckDocumentation (enmValue.FullyQualifiedName, enmValue.Documentation);
 }