public void StopHandlerSerializesCorrectly()
        {
            StopEventHandler.AddToDirectiveConverter();
            var directive = Utility.ExampleFileContent <IDirective>("StopEventHandler.json");
            var stop      = Assert.IsType <StopEventHandler>(directive);

            Assert.Equal(Guid.Parse("1234abcd-40bb-11e9-9527-6b98b093d166"), stop.Token);
        }
Exemplo n.º 2
0
        public App()
        {
            currentApp       = this;
            started          = new StartEventHandler(() => { });
            stopped          = new StopEventHandler(() => { });
            restarted        = new RestartEventHandler(() => { });
            authorized       = new AuthorizedEventHandler(() => { });
            stackSettingView = new List <View>();

            activationLink = "";
            InitializeComponent();

            thisTabbedPage = new TabbedPage1();
            thisTabbedPage.On <Xamarin.Forms.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(true);

            MainPage = thisTabbedPage;

            //通知(App側で一括管理)
            DependencyService.Get <INotificationService>().Regist();

            //すでに認証しているか確認
            string aToken  = "";
            string aSecret = "";
            string path    = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + accessTokenFilePath;

            if (File.Exists(path))
            {
                StreamReader readFile = new StreamReader(path, Encoding.GetEncoding("utf-16"));
                aToken  = readFile.ReadLine();
                aSecret = readFile.ReadLine();
                readFile.Close();
                t = CoreTweet.Tokens.Create(cKey, cSecret, aToken, aSecret);
                try
                {
                    UserResponse result = t.Account.VerifyCredentials();
                    t.UserId     = (long)result.Id;
                    t.ScreenName = result.ScreenName;
                }
                catch (Exception)
                {
                    t = null;
                }
            }

            if (t == null)
            {
                //認証していない場合は認証を行う。
                (getContentPage("MainBrowser") as MainBrowser).web.authorizeAPI(cKey, cSecret);
            }
            else
            {
                (getContentPage("MainBrowser") as MainBrowser).web.twitterStart();
                authorized();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 请重写自动跑迷宫的逻辑:
 /// 1、规划好机器人的探索策略;
 /// 2、规划好机器人自动停机的处理逻辑;
 /// 最终能让机器人对象一旦调用autoRun就能自动在迷宫中找到目标位置
 /// </summary>
 public override void autoRun()
 {
     //throw new NotImplementedException("未实现");
     doAfterStop += new StopEventHandler(process);
     while (path.Count > 0 )
     {
         bool isDeadEnd = true;
         foreach (var dir in (Direction[])Enum.GetValues(typeof(Direction)))
         {
             if (maze.GetGrid(currPos.GetNewPosFromDir(dir, 1)) == Maze.GridType.Unknown)
             {
                 run(dir, 1);
                 switch (sr)
                 {
                     case StopReason.arrive:
                         currPos = currPos.GetNewPosFromDir(dir, rd);
                         maze.SetGrid(currPos, Maze.GridType.Road);
                         path.Push(currPos);
                         isDeadEnd = false;
                         break;
                     case StopReason.done:
                         return;
                     case StopReason.hitWall:
                         maze.SetGrid(currPos.GetNewPosFromDir(dir, rd + 1), Maze.GridType.Wall);
                         break;
                     default:
                         break;
                 }
                 if (!isDeadEnd)
                     break;
             }
         }
         if (isDeadEnd)
             GoBack();
     }
 }
Exemplo n.º 4
0
 public static void registerStopEvent(StopEventHandler action)
 {
     currentApp.stopped += action;
 }
Exemplo n.º 5
0
 public void Handle(StopEventHandler message)
 {
     base.Stop();
 }