Esempio n. 1
0
        public static async Task Clear(AppProperty key)
        {
            Application myApp = Application.Current;
            bool        check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                myApp.Properties.Remove(key.ToString());
                await myApp.SavePropertiesAsync();
            }
        }
Esempio n. 2
0
        public static async Task <string> GetValue(AppProperty key)
        {
            Application myApp = Application.Current;
            bool        check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                var property = myApp.Properties[key.ToString()];
                return((string)property);
            }

            return(default(string));
        }
Esempio n. 3
0
        public static async Task <T> GetValue <T>(AppProperty key) where T : struct
        {
            Application myApp = Application.Current;
            bool        check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                var property = myApp.Properties[key.ToString()];
                return((T)property);
            }

            return(default(T));
        }
Esempio n. 4
0
        public static async Task <bool> AddReplaceJsonToSecureStorage <T>(AppProperty key, T value)
        {
            bool check = await ContainsSecureStorageKey(key.ToString());

            if (check)
            {
                RemoveValueFromSecureStorage(key.ToString());
            }

            string json;

            json = JsonConvert.SerializeObject(value);

            return(await SetValueToSecureStorage(key.ToString(), json));
        }
Esempio n. 5
0
        public static async Task AddReplaceValue <T>(AppProperty key, T value) where T : struct
        {
            Application myApp = Application.Current;

            bool check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                myApp.Properties.Remove(key.ToString());
            }

            myApp.Properties.Add(key.ToString(), value);

            await myApp.SavePropertiesAsync();
        }
Esempio n. 6
0
        public static async Task AddReplaceBinary <T>(AppProperty key, T value) where T : class
        {
            var bytes = SerialiserHelper.ToBytes(value);

            Application myApp = Application.Current;

            bool check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                myApp.Properties.Remove(key.ToString());
            }

            myApp.Properties.Add(key.ToString(), bytes);

            await myApp.SavePropertiesAsync();
        }
Esempio n. 7
0
        public static async Task AddReplaceJson <T>(AppProperty key, T value)
        {
            Application myApp = Application.Current;

            bool check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                myApp.Properties.Remove(key.ToString());
            }

            string json;

            json = JsonConvert.SerializeObject(value);

            myApp.Properties.Add(key.ToString(), json);
            await myApp.SavePropertiesAsync();
        }
Esempio n. 8
0
        public static T Get <T>(AppProperty key)
        {
            Application myApp = Application.Current;
            bool        check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                var property = myApp.Properties[key.ToString()];
                if (property is null)
                {
                    Clear(key);
                    return(default(T));
                }

                return((T)property);
            }

            return(default(T));
        }
Esempio n. 9
0
        public static async Task <T> GetJson <T>(AppProperty key) where T : class
        {
            Application myApp = Application.Current;
            bool        check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                var property = myApp.Properties[key.ToString()] as string;
                if (string.IsNullOrEmpty(property))
                {
                    await Clear(key);

                    return(default(T));
                }

                var result = JsonConvert.DeserializeObject <T>(property);
                return(result);
            }

            return(default(T));
        }
Esempio n. 10
0
        public static async Task <T> GetBinary <T>(AppProperty key) where T : class
        {
            Application myApp = Application.Current;
            bool        check = myApp.Properties.ContainsKey(key.ToString());

            if (check)
            {
                var property = myApp.Properties[key.ToString()];
                if (property is null)
                {
                    await Clear(key);

                    return(default(T));
                }

                var result = SerialiserHelper.FromBytes <T>((byte[])property);
                return(result);
            }

            return(default(T));
        }
Esempio n. 11
0
        public static bool ContainsKey(AppProperty key)
        {
            Application myApp = Application.Current;

            return(myApp.Properties.ContainsKey(key.ToString()));
        }