示例#1
0
 public static void SubscribeToNetworkEvents(RealPlugin p)
 {
     try
     {
         object plug = GetInstance();
         if (plug == null)
         {
             throw new ArgumentException("No plugin instance available");
         }
         PropertyInfo pi = plug.GetType().GetProperty("DataSubscription", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
         if (pi == null)
         {
             throw new ArgumentException("No DataSubscription found");
         }
         dynamic subs = pi.GetValue(plug);
         if (subs == null)
         {
             throw new ArgumentException("DataSubscription not initialized");
         }
         EventInfo ei = subs.GetType().GetEvent("ParsedLogLine", BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance);
         if (subs == null)
         {
             throw new ArgumentException("No ParsedLogLine found");
         }
         MethodInfo mix     = p.GetType().GetMethod("NetworkLogLineReceiver");
         Type       deltype = ei.EventHandlerType;
         Delegate   handler = Delegate.CreateDelegate(deltype, p, mix);
         ei.AddEventHandler(subs, handler);
         LogMessage(RealPlugin.DebugLevelEnum.Info, I18n.Translate("internal/ffxiv/networksubok", "Subscribed to FFXIV network events"));
     }
     catch (Exception ex)
     {
         LogMessage(RealPlugin.DebugLevelEnum.Error, I18n.Translate("internal/ffxiv/networksubexception", "Could not subscribe to FFXIV network events due to an exception: {0}", ex.Message));
     }
 }
示例#2
0
        internal MethodInfo GetImplMethodInfo(Type interfaceType, string methodName)
        {
            Debug.Assert(RealPlugin != null);
            MethodInfo m = RealPlugin.GetType().GetMethod(interfaceType.FullName + '.' + methodName);

            if (m == null)
            {
                m = RealPlugin.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            }
            return(m);
        }