Пример #1
0
        static void Main(string[] args)
        {
            // run as console app
            if (Environment.UserInteractive)
            {
                SpellBotClient spellBot = new SpellBotClient();

                // start it
                spellBot.Start(true);
            }

            // run as windows service
            else
            {
                // set workpath to .exe path (not default for services)
                // very important
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

                // create bot-service wrapper
                ServiceBase serviceWrap =
                    new BotServiceWrapper <GameTick, ResourceManager, DataController, SpellBotConfig, SpellBotClient>();

                // run service
                ServiceBase.Run(serviceWrap);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            string configFile    = SpellBotConfig.CONFIGFILE_SPELLBOT;
            string configFileAlt = SpellBotConfig.CONFIGFILE_SPELLBOT_ALT;

            // try parse config parameter
            string cmdConfig = Config.GetFilenameFromCmdArgs(args);

            // overwrite with user specified config
            if (cmdConfig != null)
            {
                configFile = configFileAlt = cmdConfig;
            }

            // run as console app
            if (Environment.UserInteractive)
            {
                SpellBotClient spellBot = new SpellBotClient();

                // start it
                spellBot.Start(true, configFile, configFileAlt);
            }

            // run as windows service
            else
            {
                // set workpath to .exe path (not default for services)
                // very important
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

                // create bot-service wrapper
                ServiceBase serviceWrap =
                    new BotServiceWrapper <GameTick, ResourceManager, DataController, SpellBotConfig, SpellBotClient>(
                        configFile, configFileAlt);

                // run service
                ServiceBase.Run(serviceWrap);
            }
        }