예제 #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();
            }
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #11
0
        public static bool ContainsKey(AppProperty key)
        {
            Application myApp = Application.Current;

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