Skip to content

ErikWahlstrom/Gu.Settings

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gu.Settings

A small framework for managing settings.

  • XmlRepository is a baseclass for managing xml files.
  • BinaryRepository is a baseclass for managing binary files.
  • JsonRepository is a baseclass for managing json files.
  • AutoSaver is a baseclass for saving files on changes.

Features:

  • T Clone(T item); deep clone by serializing and then deserializing an instance.
  • bool IsDirty(T item, IEqualityComparer comparer); check if an instance is dirty after last save.
  • Repository manages a singleton reference for each file.
  • EqualityComparers that checks structural equality by serializing and comparing bytes. If performance is an issue overloads with IEqualityComparer are exposed.
  • Saves to .tmp file, on success it is renamed to .cfg extensions are configurable via settings.
  • Creates backups on save. Backurules configurable via setting.
    • Extension
    • Directory
    • Number of backups
    • Max age backups.

Sample:

[Test]
public void XmlSample()
{
    var repository = new XmlRepository(); // Uses %AppData%/Settings. 
    var setting = repository.ReadOrCreate(() => new DummySerializable()); // Uses typeof(T).Name as filename
    setting.Value ++;
    Assert.IsTrue(repository.IsDirty(setting));
    repository.Save(setting);
    Assert.IsFalse(repository.IsDirty(setting));
}

About

A small framework for managing settings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.6%
  • Smalltalk 0.4%