// 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. 如果您的浏览器不支持javascript功能

    如果您的浏览器不支持javascript功能或被禁止使用,那么在访问许多网站(包括此网站)时,某些功能将不可用.我们建议您打开javascript功能以获得最佳的浏览效果.以下是打开它的可能原因和方法 ...

  2. docker容器生态技术链

    图片来源:https://blog.51cto.com/liuleis/2067116 说明:学习Docker容器技术,先纵向了解大致内容架构,再横向逐一分解涉及的各项技术内容,对容器所涉及的技术体系 ...

  3. 第二章· MySQL体系结构管理

    一.客户端与服务器模型  1.mysql是一个典型的C/S服务结构 1.1 mysql自带的客户端程序(/application/mysql/bin) mysql mysqladmin mysqld ...

  4. 网络初级篇之VLAN间路由(原理与配置)

    一.VLAN间的路由 由于VLAN隔离了二层广播域,也间接的隔离了各个VLAN之间的其他二层流量交换,这样导致属于不同VLAN之间的用户不能进行二层的通信.只能经过三层的路由转发才能将报文从一个VLA ...

  5. linux 计划任务超时控制和并发控制

    Linux crontab 的配置存放 /var/spool/cron 目录下. Linux crontab的日志文件存放再 /var/log/cron* timeout 命令 timeout 给脚本 ...

  6. 【转载】GAN for NLP 论文笔记

    本篇随笔为转载,原贴地址,知乎:GAN for NLP(论文笔记及解读).

  7. QOpenGLWidget

    QOpenGLWidget描述 QOpenGLWidget类是用于渲染OpenGL图形. 除了可以选择使用QPainter和标准的OpenGL渲染图形,QOpenGLWidget类提供了在Qt应用程序 ...

  8. XShell 假死

    使用vim时因为使用windows word带来的坏习惯经常喜欢ctrl+s ,而这个造成的结果就是xshell假死,解决办法是ctrl+q

  9. TOMCAT控制台日志输出到指定文件中

    1 .修改startup.bat第42行 call "%EXECUTABLE%" start %CMD_LINE_ARGS% 为 call "%EXECUTABLE%&q ...

  10. CAP原理与最终一致性 强一致性 弱一致性

    CAP原理中,有三个要素: 一致性(Consistency) 可用性(Availability) 分区容忍性(Partition tolerance) CAP原理指的是,这三个要素最多只能同时实现两点 ...