示例#1
0
        protected async void  CheckLogin()
        {
            IFileReadWrite  fileReadWrite = Xamarin.Forms.DependencyService.Get <IFileReadWrite>();
            LoginUserDetail serialized    = new LoginUserDetail();
            string          userDetails   = await fileReadWrite.ReadFromFile();

            if (string.IsNullOrEmpty(userDetails))
            {
                var firstPage = new NavigationPage(new LoginPage());
                MainPage = firstPage;
            }
            else
            {
                serialized = JsonConvert.DeserializeObject <LoginUserDetail>(userDetails);
                if (serialized == null)
                {
                    var firstPage = new NavigationPage(new LoginPage());
                    MainPage = firstPage;
                }
                else
                {
                    var firstPage = new NavigationPage(new MainMasterPage());
                    MainPage = firstPage;
                }
            }
        }
示例#2
0
        public async Task <LoginUserDetail> ReadFromJsonFile()
        {
            LoginUserDetail deserialized = new LoginUserDetail();

            try
            {
                deserialized = JsonConvert.DeserializeObject <LoginUserDetail>(await fileReadWrite.ReadFromFile());

                if (deserialized == null)
                {
                    deserialized = new LoginUserDetail();
                }
            }
            catch (Exception ex)
            {
                deserialized = new LoginUserDetail();
            }

            return(deserialized);
        }