Exemplo n.º 1
0
 public async Task <bool> Delete(string fileName)
 {
     if (!await _applicationDataHelper.FileExists(fileName))
     {
         return(true);
     }
     return(await _applicationDataHelper.DeleteFile(fileName));
 }
Exemplo n.º 2
0
        async Task _load()
        {
            using (var l = await _saveLock.LockAsync())
            {
                var file = _getFileName();
                if (!await _localStorage.FileExists(file))
                {
                    return;
                }

                var ser = await _localStorage.LoadString(file);

                if (string.IsNullOrWhiteSpace(ser))
                {
                    return;
                }

                var loadedState = _entitySerialiser.Deserialise <List <XFlowState> >(ser);

                if (loadedState == null || loadedState.Count == 0)
                {
                    return;
                }

                foreach (var item in loadedState)
                {
                    item.ParentFlow = this;
                    if (string.IsNullOrWhiteSpace(item.StageId))
                    {
                        Debug.WriteLine("Dud stage id from saved item, ignoring");
                        continue;
                    }

                    if (_stages.FirstOrDefault(_ => _.StageId == item.StageId) == null)
                    {
                        Debug.WriteLine("Warning ** Missing stage when loading workflow state: " + item.StageId);
                        continue;
                    }

                    if (item.State == XFlowStates.InProgress)
                    {
                        //this item was processing when hte app quit... set it to wiating to run to try again
                        item.State = XFlowStates.WaitingToStart;
                    }

                    _state.Add(item);
                }
            }

            await _save();
        }
Exemplo n.º 3
0
        async void _doThings()
        {
            var fileName = "something\\someting\\\\SomethuingElse\\tes.dat";

            await _storage.SaveString(fileName, "Testing123");

            var fileData = await _storage.LoadString(fileName);

            var fileExists = await _storage.FileExists(fileName);

            await _storage.DeleteFile(fileName);

            var fileExistsAFter = await _storage.FileExists(fileName);

            int count = 0;

            await Task.Delay(4000);

            DynamicViewModel = CreateContentModel <FirstDynamicViewModel>();

            await Task.Delay(2000);

            DynamicViewModel = null;

            return;


            while (count < 3)
            {
                await Task.Delay(3000);

                if (DynamicViewModel is FirstDynamicViewModel)
                {
                    DynamicViewModel = CreateContentModel <SecondDynamicViewModel>();
                }
                else
                {
                    DynamicViewModel = CreateContentModel <FirstDynamicViewModel>();
                }
                count++;
            }

            DynamicViewModel = null;


            count = 0;

            while (count < 3)
            {
                await Task.Delay(3000);

                if (DynamicViewModel is FirstDynamicViewModel)
                {
                    DynamicViewModel = CreateContentModel <SecondDynamicViewModel>();
                }
                else
                {
                    DynamicViewModel = CreateContentModel <FirstDynamicViewModel>();
                }
                count++;
            }

            DynamicViewModel = null;
        }