// 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);
}
}

最新文章

  1. AngularJs应用页面切换优化方案(转)
  2. 初识50个Linux命令
  3. hiho一下 第九十四周 数论三&#183;约瑟夫问题
  4. java利用JFreeChart实现各种数据统计图(柱形图,饼图,折线图)
  5. 161110、彻底征服 Spring AOP 之 实战篇
  6. 向Page对象注册脚本
  7. mongodb高级操作及在Java企业级开发中的应用
  8. 安装mono和jexus,运行asp.net程序
  9. json对象的简单介绍
  10. tomcat+jdk+mysql
  11. 实现CA证书创建及客户端申请证书
  12. ASP.NET MVC 分页问题
  13. .net 系列:事件和委托
  14. IDEA热部署(一)---解析关键配置。
  15. delphi Ctrl+鼠标左键或者Find Declaration不能定位到源文件
  16. linux date -s
  17. table动态增加删除
  18. DDD China Conference 2017
  19. [Canvas]奔跑的马
  20. Week6&amp;7——第一次项目冲刺(Alpha版本)

热门文章

  1. 使用javascript和jquery获取类方法
  2. mac 下开发golang 配置
  3. python之字典一
  4. SpringBoot static修饰的字段/方法如何获取application.yml配置
  5. raise与raise&#183;&#183;&#183;&#183;&#183;&#183;from
  6. 03:Java基础语法(二)
  7. 异步通信&amp;同步通信
  8. python函数:函数使用原则、定义与调用形式
  9. Linux用户组管理及用户权限3
  10. [ZOJ 3063] Draw Something Cheat