Esempio n. 1
0
        private static void Loading_OnLoadingComplete(EventArgs args)
        {
            MainMenu.Init();

            UtilityManager.Initialize();
            Value.Init();
            var champion = Type.GetType("OKTRAIO.Champions." + Player.Instance.ChampionName);

            if (champion != null)
            {
                Console.WriteLine("[MarksmanAIO] " + Player.Instance.ChampionName + " Loaded");
                IconManager.Init();
                Champion = (AIOChampion)Activator.CreateInstance(champion);
                Events.Init();

                Value.Init();
                Champion.Init();
                //JsonSettings.Init();
                UtilityManager.Activator.LoadSpells();
                if (MainMenu.Menu["playsound"].Cast <CheckBox>().CurrentValue)
                {
                    PlayWelcome();
                }
                Chat.Print("MarksmanAIO: " + Player.Instance.ChampionName + " Loaded", Color.CornflowerBlue);
            }
            else
            {
                Chat.Print("MarksmanAIO doesn't support: " + Player.Instance.ChampionName);
            }

            Humanizer.Init();
        }
        /// <summary>
        /// Creates new instance of <see cref="IMemberCompilerProvider"/>.
        /// </summary>
        /// <param name="type">The type.</param>
        public static IMemberCompilerProvider Create(Type type)
        {
            ArgumentValidator.EnsureArgumentNotNull(type, "type");
            var concreteType = typeof(MemberCompilerProvider <>).MakeGenericType(type);

            return((IMemberCompilerProvider)Activator.CreateInstance(concreteType));
        }
Esempio n. 3
0
        /// <summary>
        /// Get module permissions
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, string> GetModulePermissionsFromTargetModule()
        {
            var fieldInfo   = typeof(TPermissionsConstants).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
            var o           = Activator.CreateInstance <TPermissionsConstants>();
            var permissions = fieldInfo
                              .ToDictionary(k => k.Name, v => v.GetValue(o).ToString());

            return(permissions);
        }
        /// <summary>
        /// Get module permissions
        /// </summary>
        /// <returns></returns>
        public virtual IEnumerable <string> GetModulePermissionsFromTargetModule()
        {
            var fieldInfo   = typeof(TPermissionsConstants).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
            var o           = Activator.CreateInstance <TPermissionsConstants>();
            var permissions = fieldInfo.Select(_ => _.GetValue(o).ToString()).ToList();

            Permissions = permissions;
            return(permissions);
        }
        public override void OnBefore(IInvocation invocation)
        {
            var validator  = (IValidator)Activator.CreateInstance(_validatorType);
            var entityType = _validatorType.BaseType.GenericTypeArguments[0];
            var entities   = invocation.Arguments.Where(arg => arg.GetType() == entityType);

            foreach (var entity in entities)
            {
                ValidationTool.FluentValidate(validator, entity);
            }
        }
Esempio n. 6
0
    public static Dictionary <string, object> GetInitialState()
    {
        Dictionary <string, object> initialStateDict = new Dictionary <string, object> ()
        {
        };

        foreach (Type enumType in enumTypes)
        {
            initialStateDict.Add(enumType.ToString(), Activator.CreateInstance(enumType));
        }
        return(initialStateDict);
    }
Esempio n. 7
0
        public IQueryable CreateQuery(Expression expression)
        {
            var elementType = Reflector.GetElementType(expression.Type) ?? expression.Type;

            try
            {
                return((IQueryable)Activator.CreateInstance(typeof(NemoQueryable <>).MakeGenericType(elementType), new object[] { this, expression }));
            }
            catch (System.Reflection.TargetInvocationException tie)
            {
                throw tie.GetBaseException();
            }
        }
Esempio n. 8
0
        private void LoadClass()
        {
            string classType = XmlUtility.ReadAttribute(node, "class");

            if (menuCommand == null && !string.IsNullOrEmpty(classType))
            {
                menuCommand = Activator.CreateInstance(owner.LoadClass(classType));
            }
            string commandType = XmlUtility.ReadAttribute(node, "event");

            if (eventType == null && !string.IsNullOrEmpty(commandType))
            {
                eventType = owner.LoadClass(commandType);
            }
        }
Esempio n. 9
0
        private static void Loading_OnLoadingComplete(EventArgs args)
        {
            var champion = Type.GetType("OKTRAIO.Champions." + Player.Instance.ChampionName);

            if (champion != null)
            {
                Console.Write("[MarksmanAIO] " + Player.Instance.ChampionName + " Loaded");
                Champion = (AIOChampion)Activator.CreateInstance(champion);
                Events.Init();
                MainMenu.Init();
                UtilityMenu.Init();
                Champion.Init();
                JsonSettings.Init();
                Utility.Activator.LoadSpells();
                Utility.Activator.Init();
                Humanizer.Init();
                SkinManagement.Init();
                if (MainMenu._menu["playsound"].Cast <CheckBox>().CurrentValue)
                {
                    PlayWelcome();
                }
                Chat.Print("MarksmanAIO: " + Player.Instance.ChampionName + " Loaded", Color.CornflowerBlue);
            }
            else
            {
                Chat.Print("MarksmanAIO doesn't support: " + Player.Instance.ChampionName);
            }

            if (RandomUlt.IsCompatibleChamp() && champion == null)
            {
                UtilityMenu.Init();
            }
            if (BaseUlt.IsCompatibleChamp())
            {
                UtilityMenu.BaseUltMenu();
                BaseUlt.Initialize();
            }
            if (RandomUlt.IsCompatibleChamp())
            {
                UtilityMenu.RandomUltMenu();
                RandomUlt.Initialize();
            }
            Value.Init();
        }
