// Hearthbuddy.Windows.MainWindow
// Token: 0x060001FF RID: 511 RVA: 0x0008951C File Offset: 0x0008771C
private void method_1(object sender, RoutedEventArgs e)
{
try
{
base.Title = "Hearthbuddy";
base.SetBinding(Window.LeftProperty, new Binding("WindowX")
{
Source = MainSettings.Instance,
Mode = BindingMode.TwoWay
});
base.SetBinding(Window.TopProperty, new Binding("WindowY")
{
Source = MainSettings.Instance,
Mode = BindingMode.TwoWay
});
base.SetBinding(FrameworkElement.WidthProperty, new Binding("WindowWidth")
{
Source = MainSettings.Instance,
Mode = BindingMode.TwoWay
});
base.SetBinding(FrameworkElement.HeightProperty, new Binding("WindowHeight")
{
Source = MainSettings.Instance,
Mode = BindingMode.TwoWay
});
MainSettings.Instance.LoadRowDefinitions(this.rowDefinition_0, this.rowDefinition_1, this.rowDefinition_2);
this.method_3();
this.textBox_0.Text = Logger.FileName;
this.method_17();
this.method_18();
this.method_19();
this.method_20();
}
catch (Exception exception)
{
MainWindow.ilog_0.Error("[Ui] An exception occurred.", exception);
}
}
// Hearthbuddy.Windows.MainWindow
// Token: 0x06000201 RID: 513 RVA: 0x00003C51 File Offset: 0x00001E51
private void method_3()
{
ThreadPool.QueueUserWorkItem(new WaitCallback(this.method_21));
}
// Hearthbuddy.Windows.MainWindow
// Token: 0x06000231 RID: 561 RVA: 0x0008AC20 File Offset: 0x00088E20
[CompilerGenerated]
private void method_21(object object_0)
{
try
{
base.Dispatcher.Invoke(new Action(this.method_22));
string text;
if (this.process_0 == null)
{
base.Dispatcher.BeginInvoke(new Action(base.Close), Array.Empty<object>());
}
else if (!TritonHs.smethod_0(this.process_0, new TritonHs.Delegate6(Class12.smethod_4), out text))
{
MainWindow.ilog_0.Error(text);
System.Windows.MessageBox.Show(text, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
base.Dispatcher.BeginInvoke(new Action(base.Close), Array.Empty<object>());
}
else
{
TritonHs.Memory.ProcessExited += MainWindow.Class25.ChuckInstance9.method_1;
TritonHs.Memory.Executor.FrameDropWaitTime = 15000u;
TritonHs.Memory.Executor.ExecuteWaitTime = ;
TritonHs.Memory.DisableCache();
TritonHs.Memory.ClearCache();
int version;
int clientChangelist;
using (TritonHs.AcquireFrame())
{
version = Triton.Game.Mapping.Version.version;
clientChangelist = Triton.Game.Mapping.Version.clientChangelist;
}
if ((long)version != (long)((ulong)Class247.UInt32_1) && (long)clientChangelist != (long)((ulong)Class247.UInt32_2))
{
MainWindow.ilog_0.InfoFormat("Hearthstone client version ({0}, {1})", version, clientChangelist);
new Coroutine(new Func<Task>(MainWindow.Class25.ChuckInstance9.method_2));
Configuration.Instance.AddSettings(MainSettings.Instance);
Configuration.Instance.AddSettings(DevSettings.Instance);
Configuration.Instance.SaveAll();
base.Dispatcher.Invoke(new Action(this.method_23));
BotManager.PreStart += this.method_11;
BotManager.PostStop += this.method_10;
BotManager.Load();
base.Dispatcher.Invoke(new Action(this.method_24));
this.comboBox_0.Dispatcher.BeginInvoke(new Action(this.method_25), Array.Empty<object>());
BotManager.OnBotChanged += this.method_6;
RoutineManager.Load();
base.Dispatcher.Invoke(new Action(this.method_26));
this.comboBox_1.Dispatcher.BeginInvoke(new Action(this.method_27), Array.Empty<object>());
RoutineManager.OnRoutineChanged += this.method_7;
PluginManager.Load();
foreach (IPlugin plugin in PluginManager.Plugins)
{
if (MainSettings.Instance.EnabledPlugins.Contains(plugin.Name))
{
using (TritonHs.AcquireFrame())
{
PluginManager.Enable(plugin);
}
Thread.Sleep();
}
else
{
using (TritonHs.AcquireFrame())
{
PluginManager.Disable(plugin);
}
Thread.Sleep();
}
}
this.listBox_0.Dispatcher.Invoke<IEnumerable>(new Func<IEnumerable>(this.method_28), DispatcherPriority.Normal);
base.Dispatcher.Invoke(new Action(this.method_29));
PluginManager.PluginEnabled += this.method_5;
PluginManager.PluginDisabled += this.method_4;
MainWindow.ilog_0.InfoFormat("{0}Please read the following guide before using this program:{0}https://www.thebuddyforum.com/hearthbuddy-forum/210230-hearthbuddy-bm-release-thread.html", Environment.NewLine);
base.Dispatcher.Invoke(new Action(this.method_30));
base.Dispatcher.Invoke(new Action(this.method_31));
this.stopwatch_0.Restart();
RoutineManager.OnRoutineChanged += this.method_7;
BotManager.OnBotChanged += this.method_6;
TritonHs.IsBotFullyLoaded = true;
Hotkeys.Register("BotManager.StartStop", Keys.S, ModifierKeys.Alt | ModifierKeys.Shift, new Action<Hotkey>(MainWindow.Class25.ChuckInstance9.method_3));
if (CommandLine.Arguments.Exists("autostart"))
{
BotManager.Start();
}
}
else
{
text = string.Format("This client version ({0}, {1}) is unsupported. Hearthbuddy currently supports client version ({2}, {3}). Please check the forums for more information: https://www.thebuddyforum.com/hearthbuddy-forum/", new object[]
{
version,
clientChangelist,
Class247.UInt32_1,
Class247.UInt32_2
});
MainWindow.ilog_0.ErrorFormat(text, Array.Empty<object>());
System.Windows.MessageBox.Show(text, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
base.Dispatcher.BeginInvoke(new Action(base.Close), Array.Empty<object>());
}
}
}
catch (Exception exception)
{
MainWindow.ilog_0.Error("[OnStartup] A top-level exception has been caught.", exception);
}
}

namespace Triton.Bot

public static class PluginManager

通过load函数进行加载,而且加载的是固定路径,扫描Plugins文件夹

public static bool Load()
{
try
{
string pluginsPath = PluginManager.PluginsPath;
if (BotManager.IsRunning)
{
throw new InvalidOperationException("Cannot Load plugins while the bot is running.");
}
if (PluginManager.Plugins != null)
{
PluginManager.ilog_0.ErrorFormat("[Load] This function can only be called once.", Array.Empty<object>());
return false;
}
if (!Directory.Exists(pluginsPath))
{
Directory.CreateDirectory(pluginsPath);
}
AssemblyLoader<IPlugin> assemblyLoader = new AssemblyLoader<IPlugin>(pluginsPath, false);
PluginManager.Plugins = new List<IPlugin>();
foreach (IPlugin plugin in assemblyLoader.Instances.AsReadOnly())
{
try
{
Utility.smethod_0(plugin);
plugin.Initialize();
PluginManager.Plugins.Add(plugin);
}
catch (Exception exception)
{
PluginManager.ilog_0.Debug("[Load] Exception thrown when initializing " + plugin.Name + ". Plugin will not be loaded.", exception);
Utility.smethod_1(plugin);
plugin.Deinitialize();
}
}
return true;
}
catch (Exception arg)
{
PluginManager.ilog_0.ErrorFormat("[Load] An exception occurred: {0}.", arg);
}
return false;
}
public static string PluginsPath
{
get
{
return Path.Combine(PluginManager.String_0, "Plugins");
}
}
private static string String_0
{
get
{
return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
}
}

使用AssemblyLoader加载插件,只扫描.cs文件

this.fileSystemWatcher_0.Filter = "*.cs";
public AssemblyLoader(string directory, bool detectFileChanges)
{
this.Instances = new List<T>();
this.string_0 = directory;
this.bool_0 = detectFileChanges;
if (this.bool_0)
{
this.fileSystemWatcher_0.Path = directory;
this.fileSystemWatcher_0.Filter = "*.cs";
this.fileSystemWatcher_0.IncludeSubdirectories = true;
this.fileSystemWatcher_0.EnableRaisingEvents = true;
this.fileSystemWatcher_0.Changed += this.method_0;
this.fileSystemWatcher_0.Created += this.method_1;
this.fileSystemWatcher_0.Deleted += this.method_2;
}
this.Reload("Initializing");
}
public void Reload(string reason)
{
this.ilog_0.Debug(string.Format("Reloading AssemblyLoader<{0}> - {1}", typeof(T), reason));
this.Instances = new List<T>();
if (!Directory.Exists(this.string_0))
{
this.ilog_0.Error(string.Format("Could not Reload assemblies because the path \"{0}\" does not exist.", this.string_0));
return;
}
foreach (string path in Directory.GetDirectories(this.string_0))
{
try
{
CodeCompiler codeCompiler = new CodeCompiler(path);
CompilerResults compilerResults = codeCompiler.Compile();
if (compilerResults != null)
{
if (compilerResults.Errors.HasErrors)
{
foreach (object obj in compilerResults.Errors)
{
this.ilog_0.Error("Compiler Error: " + obj.ToString());
}
}
else
{
this.Instances.AddRange(new TypeLoader<T>(codeCompiler.CompiledAssembly, null));
}
}
}
catch (Exception ex)
{
if (ex is ReflectionTypeLoadException)
{
foreach (Exception exception in (ex as ReflectionTypeLoadException).LoaderExceptions)
{
this.ilog_0.Error("[Reload] An exception occurred.", exception);
}
}
else
{
this.ilog_0.Error("[Reload] An exception occurred.", ex);
}
}
}
using (List<T>.Enumerator enumerator2 = new TypeLoader<T>(null, null).GetEnumerator())
{
while (enumerator2.MoveNext())
{
AssemblyLoader<T>.Class229 @class = new AssemblyLoader<T>.Class229();
@class.gparam_0 = enumerator2.Current;
if (!this.Instances.Any(new Func<T, bool>(@class.method_0)))
{
this.Instances.Add(@class.gparam_0);
}
}
}
if (this.eventHandler_0 != null)
{
this.eventHandler_0(this, null);
}
}

HearthBuddy的plugin加载的更多相关文章

  1. [ipsec][strongswan] strongswan源码分析--(四)plugin加载优先级原理

    前言 如前所述, 我们知道,strongswan以插件功能来提供各种各样的功能.插件之间彼此相互提供功能,同时也有可能提供重复的功能. 这个时候,便需要一个优先级关系,来保证先后加载顺序. 方法 在配 ...

  2. ue4 plugin的编译加载

    插件Plugin: 本来应该是指一种纯以接口与外界打交道的程序模块,在同一接口背后可以有多种实现,更换实现完全不影响客户端代码(不用重编). 但是在ue4的世界里,插件似乎不是这个意思,仅仅是一种可以 ...

  3. Zepto picLazyLoad Plugin,图片懒加载的Zepto插件

    嗯,学着国外人起名字Zepto picLazyLoad Plugin确实看起来高大上,其实js代码没几句,而且我每次写js都捉襟见肘,泪奔--- 图片懒加载有很多js插件,非常著名的属jQuery的L ...

  4. 【转】JS判断SWF,JPG加载完毕、兼容(Activex,plugIn)所有浏览器

    JS判断SWF,JPG加载完毕.兼容(Activex,plugIn)所有浏览器 这里主要说下监听SWF的加载. 网上流传已久的监听方法,只能在IE(Activex插件下)下实现.在使用plugin的浏 ...

  5. 闭包创建自己的 plugin 示例 加载 loading

    plugin  插件 什么是 plugin? 实现一个功能,与主应用程序分离,减少主应用程序的大小,高复用,可维护 制作过程中,一定要避免依赖其他的元素,减少 id 等的使用,避免与页面中其他内容冲突 ...

  6. 动态加载js和css的jquery plugin

    一个简单的动态加载js和css的jquery代码,用于在生成页面时通过js函数加载一些共通的js和css文件. //how to use the function below: //$.include ...

  7. android使用PullToRefresh实现上拉加载和下拉刷新效果

    其实很早前就在博客园中也写过官方的下拉刷新控件SwipeRefreshLayout,但是这个控件仅仅支持下拉刷新,用起来还算可以.然而在我们实际开发应用中,很多地方都不止有下拉刷新,而且还有上拉加载的 ...

  8. jquery 页面滚动到底部自动加载插件集合

    很多社交网站都使用无限滚动的翻页技术来提高用户体验,当你页面滑到列表底部时候无需点击就自动加载更多的内容.下面为你推荐 10 个 jQuery 的无限滚动的插件: 1. jQuery ScrollPa ...

  9. 前端实现图片懒加载(lazyload)的两种方式

    在实际的项目开发中,我们通常会遇见这样的场景:一个页面有很多图片,而首屏出现的图片大概就一两张,那么我们还要一次性把所有图片都加载出来吗?显然这是愚蠢的,不仅影响页面渲染速度,还浪费带宽.这也就是们通 ...

随机推荐

  1. 关于api接口以及页面数据通信域名,缓存cdn设置优化

    以B站为例: 主域名:www.bilibili.com 账户登录注册相关域名,包括app登录:passport.bilibili.com 静态资源css,js,img等相关域名:static.bili ...

  2. Nginx----请求分发中心

    Nginx请求分发中心,需要明确几个基本问题,什么是请求,分发中心是什么,为什么需要分发中心. 什么是请求? Niginx是一款高性能的HTTP服务器,这里的请求当然是指接收客户端发送的http协议请 ...

  3. apk 查看sha1签名

    1,首先使用解压工具解开apk. 2,进入meta-inf文件夹,进入命令行模式 输入如下命令 keytool -printcert -file CERT.RSA

  4. Spark Submit给jar包中的main函数传递参数

    1 示范 spark-submit --master xxx demo.jar "arg1" "arg2" 运行的jar包和传参放在最后,就可以了

  5. 8、nginx基础

    1Nginx基本简述 Nginx是一个开源且高性能.可靠的Http Web服务.代理服务. 开源: 直接获取源代码 高性能: 支持海量并发 可靠: 服务稳定 我们为什么选择 Nginx服务 Nginx ...

  6. kali工具的总结

    由于篇幅有限,只列举部分,ps:第一次发有什么不对的 还望各位大大指正 nc 瑞士军刀 [v1.10-41] 使用格式: nc [-参数] 主机名 端口[s] [端口] … 侦听入站: nc -l - ...

  7. SQL 语句外键 a foreign key constraint fails

    queryRunner.update("SET FOREIGN_KEY_CHECKS = 0;"); queryRunner.update(sql, pid); queryRunn ...

  8. getAttribute和getParameter的简单区别

    getAttribute表示从request范围取得设置的属性,必须要先setAttribute设置属性,才能通过getAttribute来取得,设置与取得的为Object对象类型 getParame ...

  9. golang 系列学习(-) 数据类型

    数据类型的出现 在的编程语言中,数据类型用于声明函数和变量,数据类型的出现是为了要把数据分成数据所需要内存大小的不同数据,编程时需要什么样的内存就申请什么样的内存.就可以充分的利用内存,更好的霸控程序 ...

  10. 纯前端导出Excel表格

    <html> <head> <p style="font-size: 20px;color: red;">使用a标签方式将json导出csv文件 ...