Пример #1
0
        public IIOResult <string> Save <T>(T o)
        {
            var dialog = new SaveFileDialog {
                Filter = "JSON (*.json)|*.json"
            };
            var result = dialog.ShowDialog();

            return(result.HasValue && result.Value
                ? IOResult <string> .Complete(Save(o, dialog.FileName))
                : IOResult <string> .Cancel());
        }
Пример #2
0
        public IIOResult <T> Load <T>(T target) where T : class
        {
            var dialog = new OpenFileDialog {
                Filter = "JSON (*.json)|*.json"
            };
            var result = dialog.ShowDialog();

            return(result.HasValue && result.Value
                ? IOResult <T> .Complete(Load(target, dialog.FileName))
                : IOResult <T> .Cancel());
        }
Пример #3
0
        public IIOResult <string> Load()
        {
            var dialog = new OpenFileDialog {
                Filter = $"Images({FileTypes})|{FileTypes}"
            };
            var dialogResult = dialog.ShowDialog();

            if (!(dialogResult.HasValue && dialogResult.Value))
            {
                return(IOResult <string> .Cancel());
            }

            return(IOResult <string> .Complete(Result.Result <string> .Success(dialog.FileName)));
        }