Esempio n. 10
0
        public static Expression CreateDirectEntitySetQuery(EntitySetBase entitySet)
        {
            // A hack making expression to look like regular parameter
            // (ParameterExtractor.IsParameter => true)
            var owner   = entitySet.Owner;
            var wrapper = Activator.CreateInstance(
                typeof(OwnerWrapper <>).MakeGenericType(owner.GetType()), owner);
            var wrappedOwner = Expression.Property(Expression.Constant(wrapper), "Owner");

            if (!entitySet.Field.IsDynamicallyDefined)
            {
                return(Expression.Property(wrappedOwner, entitySet.Field.UnderlyingProperty));
            }
            var indexers = owner.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
                           .Where(p => p.GetIndexParameters().Any())
                           .Select(p => p.GetGetMethod());

            return(Expression.Convert(Expression.Call(Expression.Constant(owner), indexers.Single(), new [] { Expression.Constant(entitySet.Field.Name) }), entitySet.Field.ValueType));
        }
Esempio n. 11
0
 protected override void OnClick(EventArgs e)
 {
     base.OnClick(e);
     if (menuCommand == null || eventType == null)
     {
         LoadClass();
     }
     //1,Handle ICommand
     if (menuCommand != null)
     {
         var cmd = menuCommand as ICommand;
         if (cmd != null)
         {
             cmd.Run();
         }
         var viewProvider = menuCommand as IViewProvider;
         if (viewProvider != null)
         {
             var shellLayoutView = BundleRuntime.Instance.GetFirstOrDefaultService <IShellLayoutView>();
             if (viewProvider.ViewInfo == null)
             {
                 shellLayoutView.Show(viewProvider.View);
             }
             else
             {
                 shellLayoutView.Show(viewProvider.View, viewProvider.ViewInfo);
             }
         }
     }
     //2,Handle command name
     if (!string.IsNullOrEmpty(commandName))
     {
         var commandService = BundleRuntime.Instance.GetFirstOrDefaultService <ICommandBusService>();
         commandService.PublicCommand(commandName);
     }
     //3,Handle event bus
     if (eventType != null)
     {
         var service = BundleRuntime.Instance.GetFirstOrDefaultService <IMessageBusService>();
         service.Publish(eventType, Activator.CreateInstance(eventType));
     }
 }
Esempio n. 12
0
 public void SetKeys(ColorKey[] colorKeys, AlphaKey[] alphaKeys)
 {
     if (colorKeys != null)
     {
         Array colorKeyParam = (Array)Activator.CreateInstance(s_tyGradientColorKey.MakeArrayType(), new object[] { colorKeys.Length });
         for (int i = 0; i < colorKeys.Length; ++i)
         {
             colorKeyParam.SetValue(Activator.CreateInstance(s_tyGradientColorKey, colorKeys[i].color, colorKeys[i].time), i);
         }
         s_piColorKeys.SetValue(_gradient, colorKeyParam, null);
     }
     if (alphaKeys != null)
     {
         Array alphaKeyParam = (Array)Activator.CreateInstance(s_tyGradientAlphaKey.MakeArrayType(), new object[] { alphaKeys.Length });
         for (int i = 0; i < alphaKeys.Length; ++i)
         {
             alphaKeyParam.SetValue(Activator.CreateInstance(s_tyGradientAlphaKey, alphaKeys[i].alpha, alphaKeys[i].time), i);
         }
         s_piAlphaKeys.SetValue(_gradient, alphaKeyParam, null);
     }
 }
Esempio n. 13
0
        public override Object Create(List <Object> ctorParams)
        {
            object instance = Activator.CreateInstance(ClassType, DotnetObject.toObjects(ctorParams).ToArray());

            return(new DotnetObject(instance));
        }
Esempio n. 14
0
 public void CreateInstance_no_args()
 {
     var activator = new Activator();
     var date = activator.CreateInstance(typeof(DateTime).AsRuntimeTypeInfo());
     Assert.IsInstanceOf<DateTime>(date);
 }
