/// <summary> /// Retorna o delegate para uso. /// </summary> /// <typeparam name="T">Delegate</typeparam> /// <returns></returns> /// <exception cref="ACBrException"></exception> protected virtual T GetMethod <[DelegateConstraint] T>() where T : class { if (!methodList.ContainsKey(typeof(T))) { throw CreateException($"Função não adicionada para o [{nameof(T)}]."); } var method = methodList[typeof(T)]; this.Log().Debug($"{className} : Acessando o método [{method}] da biblioteca."); if (methodCache.ContainsKey(method)) { return(methodCache[method] as T); } var mHandler = LibLoader.GetProcAddress(handle, method); Guard.Against <ArgumentNullException>(mHandler == IntPtr.Zero || mHandler == MinusOne, "Função não encontrada: " + method); var methodHandler = LibLoader.LoadFunction <T>(mHandler); this.Log().Debug($"{className} : Método [{method}] carregado."); methodCache.Add(method, methodHandler as Delegate); return(methodHandler); }
/// <summary> /// Retorna o delegate para uso. /// </summary> /// <typeparam name="T">Delegate</typeparam> /// <returns></returns> /// <exception cref="ACBrException"></exception> protected virtual T GetMethod <T>() where T : class { if (!methodList.ContainsKey(typeof(T))) { throw CreateException($"Função não adicionada para o [{nameof(T)}]."); } var method = methodList[typeof(T)]; if (methodCache.ContainsKey(method)) { return(methodCache[method] as T); } var mHandler = LibLoader.GetProcAddress(handle, method); if (mHandler == IntPtr.Zero || mHandler == MinusOne) { throw new ArgumentNullException("Função não encontrada: " + method); } var methodHandler = LibLoader.LoadFunction <T>(mHandler); methodCache.Add(method, methodHandler as Delegate); return(methodHandler); }
public HomePage() { InitializeComponent(); var prolintVer = Updater <ProlintUpdaterWrapper> .Instance.LocalVersion; var proparseVer = Updater <ProparseUpdaterWrapper> .Instance.LocalVersion; var datadiggerVer = Updater <DataDiggerUpdaterWrapper> .Instance.LocalVersion; html.Text = HtmlResources.home.Replace("%version%", AssemblyInfo.Version) .Replace("%disclaimer%", AssemblyInfo.IsPreRelease ? HtmlResources.disclaimer : "") .Replace("%YamuiFrameworkVersion%", LibLoader.GetYamuiAssemblyVersion()) .Replace("%ProlintVersion%", prolintVer.Equals("v0") ? "*not installed*" : prolintVer) .Replace("%ProparseVersion%", proparseVer.Equals("v0") ? "*not installed*" : proparseVer) .Replace("%DataDiggerVersion%", datadiggerVer.Equals("v0") ? "*not installed*" : datadiggerVer) .Replace("%getting-started.md%", HtmlResources.getting_started.MdToHtml()); html.LinkClicked += (sender, args) => { if (args.Link.Equals("update")) { Appli.GoToPage(PageNames.OptionsUpdate); args.Handled = true; } }; yamuiScrollPage1.ContentPanel.Height = html.Height; }
public void LaunchProxy() { StringBuilder addrSv = new StringBuilder(256); StringBuilder addrOb; bool isObs = Options.Get <bool>(Options.Keys.ProxyObserve); if (!isObs) { addrOb = new StringBuilder("@", 256); } else { addrOb = new StringBuilder(256); } var rtn = LibLoader.LaunchProxy(addrSv, addrOb, 500); Debug.Log($"proxy launched with {rtn}"); Debug.Log($"Server:{addrSv}"); if (isObs) { Debug.Log($"Observe:{addrOb}"); } }
public void CheckUpdate() { string addr = Options.Get <string>(Options.Keys.UpdateAddress); if (addr != "local") { Debug.Log($"checking lastest version from {addr}"); Downloader.HttpDownloadFile(addr, TempPath); if (LibLoader.GetScriptVersion(TempPath) > LibLoader.GetScriptVersion(ScriptPath)) { File.Delete(ScriptPath); File.Move(TempPath, ScriptPath); Debug.Log("new version found!"); } else { Debug.Log("no update found!"); } } Debug.Log("update installed with " + LibLoader.InstallScript()); int ver = LibLoader.GetScriptVersion(ScriptPath); int a = ver / 100, b = ver % 100 / 10, c = ver % 10; Debug.Log("now version: " + a + "." + b + "." + c); File.Delete(TempPath); }
/// <inheritdoc /> protected ACBrSafeHandle(string dllPath) : base(IntPtr.Zero, true) { methodList = new Dictionary <Type, string>(); className = GetType().Name; var pNewSession = LibLoader.LoadLibrary(dllPath); Guard.Against <ACBrException>(pNewSession == IntPtr.Zero, "Não foi possivel carregar a biblioteca."); SetHandle(pNewSession); }
public HomePage() { InitializeComponent(); html.Text = HtmlResources.home.Replace("%version%", AssemblyInfo.Version) .Replace("%disclaimer%", AssemblyInfo.IsPreRelease ? HtmlResources.disclaimer : "") .Replace("%YamuiFrameworkVersion%", LibLoader.GetAssemblyVersion(@"YamuiFramework")) .Replace("%getting-started.md%", HtmlResources.getting_started.MdToHtml()); html.LinkClicked += HtmlOnLinkClicked; yamuiScrollPage1.ContentPanel.Height = html.Height; }
/// <inheritdoc /> protected ACBrLibHandle(string dllPath) : base(IntPtr.Zero, true) { methodCache = new Dictionary <string, Delegate>(); methodList = new Dictionary <Type, string>(); className = GetType().Name; var pNewSession = LibLoader.LoadLibrary(dllPath); if (pNewSession == IntPtr.Zero || pNewSession == MinusOne) { throw new ApplicationException("Não foi possivel carregar a biblioteca."); } SetHandle(pNewSession); }
protected ACBrLibHandle(string dllName) : base(IntPtr.Zero, true) { methodCache = new Dictionary <string, Delegate>(); methodList = new Dictionary <Type, string>(); className = GetType().Name; var pNewSession = LibLoader.LoadLibrary(Path.Combine(LibraryPath, dllName)); if (pNewSession == IntPtr.Zero || pNewSession == MinusOne) { throw CreateException("Não foi possivel carregar a biblioteca."); } SetHandle(pNewSession); InitializeMethods(); }
protected override bool ReleaseHandle() { if (IsInvalid) { return(true); } var ret = LibLoader.FreeLibrary(handle); if (ret) { SetHandleAsInvalid(); } return(ret); }
public void ConnectToServer() { bool isWaitInGame = Options.Get <bool>(Options.Keys.WaitInGame); IntPtr hWnd = (IntPtr)null; if (isWaitInGame) { hWnd = LibLoader.GetForegroundWindow(); LibLoader.ShowWindow(hWnd, 0); } Debug.Log($"connecting to {IPText.text} with {LibLoader.Connect(IPText.text, isWaitInGame ? 1 : 0)}"); if (isWaitInGame) { LibLoader.ShowWindow(hWnd, 5); } }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } DontDestroyOnLoad(this); OptionCanvas.enabled = false; ConnectCanvas.enabled = false; Options.Read(); LibLoader.FileLogInit(Path.Combine(Application.dataPath, "launcher.log")); }
public void LaunchServer(bool isTest, bool useBot) { IntPtr hWnd = (IntPtr)null; bool isWaitInGame = Options.Get <bool>(Options.Keys.WaitInGame); if (isWaitInGame) { hWnd = LibLoader.GetForegroundWindow(); LibLoader.ShowWindow(hWnd, 0); } var rtn = LibLoader.LaunchServer(isTest ? 1 : 0, isWaitInGame ? 1 : 0, useBot ? 1 : 0); Debug.Log($"server launched with {rtn}"); if (isWaitInGame) { LibLoader.ShowWindow(hWnd, 5); } }
public static void Start() { LibLoader.PreLoad += LibLoader_PreLoad; LibLoader.OnLoad += LibLoader_OnLoad; LibLoader.Unload += LibLoader_Unload; Program.Invoke((Action)(() => { LibLoader.RootMethodItem.AddChild += LibHandler.MethodItem_AddChild; })); //LibLoader.Load(Assembly.GetExecutingAssembly()); AddLoadAssemblies(); string path = Environment.CurrentDirectory + "\\Plugins"; Directory.CreateDirectory(path); LibLoader.LoadDir(path); //LibLoader.Load(Assembly.GetAssembly(typeof(ClassLibrary1.Class1))); //Thread.Sleep(10000); //LibLoader.Load(Assembly.GetAssembly(typeof(ClassLibrary2.Class1))); //LibLoader.Load(Assembly.GetAssembly(typeof(ScriptLibrary.Initializer))); }
protected ACBrLibHandle(string dllName) : base(IntPtr.Zero, true) { var uri = new Uri(Assembly.GetExecutingAssembly().CodeBase); var path = Path.GetDirectoryName(!uri.IsFile ? uri.ToString() : uri.LocalPath + Uri.UnescapeDataString(uri.Fragment)); path += Environment.Is64BitProcess ? "\\ACBrLib\\x64\\" : "\\ACBrLib\\x86\\"; Environment.SetEnvironmentVariable("PATH", path); methodCache = new Dictionary <string, Delegate>(); methodList = new Dictionary <Type, string>(); className = GetType().Name; var pNewSession = LibLoader.LoadLibrary(dllName); if (pNewSession == IntPtr.Zero || pNewSession == MinusOne) { throw CreateException("Não foi possivel carregar a biblioteca."); } SetHandle(pNewSession); InitializeMethods(); }
private static void Main() { Directory.CreateDirectory("Optimization"); ProfileOptimization.SetProfileRoot("Optimization"); ProfileOptimization.StartProfile("Test"); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Инициализация платформы /// <see cref="ImageView.Initializer"/> LibLoader.Load(Assembly.GetExecutingAssembly()); //MainForm mainForm = (MainForm)LibLoader.MainController.PlatformRegister.MainWindowInstance; //MenuStrip menuStrip = (MenuStrip)LibLoader.MainController.PlatformRegister.MainMenuElement; //mainForm.Controls.Add(menuStrip); //mainForm.MainMenuStrip = menuStrip; //mainForm.HandleCreated += (_, __) => // new Thread(LibHandler.Start) { Name = "LibLoader" }.Start(); //applicationContext = new ApplicationContext(mainForm); //Application.Run(applicationContext); }
static partial void AddLoadAssemblies() { LibLoader.Load(typeof(OpenCVSupport.ImageExtensions).Assembly); }