Advertisement
Serafim

Untitled

Sep 4th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1.         protected void callMethod(String caller = null)
  2.         {
  3.             if (caller == null) { return; }
  4.             Console.WriteLine("Call: " + caller);
  5.             Match match = Regex.Match(
  6.                 caller,
  7.                 @"jsc:\/\/(?<cls>\w+):(?<name>\w+)@?"
  8.             );
  9.  
  10.             if (match.Groups.Count >= 2)
  11.             {
  12.                 String cls = match.Groups[1].Value;
  13.                 String method = match.Groups[2].Value;
  14.                 Object[] args = caller.Replace(
  15.                     match.Groups[0].Value, ""
  16.                 ).Split(',');
  17.  
  18.                 // типы
  19.                 try
  20.                 {
  21.                     Type clsType = Type.GetType("Xphp.Plugins." + cls);
  22.                     MethodInfo methodType = clsType.GetMethod(method);
  23.                     Object target = this.getPluginInstance(clsType);
  24.  
  25.                     methodType.Invoke(
  26.                         target,
  27.                         args
  28.                     );
  29.                 }
  30.                 catch (Exception exc)
  31.                 {
  32.                     Console.WriteLine("Runtime Xphp Reflection exception: " + exc.Message.ToString());
  33.                 }
  34.             }
  35.         }
  36.  
  37.         protected Object getPluginInstance(Type type)
  38.         {
  39.             ConstructorInfo ctor = type.GetConstructor(new[] {
  40.                 typeof(MainForm),
  41.                 typeof(WebKitBrowser)
  42.             });
  43.             return ctor.Invoke(new object[] {
  44.                 this,
  45.                 this.browser
  46.             });
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement