示例#1
0
        public TimeController(Config config, IBackuper backuper)
        {
            _config   = config;
            _backuper = backuper;

            _timer = new Timer(_ => Task.Run(() => _backuper.Update()));
        }
示例#2
0
 public SaveTransaction(FileInfo file, FileInfo tempFile, object contents, IBackuper backuper)
 {
     this.file     = file;
     this.tempFile = tempFile;
     this.contents = contents;
     this.backuper = backuper ?? NullBackuper.Default;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BackupViewModel"/> class.
        /// </summary>
        /// <param name="unitOfWork">Unit of work.</param>
        /// <param name="backuper">Object to perform backup of the database.</param>
        /// <param name="applicationSettings">Application settings.</param>
        public BackupViewModel(IUnitOfWork unitOfWork, IBackuper backuper, IApplicationSettings applicationSettings)
        {
            this.unitOfWork          = unitOfWork;
            this.backuper            = backuper;
            this.applicationSettings = applicationSettings;

            Task.Factory.StartNewWithDefaultCulture(this.UpdateData);
        }
示例#4
0
 /// <summary>
 /// Creates a new <see cref="Repository"/> with <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings"></param>
 protected Repository(TSetting settings, IBackuper backuper)
 {
     settings.DirectoryPath.CreateDirectoryInfo().CreateIfNotExists();
     Settings = settings;
     Backuper = backuper;
     if (Settings.IsTrackingDirty)
     {
         Tracker = new DirtyTracker(this);
     }
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Repository{TSetting}"/> class.
 /// Creates a new <see cref="Repository{TSetting}"/> with <paramref name="settings"/>.
 /// </summary>
 /// <param name="backuper">
 /// The backuper.
 /// Note that a custom backuper may not use the backupsettings.
 /// </param>
 protected Repository(TSetting settings, IBackuper backuper, Serialize <TSetting> serialize)
 {
     Ensure.NotNull <object>(settings, nameof(settings));
     Ensure.NotNull(serialize, nameof(serialize));
     this.serialize = serialize;
     new DirectoryInfo(settings.Directory).CreateIfNotExists();
     this.Settings = settings;
     this.Backuper = backuper;
     if (this.Settings.IsTrackingDirty)
     {
         this.Tracker = new DirtyTracker(this);
     }
 }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Repository{TSetting}"/> class.
        /// Creates a new <see cref="Repository{TSetting}"/> with default settings.
        /// If the directory contains a settings file it is read and used.
        /// If not a new default setting is created and saved.
        /// </summary>
        /// <param name="settingsCreator">Creates settings if file is missing</param>
        /// <param name="backuper">
        /// The backuper.
        /// Note that a custom backuper may not use the backupsettings.
        /// </param>
        protected Repository(Func <TSetting> settingsCreator, IBackuper backuper, Serialize <TSetting> serialize)
        {
            Ensure.NotNull(settingsCreator, nameof(settingsCreator));
            Ensure.NotNull(backuper, nameof(backuper));
            Ensure.NotNull(serialize, nameof(serialize));
            this.serialize = serialize;
            this.Settings  = settingsCreator();
            Directory.CreateDirectory(this.Settings.Directory);
            if (this.Settings.IsTrackingDirty)
            {
                this.Tracker = new DirtyTracker(this);
            }

            this.Backuper = backuper;
            this.Settings = this.ReadOrCreateCore(() => this.Settings);
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Repository{TSetting}"/> class.
        /// Creates a new <see cref="Repository{TSetting}"/> with <paramref name="settings"/>.
        /// </summary>
        /// <param name="backuper">
        /// The backuper.
        /// Note that a custom backuper may not use the backup settings.
        /// </param>
        /// <param name="serialize">The <see cref="Serialize{TSetting}"/>.</param>
        /// <param name="settings">The <typeparamref name="TSetting"/>.</param>
        protected Repository(TSetting settings, IBackuper backuper, Serialize <TSetting> serialize)
        {
            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this.serialize = serialize ?? throw new ArgumentNullException(nameof(serialize));
            new DirectoryInfo(settings.Directory).CreateIfNotExists();
            this.Settings = settings;
            this.Backuper = backuper;
            if (this.Settings.IsTrackingDirty)
            {
                this.Tracker = new DirtyTracker(this);
            }
        }
示例#8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Repository{TSetting}"/> class.
        /// Creates a new <see cref="Repository{TSetting}"/> with default settings.
        /// If the directory contains a settings file it is read and used.
        /// If not a new default setting is created and saved.
        /// </summary>
        /// <param name="settingsCreator">Creates settings if file is missing.</param>
        /// <param name="backuper">
        /// The backuper.
        /// Note that a custom backuper may not use the backup settings.
        /// </param>
        /// <param name="serialize">The <see cref="Serialize{TSetting}"/>.</param>
        protected Repository(Func <TSetting> settingsCreator, IBackuper backuper, Serialize <TSetting> serialize)
        {
            if (settingsCreator is null)
            {
                throw new ArgumentNullException(nameof(settingsCreator));
            }

            this.serialize = serialize ?? throw new ArgumentNullException(nameof(serialize));
            this.Backuper  = backuper ?? throw new ArgumentNullException(nameof(backuper));
            this.Settings  = settingsCreator();
            _ = Directory.CreateDirectory(this.Settings.Directory);
            if (this.Settings.IsTrackingDirty)
            {
                this.Tracker = new DirtyTracker(this);
            }

            this.Settings = this.ReadOrCreateCore(this.GetFileInfoCore <TSetting>(), () => this.Settings);
        }
示例#9
0
 public XmlRepository(RuntimeXmlRepositorySettings settings, IBackuper backuper)
     : base(settings, backuper)
 {
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SingletonRepository{TSetting}"/> class.
 /// Creates a new <see cref="Repository{TSetting}"/> with <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">Setting controlling behavior.</param>
 /// <param name="backuper">
 /// The backuper.
 /// Note that a custom backuper may not use the backupsettings.
 /// </param>
 /// <param name="serialize">Serialization logic.</param>
 protected SingletonRepository(TSetting settings, IBackuper backuper, Serialize <TSetting> serialize)
     : base(settings, backuper, serialize)
 {
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SingletonRepository{TSetting}"/> class.
 /// Creates a new <see cref="Repository{TSetting}"/> with default settings.
 /// If the directory contains a settings file it is read and used.
 /// If not a new default setting is created and saved.
 /// </summary>
 /// <param name="settingsCreator">Creates settings if file is missing.</param>
 /// <param name="backuper">
 /// The backuper.
 /// Note that a custom backuper may not use the backupsettings.
 /// </param>
 /// <param name="serialize">Serialization logic.</param>
 protected SingletonRepository(Func <TSetting> settingsCreator, IBackuper backuper, Serialize <TSetting> serialize)
     : base(settingsCreator, backuper, serialize)
 {
     this.fileCache.Add(this.GetFileInfoCore <TSetting>().FullName, this.Settings);
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRepository"/> class.
 /// If the directory contains a settings file it is read and used.
 /// If not a new setting is created and saved.
 /// </summary>
 /// <param name="settingsCreator">Creates settings if file is missing</param>
 /// <param name="backuper">
 /// The backuper.
 /// Note that a custom backuper may not use the backupsettings.
 /// </param>
 public DataRepository(Func <DataRepositorySettings> settingsCreator, IBackuper backuper)
     : base(settingsCreator, backuper, Serialize <DataRepositorySettings> .Default)
 {
 }
示例#13
0
 public JsonRepository(JsonRepositorySettings settings, IBackuper backuper)
     : base(settings, backuper)
 {
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRepository{TSetting}"/> class.
 /// Creates a new <see cref="Repository{TSetting}"/> with default settings.
 /// If the directory contains a settings file it is read and used.
 /// If not a new default setting is created and saved.
 /// </summary>
 /// <param name="settingsCreator">Creates settings if file is missing</param>
 /// <param name="backuper">
 /// The backuper.
 /// Note that a custom backuper may not use the backupsettings.
 /// </param>
 /// <param name="serialize">Serialization logic.</param>
 protected DataRepository(Func <TSetting> settingsCreator, IBackuper backuper, Serialize <TSetting> serialize)
     : base(settingsCreator, backuper, serialize)
 {
 }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SingletonRepository"/> class.
 /// </summary>
 public SingletonRepository(Core.RepositorySettings settings, JsonSerializerSettings jsonSettings, IBackuper backuper)
     : base(Create(settings, jsonSettings), backuper, Serialize <RepositorySettings> .Default)
 {
 }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SingletonRepository"/> class.
 /// </summary>
 public SingletonRepository(RepositorySettings settings, IBackuper backuper)
     : base(settings, backuper, Serialize <RepositorySettings> .Default)
 {
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SingletonRepository"/> class.
 /// If the directory contains a settings file it is read and used.
 /// If not a new setting is created and saved.
 /// </summary>
 /// <param name="settingsCreator">Creates settings if file is missing.</param>
 /// <param name="backuper">
 /// The backuper.
 /// Note that a custom backuper may not use the backupsettings.
 /// </param>
 public SingletonRepository(Func <RepositorySettings> settingsCreator, IBackuper backuper)
     : base(settingsCreator, backuper, Serialize <RepositorySettings> .Default)
 {
 }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRepository"/> class.
 /// </summary>
 /// <param name="settings">The <see cref="DataRepositorySettings"/>.</param>
 /// <param name="backuper">The <see cref="IBackuper"/>.</param>
 public DataRepository(DataRepositorySettings settings, IBackuper backuper)
     : base(settings, backuper, Serialize <DataRepositorySettings> .Default)
 {
 }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRepository"/> class.
 /// </summary>
 public DataRepository(Core.IRepositorySettings settings, IBackuper backuper)
     : base(Create(settings), backuper, Serialize <DataRepositorySettings> .Default)
 {
 }
示例#20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BackupService"/> class.
 /// </summary>
 /// <param name="unitOfWork">Unit of work.</param>
 /// <param name="settingsService">Settings service.</param>
 /// <param name="backuper">The object to perform backup of the database.</param>
 public BackupService(IUnitOfWork unitOfWork, ISettingsService settingsService, IBackuper backuper)
 {
     this.unitOfWork      = unitOfWork;
     this.settingsService = settingsService;
     this.backuper        = backuper;
 }