Esempio n. 1
0
        public static void Run(string variableName)
        {
            NWObject self   = (NWGameObject.OBJECT_SELF);
            string   script = self.GetLocalString(variableName);

            using (new Profiler("ScriptEvent." + script))
            {
                string rootNamespace   = Assembly.GetExecutingAssembly().GetName().Name;
                string scriptNamespace = rootNamespace + ".Scripts." + script;

                // Check the script cache first. If it exists, we run it.
                if (ScriptService.IsScriptRegisteredByNamespace(scriptNamespace))
                {
                    ScriptService.RunScriptByNamespace(scriptNamespace);
                    return;
                }

                // Otherwise look for a script contained by the app.
                scriptNamespace = rootNamespace + "." + script;
                Type type = Type.GetType(scriptNamespace);

                if (type == null)
                {
                    Console.WriteLine("Unable to locate type for ScriptEvent: " + script);
                    return;
                }

                IRegisteredEvent @event = Activator.CreateInstance(type) as IRegisteredEvent;
                @event?.Run();
            }
        }
Esempio n. 2
0
        public static void Run(string script)
        {
            if (!script.StartsWith("Item."))
            {
                script = "Item." + script;
            }

            using (new Profiler(nameof(ScriptEvent) + "." + script))
            {
                string rootNamespace   = Assembly.GetExecutingAssembly().GetName().Name;
                string scriptNamespace = rootNamespace + ".Scripts." + script;

                // Check the script cache first. If it exists, we run it.
                if (ScriptService.IsScriptRegisteredByNamespace(scriptNamespace))
                {
                    ScriptService.RunScriptByNamespace(scriptNamespace);
                    return;
                }

                // Otherwise look for a script contained by the app.
                scriptNamespace = rootNamespace + "." + script;
                Type type = Type.GetType(scriptNamespace);

                if (type == null)
                {
                    Console.WriteLine("Unable to locate type for ScriptItemEvent: " + script);
                    return;
                }

                IRegisteredEvent @event = Activator.CreateInstance(type) as IRegisteredEvent;
                @event?.Run();
            }
        }
Esempio n. 3
0
 public static bool RunEvent(Type type, params object[] args)
 {
     try
     {
         IRegisteredEvent @event = _container.ResolveKeyed <IRegisteredEvent>(type.ToString());
         return(@event.Run(args));
     }
     catch (Exception ex)
     {
         IErrorService errorService = _container.Resolve <IErrorService>();
         errorService.LogError(ex, type.ToString());
         throw;
     }
 }
Esempio n. 4
0
        public static void Run(string variableName)
        {
            NWObject self   = (Object.OBJECT_SELF);
            string   script = self.GetLocalString(variableName);

            using (new Profiler("LegacyJVMEvent." + script))
            {
                Type type = Type.GetType(Assembly.GetExecutingAssembly().GetName().Name + "." + script);

                if (type == null)
                {
                    Console.WriteLine("Unable to locate type for LegacyJVMEvent: " + script);
                    return;
                }

                IRegisteredEvent @event = Activator.CreateInstance(type) as IRegisteredEvent;
                @event?.Run();
            }
        }
Esempio n. 5
0
        public static void Run(string script)
        {
            if (!script.StartsWith("Item."))
            {
                script = "Item." + script;
            }

            using (new Profiler(nameof(LegacyJVMEvent) + "." + script))
            {
                Type type = Type.GetType(Assembly.GetExecutingAssembly().GetName().Name + "." + script);

                if (type == null)
                {
                    Console.WriteLine("Unable to locate type for LegacyJVMItemEvent: " + script);
                    return;
                }

                IRegisteredEvent @event = Activator.CreateInstance(type) as IRegisteredEvent;
                @event?.Run();
            }
        }
Esempio n. 6
0
        public static bool RunEvent <T>(params object[] args)
            where T : IRegisteredEvent
        {
            try
            {
                using (var scope = _container.BeginLifetimeScope())
                {
                    IRegisteredEvent @event = scope.ResolveKeyed <IRegisteredEvent>(typeof(T).ToString());
                    return(@event.Run(args));
                }
            }
            catch (Exception ex)
            {
                using (var scope = _container.BeginLifetimeScope())
                {
                    IErrorService errorService = scope.Resolve <IErrorService>();
                    errorService.LogError(ex, typeof(T).ToString());
                }

                throw;
            }
        }
Esempio n. 7
0
        public static bool RunEvent(Type type, params object[] args)
        {
            try
            {
                bool success;
                using (var scope = _container.BeginLifetimeScope())
                {
                    IRegisteredEvent @event = scope.ResolveKeyed <IRegisteredEvent>(type.ToString());
                    success = @event.Run(args);
                }

                return(success);
            }
            catch (Exception ex)
            {
                using (var scope = _container.BeginLifetimeScope())
                {
                    IErrorService errorService = scope.Resolve <IErrorService>();
                    errorService.LogError(ex, type.ToString());
                }

                throw;
            }
        }