示例#1
0
 /// <summary>
 /// Retourner un objet de type MethodInfo que l'on peut invoquer avec ses parametres
 /// </summary>
 public static MethodInfo getMethod(string name, Type type, OperationInfo.VisibilityType visibility)
 {
     foreach (MethodInfo mi in type.GetMethods())
     {
         if (mi.GetCustomAttributes(typeof(OperationInfo), false).Count() != 0)
         {
             if (mi.GetCustomAttributes(typeof(OperationInfo), false)[0].GetType() == typeof(OperationInfo))
             {
                 OperationInfo oi = (OperationInfo)mi.GetCustomAttributes(typeof(OperationInfo), false)[0];
                 if (oi.Visibility == visibility)
                 {
                     if (oi.Title == name)
                     {
                         return(mi);
                     }
                 }
             }
         }
     }
     throw new Exception();
 }
示例#2
0
 /// <summary>
 /// Exécuter l'opération demandée, puis envoyer le résultat au client
 /// </summary>
 public void handleRequest(ServerToolsEvent e, Type type, string name)
 {
     try {
         MethodInfo mi = LibraryInterfaceServer.Utils.getMethod(e.Operation, type, OperationInfo.VisibilityType.GLOBAL);
         if (mi.GetCustomAttributes(typeof(OperationInfo), false).Count() != 0)
         {
             if (mi.GetCustomAttributes(typeof(OperationInfo), false)[0].GetType() == typeof(OperationInfo))
             {
                 OperationInfo oi = (OperationInfo)mi.GetCustomAttributes(typeof(OperationInfo), false)[0];
                 if (oi.Visibility == OperationInfo.VisibilityType.GLOBAL)
                 {
                     try {
                         e.Param.Add(e.Id.ToString());
                         MethodInfo    mib    = LibraryInterfaceServer.Utils.getMethod(oi.Func, type, OperationInfo.VisibilityType.PRIVATE);
                         List <string> result = (List <string>)mib.Invoke(null, new object[] { e.Param });
                         if (result != null)
                         {
                             Send(name, e.Source, e.Operation, e.Stamp.ToString(), result, e.Id);
                         }
                         return;
                     }
                     catch {
                         Send(name, e.Source, e.Operation, e.Stamp.ToString(), new List <string>()
                         {
                             DataUtils.BAD_PARAMETERS_CODE
                         }, e.Id);
                         return;
                     }
                 }
             }
         }
     }
     catch {
         Send(name, e.Source, e.Operation, e.Stamp.ToString(), new List <string>()
         {
             DataUtils.UNKOWN_OPERATION
         }, e.Id);
     }
 }
示例#3
0
 /// <summary>
 /// Retourner un objet de type MethodInfo que l'on peut invoquer avec ses parametres
 /// </summary>
 public static MethodInfo getMethod(string name, Type type, OperationInfo.VisibilityType visibility)
 {
     foreach (MethodInfo mi in type.GetMethods()) {
         if (mi.GetCustomAttributes(typeof(OperationInfo), false).Count() != 0) {
             if (mi.GetCustomAttributes(typeof(OperationInfo), false)[0].GetType() == typeof(OperationInfo)) {
                 OperationInfo oi = (OperationInfo)mi.GetCustomAttributes(typeof(OperationInfo), false)[0];
                 if (oi.Visibility == visibility) {
                     if (oi.Title == name)
                         return mi;
                 }
             }
         }
     }
     throw new Exception();
 }