public HBRelogApi() { // find the HBRelogHelper plugin assembly _hbRelogHelperAsm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault( a => a.GetName().Name.Contains("HBRelogHelper")); if (_hbRelogHelperAsm != null) { Type apiType = _hbRelogHelperAsm.GetType("HighVoltz.HBRelogHelper.HBRelogApi"); // IsConnected PropertyInfo propertyInfo = apiType.GetProperty("IsConnected", BindingFlags.Public | BindingFlags.Static); _isConnected = (Func <bool>)Delegate.CreateDelegate(typeof(Func <bool>), propertyInfo.GetGetMethod()); // CurrentProfileName propertyInfo = apiType.GetProperty("CurrentProfileName", BindingFlags.Public | BindingFlags.Static); _currentProfileName = (Func <string>)Delegate.CreateDelegate(typeof(Func <string>), propertyInfo.GetGetMethod()); // RestartWow MethodInfo methodInfo = apiType.GetMethod("RestartWow", BindingFlags.Public | BindingFlags.Static); _restartWow = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo); // RestartHB methodInfo = apiType.GetMethod("RestartHB", BindingFlags.Public | BindingFlags.Static); _restartHB = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo); // GetProfileNames methodInfo = apiType.GetMethod("GetProfileNames", BindingFlags.Public | BindingFlags.Static); _getProfileNames = (Func <string[]>)Delegate.CreateDelegate(typeof(Func <string[]>), methodInfo); // StartProfile methodInfo = apiType.GetMethod("StartProfile", BindingFlags.Public | BindingFlags.Static); _startProfile = (Action <string>)Delegate.CreateDelegate(typeof(Action <string>), methodInfo); // StopProfile methodInfo = apiType.GetMethod("StopProfile", BindingFlags.Public | BindingFlags.Static); _stopProfile = (Action <string>)Delegate.CreateDelegate(typeof(Action <string>), methodInfo); // PauseProfile methodInfo = apiType.GetMethod("PauseProfile", BindingFlags.Public | BindingFlags.Static); _pauseProfile = (Action <string>)Delegate.CreateDelegate(typeof(Action <string>), methodInfo); // IdleProfile methodInfo = apiType.GetMethod("IdleProfile", BindingFlags.Public | BindingFlags.Static); _idleProfile = (Action <string, TimeSpan>)Delegate.CreateDelegate(typeof(Action <string, TimeSpan>), methodInfo); // GetProfileStatus methodInfo = apiType.GetMethod("GetProfileStatus", BindingFlags.Public | BindingFlags.Static); _getProfileStatus = (Func <string, int>)Delegate.CreateDelegate(typeof(Func <string, int>), methodInfo); // SetProfileStatusText methodInfo = apiType.GetMethod("SetProfileStatusText", BindingFlags.Public | BindingFlags.Static); _setProfileStatusText = (Action <string>)Delegate.CreateDelegate(typeof(Action <string>), methodInfo); // Logon methodInfo = apiType.GetMethod("Logon", BindingFlags.Public | BindingFlags.Static); _logon = (LogonDelegate)Delegate.CreateDelegate(typeof(LogonDelegate), methodInfo); methodInfo = apiType.GetMethod("SkipCurrentTask", BindingFlags.Public | BindingFlags.Static); _skipCurrentTask = (Action <string>)Delegate.CreateDelegate(typeof(Action <string>), methodInfo); } }
public HBRelogApi() { // find the HBRelogHelper plugin assembly _hbRelogHelperAsm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault( a => a.GetName().Name.Contains("HBRelogHelper")); if (_hbRelogHelperAsm != null) { Type apiType = _hbRelogHelperAsm.GetType("HighVoltz.HBRelogHelper.HBRelogApi"); // IsConnected PropertyInfo propertyInfo = apiType.GetProperty("IsConnected", BindingFlags.Public | BindingFlags.Static); _isConnected = (Func<bool>) Delegate.CreateDelegate(typeof (Func<bool>), propertyInfo.GetGetMethod()); // CurrentProfileName propertyInfo = apiType.GetProperty("CurrentProfileName", BindingFlags.Public | BindingFlags.Static); _currentProfileName = (Func<string>) Delegate.CreateDelegate(typeof (Func<string>), propertyInfo.GetGetMethod()); // RestartWow MethodInfo methodInfo = apiType.GetMethod("RestartWow", BindingFlags.Public | BindingFlags.Static); _restartWow = (Action) Delegate.CreateDelegate(typeof (Action), methodInfo); // RestartHB methodInfo = apiType.GetMethod("RestartHB", BindingFlags.Public | BindingFlags.Static); _restartHB = (Action) Delegate.CreateDelegate(typeof (Action), methodInfo); // GetProfileNames methodInfo = apiType.GetMethod("GetProfileNames", BindingFlags.Public | BindingFlags.Static); _getProfileNames = (Func<string[]>) Delegate.CreateDelegate(typeof (Func<string[]>), methodInfo); // StartProfile methodInfo = apiType.GetMethod("StartProfile", BindingFlags.Public | BindingFlags.Static); _startProfile = (Action<string>) Delegate.CreateDelegate(typeof (Action<string>), methodInfo); // StopProfile methodInfo = apiType.GetMethod("StopProfile", BindingFlags.Public | BindingFlags.Static); _stopProfile = (Action<string>) Delegate.CreateDelegate(typeof (Action<string>), methodInfo); // PauseProfile methodInfo = apiType.GetMethod("PauseProfile", BindingFlags.Public | BindingFlags.Static); _pauseProfile = (Action<string>) Delegate.CreateDelegate(typeof (Action<string>), methodInfo); // IdleProfile methodInfo = apiType.GetMethod("IdleProfile", BindingFlags.Public | BindingFlags.Static); _idleProfile = (Action<string, TimeSpan>) Delegate.CreateDelegate(typeof (Action<string, TimeSpan>), methodInfo); // GetProfileStatus methodInfo = apiType.GetMethod("GetProfileStatus", BindingFlags.Public | BindingFlags.Static); _getProfileStatus = (Func<string, int>) Delegate.CreateDelegate(typeof (Func<string, int>), methodInfo); // SetProfileStatusText methodInfo = apiType.GetMethod("SetProfileStatusText", BindingFlags.Public | BindingFlags.Static); _setProfileStatusText = (Action<string>) Delegate.CreateDelegate(typeof (Action<string>), methodInfo); // Logon methodInfo = apiType.GetMethod("Logon", BindingFlags.Public | BindingFlags.Static); _logon = (LogonDelegate) Delegate.CreateDelegate(typeof (LogonDelegate), methodInfo); methodInfo = apiType.GetMethod("SkipCurrentTask", BindingFlags.Public | BindingFlags.Static); _skipCurrentTask = (Action<string>) Delegate.CreateDelegate(typeof (Action<string>), methodInfo); } }