/// <summary>
        /// Update the data associated with the input key if and only if the passed version matches the currently stored version. This method is safe in the face of concurrent writes. Maximum per-key size is 128KB.
        /// Documentation https://developers.google.com/appstate/v1/reference/states/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AppState service.</param>
        /// <param name="stateKey">The key for the data to be retrieved.</param>
        /// <param name="body">A valid AppState v1 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>WriteResultResponse</returns>
        public static WriteResult Update(AppStateService service, int stateKey, UpdateRequest body, StatesUpdateOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Building the initial request.
                var request = service.States.Update(body, stateKey);

                // Applying optional parameters to the request.
                request = (StatesResource.UpdateRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request States.Update failed.", ex);
            }
        }
Example #2
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            using (var scope = App.Container.BeginLifetimeScope())
            {
                worldStateService = scope.Resolve <AppStateService>();
            }
        }
        protected async Task OnButtonSubmitAsync()
        {
            try
            {
                forecast = await weatherServices.GetWeatherForcastByEnteredZip(currentWeather.ZipCode);

                await AppStateService.Set(new AppState { Lat = forecast.Coord.Lat, Lon = forecast.Coord.Lon });
            }
            catch (Exception)
            {
                toastService.ShowError("Zipcode could not be found. Please try again.");
            }
        }
        public void Should_return_preferences_object()
        {
            var state = new AppState()
            {
                CollectionModsSearchTerm = "test"
            };
            var storage = new Mock <IStorageProvider>();

            storage.Setup(s => s.GetAppState()).Returns(state);

            var service = new AppStateService(storage.Object, new Mock <IMapper>().Object);
            var result  = service.Get();

            result.Should().Be(state);
        }
        protected override async Task OnInitializedAsync()
        {
            try
            {
                AppStateService.OnChange += StateHasChanged;
                currentWeather.ZipCode    = 45013;
                forecast = await weatherServices.GetWeatherForcastByEnteredZip(currentWeather.ZipCode);

                await AppStateService.Set(new AppState { Lat = forecast.Coord.Lat, Lon = forecast.Coord.Lon });
            }
            catch (Exception)
            {
                toastService.ShowError("Error occured when loading...");
            }
        }
        public void Should_set_preferences_object()
        {
            IAppState setState = null;
            var       storage  = new Mock <IStorageProvider>();

            storage.Setup(s => s.SetAppState(It.IsAny <IAppState>())).Returns <IAppState>((p) =>
            {
                setState = p;
                return(true);
            });

            var state   = new AppState();
            var service = new AppStateService(storage.Object, new Mock <IMapper>().Object);

            service.Save(state);
            setState.Should().Be(state);
        }
        /// <summary>
        /// Deletes a key and the data associated with it. The key is removed and no longer counts against the key quota. Note that since this method is not safe in the face of concurrent modifications, it should only be used for development and testing purposes. Invoking this method in shipping code can result in data loss and data corruption.
        /// Documentation https://developers.google.com/appstate/v1/reference/states/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AppState service.</param>
        /// <param name="stateKey">The key for the data to be retrieved.</param>
        public static void Delete(AppStateService service, int stateKey)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.States.Delete(stateKey).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request States.Delete failed.", ex);
            }
        }
Example #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            InitNotificationChannel();

            SetContentView(Resource.Layout.activity_dashboard);

            using (var scope = App.Container.BeginLifetimeScope())
            {
                appStateService = scope.Resolve <AppStateService>();
            }

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar_dashboard);

            SetSupportActionBar(toolbar);


            var viewPager = FindViewById <ViewPager>(Resource.Id.pager_main_dashboard);

            dashboardPagerAdapter = new DashboardPagerAdapter(
                new List <StatsFragment>()
            {
                new CommonStatsFragment(),
                new CetusStatsFragment(),
                new VallisStatsFragment(),
                new FissureStatsFragment(),
                new InvasionStatsFragment()
            },
                SupportFragmentManager);
            viewPager.Adapter            = dashboardPagerAdapter;
            viewPager.OffscreenPageLimit = 4;

            var tab = FindViewById <Widget.TabLayout>(Resource.Id.tab_main_dashboard);

            tab.SetupWithViewPager(viewPager);
        }
        /// <summary>
        /// Lists all the states keys, and optionally the state data.
        /// Documentation https://developers.google.com/appstate/v1/reference/states/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AppState service.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>ListResponseResponse</returns>
        public static ListResponse List(AppStateService service, StatesListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Building the initial request.
                var request = service.States.List();

                // Applying optional parameters to the request.
                request = (StatesResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request States.List failed.", ex);
            }
        }
Example #10
0
 public FeedController(BlogService blogService, AppStateService appStateService)
 {
     this.blogService     = blogService;
     this.appStateService = appStateService;
 }
Example #11
0
 public DeviceController(AppStateService appStateService)
 {
     _appStateService = appStateService;
 }