Giter Site home page Giter Site logo

xmxth001 / settings Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aritchie/settings

0.0 0.0 0.0 9.05 MB

A cross platform settings plugin for Xamarin and Windows. Unlike other setting libraries in the wild, this library provides several unique features. Store almost any object, monitor change events, iOS app groups, iCloud Provider, and Old school windows settings

License: MIT License

C# 99.53% Batchfile 0.47%

settings's Introduction

UPDATE - This library has now moved to the Shiny Framework at https://github.com/shinyorg/shiny

ACR Settings Plugin for Xamarin and Windows

A cross platform settings plugin for Xamarin and Windows. Unlike other setting libraries in the wild, this library provides several unique features

Change Log - April 12, 2018

NuGet Build status

Features

  • You can store/retrieve just about any type of object (thanks to Newtonsoft.Json)
  • You can monitor for changes using the Changed event
  • iCloud Settings Provider
  • You can use roaming profiles which is useful for:
    • iOS app groups
    • iOS extensions
    • iWatch
    • Android Wear

To use, simply call:

var int1 = CrossSettings.Current.Get<int>("Key");
var int2 = CrossSettings.Current.Get<int?>("Key");

CrossSettings.Current.Set("Key", AnyObject); // converts to JSON
var obj = CrossSettings.Current.Get<AnyObject>("Key");

Strongly Typed Binding (works with all platforms - no fancy reflection that breaks on iOS)

var myInpcObj = CrossSettings.Current.Bind<MyInpcObject>(); // Your object must implement INotifyPropertyChanged
myInpcObj.SomeProperty = "Hi"; // everything is automatically synchronized to settings right here

//From your viewmodel
CrossSettings.Current.Bind(this);

// make sure to unbind when your model is done
CrossSettings.Current.UnBind(obj);

To supply your own implementation:

CrossSettings.Current = new YourImplementationInheritingISettings();

Monitor setting changes:

CrossSettings.Current.Changed += (sender, args) => {
    Console.WriteLine(args.Action);
    Console.WriteLine(args.Key);
    Console.WriteLine(args.Value);
};

Dependency Injection:

Autofac

    containerBuilder.Register(x => CrossSettings.Current).As<ISettings>().SingleInstance();
    
    OR for strongly typed

    containerBuilder.Register(_ => CrossSettings.Current.Bind<YouAppSettings>()).AsSelf().SingleInstance();

settings's People

Contributors

aritchie avatar petero-dk avatar pelleravn avatar

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.