コード例 #1
0
ファイル: ConsoleUI.cs プロジェクト: WildMachine/DoormatBot
        void SelectSite()
        {
            DiceBot.CompileSites();
            string Sites   = "";
            int    counter = 1;

            foreach (SitesList x in Doormat.Sites)
            {
                Sites += string.Format("{0}) {1}\n", counter++, x.Name);
            }
            while (true)
            {
                Console.WriteLine("Which site would you like to use? Enter the correspondiong number.");
                Console.WriteLine(Sites);
                string input       = Console.ReadLine();
                int    selectedval = 0;
                if (int.TryParse(input, out selectedval))
                {
                    if (selectedval > 0 && selectedval <= Doormat.Sites.Count)
                    {
                        SitesList selected = Doormat.Sites[selectedval - 1];
                        DiceBot.CurrentSite = Activator.CreateInstance(selected.SiteType()) as DoormatCore.Sites.BaseSite;


                        SelectCurrency();
                        break;
                    }
                }
            }
        }
コード例 #2
0
        public Task <object> CreateInstance(IDictionary <string, object> input)
        {
            using (StreamWriter x = File.AppendText("test.txt"))
            {
                x.WriteLine(input);
                foreach (PropertyInfo y in input.GetType().GetProperties())
                {
                    x.WriteLine(y.Name);
                }
                x.WriteLine(input["OnGameChanged"]);
            }
            if (Instance == null)
            {
                Logger.LoggingLevel     = 6;
                Instance                = new Doormat();
                Callbacks               = new Dictionary <string, Func <object, Task <object> > >();
                Instance.OnGameChanged += Instance_OnGameChanged;
                Callbacks.Add("OnGameChanged", (Func <object, Task <object> >)input["OnGameChanged"]);
                Instance.OnSiteAction += Instance_OnSiteAction;
                Callbacks.Add("OnSiteAction", (Func <object, Task <object> >)input["OnSiteAction"]);
                Instance.OnSiteChat += Instance_OnSiteChat;
                Callbacks.Add("OnSiteChat", (Func <object, Task <object> >)input["OnSiteChat"]);
                Instance.OnSiteBetFinished += Instance_OnSiteDiceBetFinished;
                Callbacks.Add("OnSiteDiceBetFinished", (Func <object, Task <object> >)input["OnSiteDiceBetFinished"]);
                Instance.OnSiteError += Instance_OnSiteError;
                Callbacks.Add("OnSiteError", (Func <object, Task <object> >)input["OnSiteError"]);
                Instance.OnSiteLoginFinished += Instance_OnSiteLoginFinished;
                Callbacks.Add("OnSiteLoginFinished", (Func <object, Task <object> >)input["OnSiteLoginFinished"]);
                Instance.OnSiteNotify += Instance_OnSiteNotify;
                Callbacks.Add("OnSiteNotify", (Func <object, Task <object> >)input["OnSiteNotify"]);
                Instance.OnSiteRegisterFinished += Instance_OnSiteRegisterFinished;
                Callbacks.Add("OnSiteRegisterFinished", (Func <object, Task <object> >)input["OnSiteRegisterFinished"]);
                Instance.OnSiteStatsUpdated += Instance_OnSiteStatsUpdated;
                Callbacks.Add("OnSiteStatsUpdated", (Func <object, Task <object> >)input["OnSiteStatsUpdated"]);
                Instance.LoadPersonalSettings("personalsettings.json");
                Instance.LoadBetSettings("betsettings.json");
                Instance.CompileSites();
            }
            //Instance.Sites = null;
            Logger.DumpLog("Finished creating instance, creating task and returning", 6);
            Task <object> taskA = new Task <object>(() => (Instance));

            //taskA.Start();
            taskA.RunSynchronously();
            Logger.DumpLog("Finished creating instance, returning", 6);
            return(taskA);
        }