Exemplo n.º 1
0
        public string WriteOutput(string input)
        {
            Console.WriteLine(input);

            Wrote?.Invoke(this, new ConsoleEventArgs {
                Message = input
            });

            return(input);
        }
Exemplo n.º 2
0
        public static void Write()
        {
            var bytes = MessagePackSerializer.Serialize(MainWindow.MainViewModel);

            if (!Directory.Exists(PATH))
            {
                Directory.CreateDirectory(PATH);
            }
            File.WriteAllBytes(FILEPATH, bytes);
            Wrote?.Invoke(bytes);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Writes the settings.
        /// </summary>
        public void Write()
        {
            try
            {
                // valide settings values
                Validate();

                // write settings values
                using (var stream = new FileStream(Target, FileMode.Create, FileAccess.Write))
                {
                    var serializer = new DataContractJsonSerializer(typeof(UserSettings));
                    serializer.WriteObject(stream, this);
                }

                Wrote?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException("failed to save settings", exception);
            }
        }