Esempio n. 15
0
 /// <summary>
 /// Creates an instance of the specified type using the constructor that best matches the specified parameters.
 /// </summary>
 /// 
 /// <returns>
 /// A reference to the newly created object.
 /// </returns>
 /// <param name="type">The type of object to create. </param><param name="args">An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args"/> is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked. </param><param name="activationAttributes">An array of one or more attributes that can participate in activation. This is typically an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute"/> object. The <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute"/> specifies the URL that is required to activate a remote object.  </param><exception cref="T:System.ArgumentNullException"><paramref name="type"/> is null. </exception><exception cref="T:System.ArgumentException"><paramref name="type"/> is not a RuntimeType. -or-<paramref name="type"/> is an open generic type (that is, the <see cref="P:System.Type.ContainsGenericParameters"/> property returns true).</exception><exception cref="T:System.NotSupportedException"><paramref name="type"/> cannot be a <see cref="T:System.Reflection.Emit.TypeBuilder"/>.-or- Creation of <see cref="T:System.TypedReference"/>, <see cref="T:System.ArgIterator"/>, <see cref="T:System.Void"/>, and <see cref="T:System.RuntimeArgumentHandle"/> types, or arrays of those types, is not supported.-or- <paramref name="activationAttributes"/> is not an empty array, and the type being created does not derive from <see cref="T:System.MarshalByRefObject"/>. -or-The assembly that contains <paramref name="type"/> is a dynamic assembly that was created with <see cref="F:System.Reflection.Emit.AssemblyBuilderAccess.Save"/>.-or-The constructor that best matches <paramref name="args"/> has varargs arguments.</exception><exception cref="T:System.Reflection.TargetInvocationException">The constructor being called throws an exception. </exception><exception cref="T:System.MethodAccessException">The caller does not have permission to call this constructor. </exception><exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism. </exception><exception cref="T:System.Runtime.InteropServices.InvalidComObjectException">The COM type was not obtained through <see cref="Overload:System.Type.GetTypeFromProgID"/> or <see cref="Overload:System.Type.GetTypeFromCLSID"/>. </exception><exception cref="T:System.MissingMethodException">No matching public constructor was found. </exception><exception cref="T:System.Runtime.InteropServices.COMException"><paramref name="type"/> is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered. </exception><exception cref="T:System.TypeLoadException"><paramref name="type"/> is not a valid type. </exception><filterpriority>1</filterpriority><PermissionSet><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*"/><IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess"/><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, RemotingConfiguration"/></PermissionSet>
 public static object CreateInstance(Type type, object[] args, object[] activationAttributes)
 {
     return Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance, (Binder)null, args, (CultureInfo)null, activationAttributes);
 }
Esempio n. 16
0
 /// <summary>
 /// Creates an instance of the specified type using the constructor that best matches the specified parameters.
 /// </summary>
 /// 
 /// <returns>
 /// A reference to the newly created object.
 /// </returns>
 /// <param name="type">The type of object to create. </param><param name="bindingAttr">A combination of zero or more bit flags that affect the search for the <paramref name="type"/> constructor. If <paramref name="bindingAttr"/> is zero, a case-sensitive search for public constructors is conducted. </param><param name="binder">An object that uses <paramref name="bindingAttr"/> and <paramref name="args"/> to seek and identify the <paramref name="type"/> constructor. If <paramref name="binder"/> is null, the default binder is used. </param><param name="args">An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args"/> is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked. </param><param name="culture">Culture-specific information that governs the coercion of <paramref name="args"/> to the formal types declared for the <paramref name="type"/> constructor. If <paramref name="culture"/> is null, the <see cref="T:System.Globalization.CultureInfo"/> for the current thread is used. </param><exception cref="T:System.ArgumentNullException"><paramref name="type"/> is null. </exception><exception cref="T:System.ArgumentException"><paramref name="type"/> is not a RuntimeType. -or-<paramref name="type"/> is an open generic type (that is, the <see cref="P:System.Type.ContainsGenericParameters"/> property returns true).</exception><exception cref="T:System.NotSupportedException"><paramref name="type"/> cannot be a <see cref="T:System.Reflection.Emit.TypeBuilder"/>.-or- Creation of <see cref="T:System.TypedReference"/>, <see cref="T:System.ArgIterator"/>, <see cref="T:System.Void"/>, and <see cref="T:System.RuntimeArgumentHandle"/> types, or arrays of those types, is not supported. -or-The assembly that contains <paramref name="type"/> is a dynamic assembly that was created with <see cref="F:System.Reflection.Emit.AssemblyBuilderAccess.Save"/>.-or-The constructor that best matches <paramref name="args"/> has varargs arguments.</exception><exception cref="T:System.Reflection.TargetInvocationException">The constructor being called throws an exception. </exception><exception cref="T:System.MethodAccessException">The caller does not have permission to call this constructor. </exception><exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism. </exception><exception cref="T:System.Runtime.InteropServices.InvalidComObjectException">The COM type was not obtained through <see cref="Overload:System.Type.GetTypeFromProgID"/> or <see cref="Overload:System.Type.GetTypeFromCLSID"/>. </exception><exception cref="T:System.MissingMethodException">No matching constructor was found. </exception><exception cref="T:System.Runtime.InteropServices.COMException"><paramref name="type"/> is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered. </exception><exception cref="T:System.TypeLoadException"><paramref name="type"/> is not a valid type. </exception><filterpriority>1</filterpriority><PermissionSet><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*"/><IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess"/><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, RemotingConfiguration"/></PermissionSet>
 public static object CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture)
 {
     return Activator.CreateInstance(type, bindingAttr, binder, args, culture, (object[])null);
 }