Beispiel #1
0
        public static Task CreateDirectory(this SexyDatabase db, DirectoryInfo directory)
        {
            var completionSource = new TaskCompletionSource <object>();

            Action <IPropertyChanged> globalChanged = null;

            globalChanged = changed =>
            {
                db.GlobalChanged -= globalChanged;
                completionSource.SetResult(null);
            };
            db.GlobalChanged += globalChanged;
            directory.Create();
            return(completionSource.Task.ContinueWith(async => db.WaitForIdle()));
        }
Beispiel #2
0
        public static Task EditFile(this SexyDatabase db, FileInfo file, string value)
        {
            var completionSource = new TaskCompletionSource <object>();

            Action <IPropertyChanged> globalChanged = null;

            globalChanged = changed =>
            {
                db.GlobalChanged -= globalChanged;
                completionSource.SetResult(null);
            };
            db.GlobalChanged += globalChanged;
            File.WriteAllText(file.FullName, value);
            return(completionSource.Task.ContinueWith(async => db.WaitForIdle()));
        }