예제 #1
0
        public new async Task Storage()
        {
            try
            {
                EncryCodeSecretScribe encryCodeSecretScribe = new EncryCodeSecretScribe()
                {
                    Name       = Name,
                    ComfirmKey = ComfirmKey,
                    Str        = Str
                };

                string      str = "data.encry";
                StorageFile file;
                try
                {
                    file = await EncryCodeFolder.GetFileAsync(str);
                }
                catch (FileNotFoundException)
                {
                    file = await EncryCodeFolder.CreateFileAsync(str);
                }

                str = JsonConvert.SerializeObject(encryCodeSecretScribe);
                await FileIO.WriteTextAsync(file, str);

                OnStorage?.Invoke(this, true);
            }
            catch (Exception)
            {
                OnStorage?.Invoke(this, false);
            }
        }
예제 #2
0
        public async Task Read()
        {
            try
            {
                string str  = "data.encry";
                var    file = await EncryCodeFolder.GetFileAsync(str);

                str = await FileIO.ReadTextAsync(file);

                var json = JsonSerializer.Create();
                EncryCodeSecretScribe encryCodeSecretScribe =
                    json.Deserialize <EncryCodeSecretScribe>(new JsonTextReader(new StringReader(str)));
                //EncryCodeSecretScribe = encryCodeSecretScribe;
                Name       = encryCodeSecretScribe.Name;
                ComfirmKey = encryCodeSecretScribe.ComfirmKey;
                Str        = encryCodeSecretScribe.Str;
                OnRead?.Invoke(this, true);
            }
            catch (Exception)
            {
                OnRead?.Invoke(this, false);
            }
        }