GithubHelp home page GithubHelp logo

jakeginnivan / settingsprovider.net Goto Github PK

View Code? Open in Web Editor NEW
59.0 12.0 25.0 3.02 MB

Simple Settings provider for .net applications

License: MIT License

Shell 0.38% C# 99.31% PowerShell 0.30%

settingsprovider.net's Introduction

SettingsProvider.NET

The aim of settings provider is to quickly give you a simple way to store application settings and read metadata about those settings, like description, name, default values etc

v2 Has added a few things to make versioning easier, the Key attribute allows you to rename properties, and types are no longer fully qualified (so you can move classes)

Usage

Start of by creating your settings class, marking up with metadata

public class MySettings
{
    [DefaultValue("Jake")]
    [DisplayName("Your Name")]
    public string Name { get; set; }

    [DefaultValue(true)]
    [Description("Should Some App Remember your name?")]
    public bool RememberMe { get;set; }

    public List<Guid> Favourites { get;set; }

    [Key("OriginalName")]
    public string Renamed { get; set; }

    [ProtectedString]
    public string Encrypted { get; set; }
}

Reading Settings

var settingsProvider = new SettingsProvider(); //By default uses IsolatedStorage for storage
var mySettings = settingsProvider.GetSettings<MySettings>();
Assert.True(mySettings.RememberMe); 

Saving Settings

var settingsProvider = new SettingsProvider(); //By default uses IsolatedStorage for storage
var mySettings = new MySettings { Name = "Mr Ginnivan" };
settingsProvider.Save(mySettings);

Settings MetaData

This is handy if you want to generate a UI for your settings

var settingsProvider = new SettingsProvider();
foreach (var setting in settingsProvider.ReadSettingMetadata<MySettings>())
{
    Console.WriteLine("{0} ({1}) - {2}", setting.DisplayName, setting.Description, setting.DefaultValue);
}
// Prints:
//
// Your Name () - Jake
// RememberMe (Should Some App Remember your name?) - true

Additional Notes

  • Nested complex types do not have the same features and simply use the DataContractJsonSerializer to serialise

settingsprovider.net's People

Contributors

anovitsky avatar jakeginnivan avatar samgerene avatar xelio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

settingsprovider.net's Issues

shared settings

Hello there. I simply love this package. I was wondering if there is any way to share the created settings between two projects?

I want to be able to create the settings from a wpf app and then have a windows service read from them. Is this possible?

Thanks

Settings not written

Hi Again

I am using the nuget in a class library i call to save settings. However i can see the file being created but it appears to be empty and when I try to read it, i get empty values. What am I doing wrong?

Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.