Exemple #1
0
 /// <summary>
 /// Add a property to the service for the given property annotated with the KRPCProperty attribute.
 /// </summary>
 public void AddProperty(PropertyInfo property)
 {
     TypeUtils.ValidateKRPCProperty (property);
     if (property.GetGetMethod () != null) {
         var method = property.GetGetMethod ();
         var handler = new ProcedureHandler (method);
         var attribute = "Property.Get(" + property.Name + ")";
         AddProcedure (new ProcedureSignature (Name, method.Name, property.GetDocumentation (), handler, GameScene, attribute));
     }
     if (property.GetSetMethod () != null) {
         var method = property.GetSetMethod ();
         var handler = new ProcedureHandler (method);
         var attribute = "Property.Set(" + property.Name + ")";
         AddProcedure (new ProcedureSignature (Name, method.Name, property.GetDocumentation (), handler, GameScene, attribute));
     }
 }
Exemple #2
0
 /// <summary>
 /// Add a class property to the given class in the given service for the given property annotated with the KRPCProperty attribute.
 /// </summary>
 public void AddClassProperty(string cls, PropertyInfo property)
 {
     if (!Classes.ContainsKey (cls))
         throw new ArgumentException ("Class " + cls + " does not exist");
     if (property.GetGetMethod () != null) {
         var method = property.GetGetMethod ();
         var handler = new ClassMethodHandler (method);
         var attribute = "Class.Property.Get(" + Name + "." + cls + "," + property.Name + ")";
         var parameter_attribute = "ParameterType(0).Class(" + Name + "." + cls + ")";
         AddProcedure (new ProcedureSignature (Name, cls + '_' + method.Name, property.GetDocumentation (), handler, GameScene, attribute, parameter_attribute));
     }
     if (property.GetSetMethod () != null) {
         var method = property.GetSetMethod ();
         var handler = new ClassMethodHandler (method);
         var attribute = "Class.Property.Set(" + Name + "." + cls + "," + property.Name + ")";
         var parameter_attribute = "ParameterType(0).Class(" + Name + "." + cls + ")";
         AddProcedure (new ProcedureSignature (Name, cls + '_' + method.Name, property.GetDocumentation (), handler, GameScene, attribute, parameter_attribute));
     }
 }