Example #1
0
        public void HandleStorageEvent(JsonElement oEvent)
        {
            var evt = new StorageEvent(oEvent);

            _log.LogTrace("Raise local storage change event.");

            StorageUpdated?.Invoke(evt);
        }
Example #2
0
        public void Update(StorageObjectsRemoveMessage message)
        {
            for (int i = 0; i < message.ObjectUIDList.Count; i++)
            {
                Objects.RemoveAll(o => o.UID == message.ObjectUIDList[i]);
            }

            StorageUpdated?.Invoke();
        }
Example #3
0
        public void Update(StorageObjectUpdateMessage message)
        {
            var obj = Objects.FirstOrDefault(f => f.UID == message.Object.ObjectUID);

            // Needs to be added
            if (obj == null)
            {
                Objects.Add(new ObjectEntry(message.Object, DataManager.Get <Items>((int)message.Object.ObjectGID)));
            }
            // Needs to be updated
            else
            {
                obj.Update(message.Object);
            }

            StorageUpdated?.Invoke();
        }
Example #4
0
        public async Task SetItem(string key, string value)
        {
            _log.LogTrace("Set {key} in local storage", key);

            try
            {
                await _interop.InvokeVoidAsync(JSNamespace + ".LocalStorage.setItem", key, value);

                StorageUpdated?.Invoke(new StorageEvent(key, null, value));
            }
            catch (JSException jsError)
            {
                var error = EnrichError.TryUnwrap(jsError);

                _log.LogError("JSError: " + error.Message);

                throw error;
            }
        }
Example #5
0
        public void Update(StorageObjectsUpdateMessage message)
        {
            for (int i = 0; i < message.ObjectList.Count; i++)
            {
                var obj = Objects.FirstOrDefault(f => f.UID == message.ObjectList[i].ObjectUID);

                // Needs to be added
                if (obj == null)
                {
                    Objects.Add(new ObjectEntry(message.ObjectList[i], DataManager.Get <Items>((int)message.ObjectList[i].ObjectGID)));
                }
                // Needs to be updated
                else
                {
                    obj.Update(message.ObjectList[i]);
                }
            }

            StorageUpdated?.Invoke();
        }
Example #6
0
        private async Task Save()
        {
            if (String.IsNullOrWhiteSpace(Storage.StorageName))
            {
                await this.pageService.DisplayAlert("Error", "Please enter a storage name.", "Ok");

                return;
            }

            if (Storage.Id == 0)
            {
                await this.storageStore.AddStorageType(Storage);

                StorageAdded?.Invoke(this, Storage);
            }
            else
            {
                await this.storageStore.UpdateStorageType(Storage);

                StorageUpdated?.Invoke(this, Storage);
            }

            await this.pageService.PopAsync();
        }
Example #7
0
        public async Task RemoveItem(string key)
        {
            await _interop.InvokeVoidAsync("window.localStorage.removeItem", key);

            StorageUpdated?.Invoke(new StorageEvent(key, null, null));
        }
Example #8
0
        public async Task Clear()
        {
            await _interop.InvokeVoidAsync("window.localStorage.clear");

            StorageUpdated?.Invoke(new StorageEvent(null, null, null));
        }
Example #9
0
        public void Update(StorageObjectRemoveMessage message)
        {
            Objects.RemoveAll(o => o.UID == message.ObjectUID);

            StorageUpdated?.Invoke();
        }
Example #10
0
        public void Update(StorageKamasUpdateMessage message)
        {
            Kamas = message.KamasTotal;

            StorageUpdated?.Invoke();
        }