public static void OnLoad(EventArgs args) { try { Game.PrintChat("[00:01] <font color='#CC0000'>BATTLERITE!</font> Join http://aimtec.io for Battlerite scripts! SUPER FUN"); var plugins = Assembly.GetExecutingAssembly() .GetTypes() .Where(x => typeof(IPlugin).IsAssignableFrom(x) && !x.IsInterface) .Select(x => GetActivator <IPlugin>(x.GetConstructors().First())(null)); var menu = new Menu("ElEasy", "ElEasy", true); foreach (var plugin in plugins) { if (plugin.ToString().ToLower().Contains(Player.ChampionName.ToLower())) //this is some real broscience { plugin.CreateMenu(menu); plugin.Load(); } } menu.AddItem(new MenuItem("Versionnumber", $"Version: {ScriptVersion}")); menu.AddItem(new MenuItem("by.jQuery", "Created by jQuery")); menu.AddToMainMenu(); Menu = menu; } catch (Exception e) { Console.WriteLine("An error occurred: '{0}'", e); } }
public static void OnLoad() { try { var plugins = Assembly.GetExecutingAssembly() .GetTypes() .Where(x => typeof(IPlugin).IsAssignableFrom(x) && !x.IsInterface) .Select(x => GetActivator <IPlugin>(x.GetConstructors().First())(null)); var menu = new Menu("ElEasy", "ElEasy", true); foreach (var plugin in plugins) { if (plugin.ToString().ToLower().Contains(Player.ChampionName.ToLower())) //this is some real broscience { plugin.CreateMenu(menu); plugin.Load(); } } menu.AddItem(new MenuItem("Versionnumber", $"Version: {ScriptVersion}")); menu.AddItem(new MenuItem("by.jQuery", "Created by jQuery")); menu.AddToMainMenu(); Menu = menu; } catch (Exception e) { Console.WriteLine("An error occurred: '{0}'", e); } }
/// <summary> /// Creates an instance of the specified type. /// </summary> /// <param name="type">The <see cref="Type" /> of the result object.</param> /// <param name="args">An array of constructor arguments.</param> public static object Activate(Type type, params object[] args) { Requires.NotNull(type, nameof(type)); return(args.Any() ? GetActivator(type, args)(args) : GetActivator(type)()); }
public static T New <T>(this Type type, params object[] args) { Type[] argTypes = args.Select(a => a.GetType()).ToArray(); var ctor = type.GetConstructor(argTypes); return(GetActivator <T>(ctor)(args)); }
public T GetInstance <T>(params object[] constructorArguments) { if (constructorArguments != null && constructorArguments.Length > 0) { var types = (from c in constructorArguments select c.GetType()).ToArray(); return((T)GetActivator(typeof(T), types)(constructorArguments)); } else { return(Activator.CreateInstance <T>()); } }
public static T Create <T>(Type[] types, params object[] args) { if (types.Length != args.Length) { throw new TypeLoadException(); } var ctor = typeof(T).GetConstructor(types); if (ctor == null) { throw new MissingMethodException(nameof(T), ".ctor"); } return(GetActivator <T>(ctor)(args)); }
/// <summary> /// Creates the type of the generic. /// </summary> /// <param name="type">The type.</param> /// <param name="arguments">The arguments.</param> /// <param name="parameters">The parameters.</param> /// <returns>System.Object.</returns> public static object CreateGenericType(Type type, Type[] arguments, params object[] parameters) { Type genericType = type.MakeGenericType(arguments); object obj; if (parameters != null && parameters.Count() > 0) { obj = GetActivator(genericType, parameters.Select(p => p.GetType()))(parameters); } else { obj = GetActivator(genericType)(); } return(obj); }
public static void OnLoad(EventArgs args) { try { var plugins = Assembly.GetExecutingAssembly() .GetTypes() .Where(x => typeof(IPlugin).IsAssignableFrom(x) && !x.IsInterface) .Select(x => GetActivator <IPlugin>(x.GetConstructors().First())(null)); FrozenGJ.Info("EL工具集"); var menu = new Menu("ElUtilitySuite", "ElUtilitySuite", true).SetFontStyle(FontStyle.Bold, Color.GreenYellow); foreach (var plugin in plugins) { plugin.CreateMenu(menu); plugin.Load(); } foreach (var ally in HeroManager.Allies) { IncomingDamageManager.AddChampion(ally); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(@"[ELUTILITYSUITE] loaded champions: {0}", ally.ChampionName); } Console.ForegroundColor = ConsoleColor.White; menu.AddItem(new MenuItem("seperator1", "")); menu.AddItem(new MenuItem("usecombo", "Combo (Active)").SetValue(new KeyBind(32, KeyBindType.Press))); menu.AddItem(new MenuItem("seperator", "")); menu.AddItem(new MenuItem("Versionnumber", $"Version: {ScriptVersion}")); menu.AddItem(new MenuItem("by.jQuery", "jQuery / ChewyMoon")); menu.AddToMainMenu(); Menu = menu; } catch (Exception e) { Console.WriteLine(@"An error occurred: '{0}'", e); } }
public static void OnLoad(EventArgs args) { try { var plugins = Assembly.GetExecutingAssembly() .GetTypes() .Where(x => typeof(IPlugin).IsAssignableFrom(x) && !x.IsInterface) .Select(x => GetActivator <IPlugin>(x.GetConstructors().First())(null)); var menu = new Menu("ElUtilitySuite", "ElUtilitySuite", true).SetFontStyle(FontStyle.Bold, Color.GreenYellow); foreach (var plugin in plugins) { plugin.CreateMenu(menu); plugin.Load(); } foreach (var ally in HeroManager.Allies) { IncomingDamageManager.AddChampion(ally); } Game.PrintChat("[00:01] <font color='#CC0000'>BATTLERITE!</font> Join http://aimtec.io for Battlerite scripts! SUPER FUN"); menu.AddItem(new MenuItem("seperator1", "")); menu.AddItem(new MenuItem("usecombo", "Combo (Active)").SetValue(new KeyBind(32, KeyBindType.Press))); menu.AddItem(new MenuItem("seperator", "")); menu.AddItem(new MenuItem("Versionnumber", $"Version: {ScriptVersion}")); menu.AddItem(new MenuItem("by.jQuery", "jQuery / ChewyMoon")); menu.AddToMainMenu(); Menu = menu; } catch (Exception e) { Console.WriteLine(@"An error occurred: '{0}'", e); } }
public static T Create <T>(ConstructorInfo CI, params object[] Params) { return(GetActivator <T>(CI)(Params)); }
private object CreateFromArgs(params object[] args) { return(GetActivator(GenerateTypeKey(args), args)(args)); }
public static EventEnvelope CreateEventEnvelope(this object content, string aggregateId, int version) => (GetActivator(content.GetType())(aggregateId, version, content) as EventEnvelope) !;
static object Create(Type type, params object[] args) { return(args.Any() ? GetActivator(type, args)(args) : GetActivator(type)()); }
public static void OnLoad() { try { var plugins = Assembly.GetExecutingAssembly().GetTypes().Where(x => typeof(IPlugin).IsAssignableFrom(x) && !x.IsInterface).Select(x => GetActivator <IPlugin>(x.GetConstructors().First())(null)); menu = MainMenu.AddMenu("ElUtilitySuite", "ElUtilitySuite"); menu.AddSeparator(); menu.Add("usecombo", new KeyBind("Combo (Active)", false, KeyBind.BindTypes.HoldActive, 32)); menu.AddSeparator(); foreach (var plugin in plugins) { plugin.CreateMenu(menu); plugin.Load(); } Menu = menu; } catch (Exception e) { Console.WriteLine("An error occurred: '{0}'", e); } }
public static object NewInstance(Type type, params object[] args) { return(GetActivator(type)(args)); }
public static void OnLoad() { try { var plugins = Assembly.GetExecutingAssembly().GetTypes().Where(x => typeof(IPlugin).IsAssignableFrom(x) && !x.IsInterface).Select(x => GetActivator <IPlugin>(x.GetConstructors().First())(null)); var menu = MainMenu.AddMenu("ElUtilitySuite", "ElUtilitySuite"); foreach (var plugin in plugins) { plugin.CreateMenu(menu); plugin.Load(); } foreach (var ally in HeroManager.Allies) { IncomingDamageManager.AddChampion(ally); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(@"[ELUTILITYSUITE] loaded champions: {0}", ally.ChampionName); } Console.ForegroundColor = ConsoleColor.White; Menu = menu; } catch (Exception e) { Console.WriteLine(@"An error occurred: '{0}'", e); } }
/* <챔피언 어셈 확장하기> * 1. 일단 독립 프로젝트로 만들던가, 첨부터 가져오던가 하고... * 2. 기존 프로젝트의 OnLoad() 함수이름 변경: public void Load() * 3. 기존 프로젝트의 메뉴제작 함수 이름 변경, 혹은 신규 생성: public void CreateMenu() * 4. 기존 프로젝트의 internal class 이름 변경: internal class <Champion Name> : IPlugin * 5. OKTW 등 공통 모듈은 Root 에 namespace 변경하여 포함: namespace JinxsSupport { * 이렇게 하면, 기존에 독립적으로 동작하던 어셈을 통합버전으로 합칠 수 있음. 가장 간단한 형태의 멀티 어셈! * Support Mode 등 공통 모드는 중앙에 포함시키기... */ public static void OnLoad(EventArgs args) { try { menu = new Menu("Support Mode", "SupportMode", true).SetFontStyle(System.Drawing.FontStyle.Regular, SharpDX.Color.GreenYellow); menu.AddItem(new MenuItem("enabled", "Enabled").SetValue(true)).Permashow(true, "Support Mode"); PrintChat("<font color=\"#FFFFFF\" >Version " + Assembly.GetExecutingAssembly().GetName().Version + "</font>"); #if true // 동작 확인 필요 Menu rootMenu = Menu.GetMenu("LeagueSharp.Common", "LeagueSharp.Common"); //rootMenu.Item("TargetingMode").GetValue<StringList>().SelectedIndex // 해당값을 읽어올때 if (rootMenu != null) { string strMode = Enum.GetName(typeof(TargetingMode), rootMenu.Item("TargetingMode").GetValue <StringList>().SelectedIndex); PrintChat(string.Format("Current Targeting Mode: {0}", strMode)); if (Player.CharData.BaseSkinName.ToLower() == "sivir" || Player.CharData.BaseSkinName.ToLower() == "jhin" || Player.CharData.BaseSkinName.ToLower() == "kalista" || Player.CharData.BaseSkinName.ToLower() == "drmundo" || Player.CharData.BaseSkinName.ToLower() == "tristana") { if (rootMenu.Item("TargetingMode").GetValue <StringList>().SelectedIndex != (int)TargetingMode.LessAttack) { rootMenu.Item("TargetingMode").SetValue(new StringList(Enum.GetNames(typeof(TargetingMode)), (int)TargetingMode.LessAttack)); PrintChat(string.Format("Targeting Mode Changed: {0}", Enum.GetName(typeof(TargetingMode), rootMenu.Item("TargetingMode").GetValue <StringList>().SelectedIndex))); } } else if (Player.CharData.BaseSkinName.ToLower() == "bard" || Player.CharData.BaseSkinName.ToLower() == "thresh" || Player.CharData.BaseSkinName.ToLower() == "alistar" || Player.CharData.BaseSkinName.ToLower() == "lulu" || Player.CharData.BaseSkinName.ToLower() == "nami" || Player.CharData.BaseSkinName.ToLower() == "blitzcrank" || Player.CharData.BaseSkinName.ToLower() == "katarina" || Player.CharData.BaseSkinName.ToLower() == "soraka") { if (rootMenu.Item("TargetingMode").GetValue <StringList>().SelectedIndex != (int)TargetingMode.LessCast) { rootMenu.Item("TargetingMode").SetValue(new StringList(Enum.GetNames(typeof(TargetingMode)), (int)TargetingMode.LessCast)); PrintChat(string.Format("Setup Targeting Mode: {0}", Enum.GetName(typeof(TargetingMode), rootMenu.Item("TargetingMode").GetValue <StringList>().SelectedIndex))); } if (Player.CharData.BaseSkinName.ToLower() != "katarina") { menu.AddToMainMenu(); Orbwalking.BeforeAttack += BeforeAttack; } } else { rootMenu.Item("TargetingMode").SetValue(new StringList(Enum.GetNames(typeof(TargetingMode)), (int)TargetingMode.AutoPriority)); PrintChat(string.Format("Default Targeting Mode: {0}", Enum.GetName(typeof(TargetingMode), rootMenu.Item("TargetingMode").GetValue <StringList>().SelectedIndex))); } } #endif var plugins = Assembly.GetExecutingAssembly() .GetTypes() .Where(x => typeof(IPlugin).IsAssignableFrom(x) && !x.IsInterface) .Select(x => GetActivator <IPlugin>(x.GetConstructors().First())(null)); foreach (var plugin in plugins) { if (plugin.ToString().ToLower().Contains(Player.CharData.BaseSkinName.ToLower())) { plugin.Load(); // 각 인터페이스 클래스(챔피언)는 Load() 함수 필요 plugin.CreateMenu(); // 각 인터페이스 클래스(챔피언)는 CreateMenu() 항목을 가져야 함. } } Game.OnUpdate += OnUpdate; } catch (Exception e) { Console.WriteLine("An error occurred: '{0}'", e); } }