예제 #1
0
 public void HandleString(String str)
 {
     MethodInfo[] methods = typeof(Program).GetMethods();
     foreach (MethodInfo method in methods)
     {
         Attribute         attr = Attribute.GetCustomAttribute(method, typeof(ProvidesAttribute));
         ProvidesAttribute prov = attr as ProvidesAttribute;
         if ((prov != null) && (prov.Contains(str)))
         {
             method.Invoke(this, new Object[] { str });
             break;      // removing this enables multiple "providers"
         }
     }
 }
예제 #2
0
 public void HandleString(String str)
 {
     // we could loop through each Type in the assembly here instead of just looking at the
     // methods of Program; this would allow us to push our "providers" out to other classes
     MethodInfo[] methods = typeof(Program).GetMethods();
     foreach (MethodInfo method in methods)
     {
         Attribute         attr = Attribute.GetCustomAttribute(method, typeof(ProvidesAttribute));
         ProvidesAttribute prov = attr as ProvidesAttribute;
         if ((prov != null) && (prov.Contains(str)))
         {
             method.Invoke(this, new Object[] { str });
             break;      // removing this enables multiple "providers"
         }
     }
 }