Exemplo n.º 1
0
 public Task ClearCurrentConfigAsync()
 {
     return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
         currentConfig = null;
         AVClient.ApplicationSettings.Remove(CurrentConfigKey);
     }), CancellationToken.None));
 }
Exemplo n.º 2
0
        public Task <AVConfig> GetCurrentConfigAsync()
        {
            return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
                if (currentConfig == null)
                {
                    return storageController.LoadAsync().OnSuccess(t => {
                        object tmp;
                        t.Result.TryGetValue(CurrentConfigKey, out tmp);

                        string propertiesString = tmp as string;
                        if (propertiesString != null)
                        {
                            var dictionary = AVClient.DeserializeJsonString(propertiesString);
                            currentConfig = new AVConfig(dictionary);
                        }
                        else
                        {
                            currentConfig = new AVConfig();
                        }

                        return currentConfig;
                    });
                }

                return Task.FromResult(currentConfig);
            }), CancellationToken.None).Unwrap());
        }
Exemplo n.º 3
0
 public Task TestGetConfig()
 {
     return(AVConfig.GetAsync().ContinueWith(t => {
         Assert.AreEqual("testValue", t.Result["testKey"]);
         Assert.AreEqual("testValue", t.Result.Get <string>("testKey"));
     }));
 }
Exemplo n.º 4
0
        public void TestCurrentConfig()
        {
            AVConfig config = AVConfig.CurrentConfig;

            Assert.AreEqual("testValue", config["testKey"]);
            Assert.AreEqual("testValue", config.Get <string>("testKey"));
        }
        public Task ClearCurrentConfigAsync()
        {
            return taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
            currentConfig = null;

            return storageController.LoadAsync().OnSuccess(t => t.Result.RemoveAsync(CurrentConfigKey));
              }).Unwrap().Unwrap(), CancellationToken.None);
        }
Exemplo n.º 6
0
        public Task ClearCurrentConfigAsync()
        {
            return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
                currentConfig = null;

                return storageController.LoadAsync().OnSuccess(t => t.Result.RemoveAsync(CurrentConfigKey));
            }).Unwrap().Unwrap(), CancellationToken.None));
        }
Exemplo n.º 7
0
        public Task TestGetConfigCancel()
        {
            CancellationTokenSource tokenSource = new CancellationTokenSource();

            tokenSource.Cancel();
            return(AVConfig.GetAsync(tokenSource.Token).ContinueWith(t => {
                Assert.True(t.IsCanceled);
            }));
        }
Exemplo n.º 8
0
        public Task SetCurrentConfigAsync(AVConfig config)
        {
            return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
                currentConfig = config;

                var jsonObject = ((IJsonConvertible)config).ToJSON();
                var jsonString = AVClient.SerializeJsonString(jsonObject);

                AVClient.ApplicationSettings[CurrentConfigKey] = jsonString;
            }), CancellationToken.None));
        }
Exemplo n.º 9
0
        public Task SetCurrentConfigAsync(AVConfig config)
        {
            return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
                currentConfig = config;

                var jsonObject = ((IJsonConvertible)config).ToJSON();
                var jsonString = AVClient.SerializeJsonString(jsonObject);

                return storageController.LoadAsync().OnSuccess(t => t.Result.AddAsync(CurrentConfigKey, jsonString));
            }).Unwrap().Unwrap(), CancellationToken.None));
        }
Exemplo n.º 10
0
        public void TestToJSON()
        {
            AVConfig config1 = AVConfig.CurrentConfig;
            IDictionary <string, object> expectedJson = new Dictionary <string, object> {
                {
                    "params", new Dictionary <string, object> {
                        {
                            "testKey", "testValue"
                        }
                    }
                }
            };

            Assert.AreEqual(((IJsonConvertible)config1).ToJSON(), expectedJson);
        }
        public Task<AVConfig> GetCurrentConfigAsync()
        {
            return taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
            if (currentConfig == null) {
              return storageController.LoadAsync().OnSuccess(t => {
            object tmp;
            t.Result.TryGetValue(CurrentConfigKey, out tmp);

            string propertiesString = tmp as string;
            if (propertiesString != null) {
              var dictionary = AVClient.DeserializeJsonString(propertiesString);
              currentConfig = new AVConfig(dictionary);
            } else {
              currentConfig = new AVConfig();
            }

            return currentConfig;
              });
            }

            return Task.FromResult(currentConfig);
              }), CancellationToken.None).Unwrap();
        }
Exemplo n.º 12
0
        public Task <AVConfig> GetCurrentConfigAsync()
        {
            return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
                if (currentConfig == null)
                {
                    object tmp;
                    AVClient.ApplicationSettings.TryGetValue(CurrentConfigKey, out tmp);

                    string propertiesString = tmp as string;
                    if (propertiesString != null)
                    {
                        var dictionary = AVClient.DeserializeJsonString(propertiesString);
                        currentConfig = new AVConfig(dictionary);
                    }
                    else
                    {
                        currentConfig = new AVConfig();
                    }
                }

                return currentConfig;
            }), CancellationToken.None));
        }
        public Task SetCurrentConfigAsync(AVConfig config)
        {
            return taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
            currentConfig = config;

            var jsonObject = ((IJsonConvertible)config).ToJSON();
            var jsonString = AVClient.SerializeJsonString(jsonObject);

            return storageController.LoadAsync().OnSuccess(t => t.Result.AddAsync(CurrentConfigKey, jsonString));
              }).Unwrap().Unwrap(), CancellationToken.None);
        }
 public Task ClearCurrentConfigInMemoryAsync()
 {
     return taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
     currentConfig = null;
       }), CancellationToken.None);
 }
Exemplo n.º 15
0
 public Task ClearCurrentConfigInMemoryAsync()
 {
     return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
         currentConfig = null;
     }), CancellationToken.None));
 }