fx.configuration

23
FX.CONFIGURATION Larry Nung

Upload: larry-nung

Post on 20-Jan-2017

149 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Fx.configuration

FX.CONFIGURATIONLarry Nung

Page 2: Fx.configuration

AGENDAIntroductionGetting startedReferenceQ & A

2

Page 3: Fx.configuration

INTRODUCTION3

Page 4: Fx.configuration

INTRODUCTION A lightweight, simple, flexible, extensible

library to read configurations using strongly typed classes.

Support different config format Application JSON

4

Page 5: Fx.configuration

GETTING STARTED5

Page 6: Fx.configuration

GETTING STARTED

Reference library

Create configuratio

n class

Generate configuratio

n file

Create instance to

read configuratio

n setting

6

Page 7: Fx.configuration

GETTING STARTEDRead application configuration7

Page 8: Fx.configuration

READ APPLICATION CONFIGURATION<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Setting1" value="Larry

Nung"/> <add key="Setting2" value="Level Up

(http://larrynung.github.io/index.html)"/> </appSettings> </configuration>

8

Page 9: Fx.configuration

READ APPLICATION CONFIGURATIONusing FX.Configuration;

namespace ConsoleApplication12 { public class MyAppConfig:

AppConfiguration{ public string Setting1 { get; private

set; } public string Setting2 { get; private

set; } } } 9

Page 10: Fx.configuration

READ APPLICATION CONFIGURATIONusing System;

namespace ConsoleApplication12 { class Program { static void Main(string[] args) { var config = new MyAppConfig();

Console.WriteLine(config.Setting1); Console.WriteLine(config.Setting2); } } }

10

Page 11: Fx.configuration

GETTING STARTEDRead JSON configuration11

Page 12: Fx.configuration

READ JSON CONFIGURATION{ "Setting1": "Larry Nung", "Setting2": "Level Up

(http://larrynung.github.io/index.html)" }

12

Page 13: Fx.configuration

READ JSON CONFIGURATIONusing FX.Configuration;

namespace ConsoleApplication12 { public class MyJSONConfig: JsonConfiguration {

//public MyJSONConfig() // : base("Config.json") //{ //} public string Setting1 { get; private set; } public string Setting2 { get; private set; } } }

13

Page 14: Fx.configuration

READ JSON CONFIGURATIONusing System;

namespace ConsoleApplication12 { class Program { static void Main(string[] args) { var config = new MyJSONConfig();

Console.WriteLine(config.Setting1); Console.WriteLine(config.Setting2); } } }

14

Page 15: Fx.configuration

GETTING STARTEDRead mixed configuration15

Page 16: Fx.configuration

READ MIXED CONFIGURATION<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Setting1" value="Larry

Nung"/> </appSettings> </configuration>

16

Page 17: Fx.configuration

READ MIXED CONFIGURATION{ "Setting2": "Level Up

(http://larrynung.github.io/index.html)" }

17

Page 18: Fx.configuration

READ MIXED CONFIGURATIONusing FX.Configuration;

namespace ConsoleApplication12 { public class MyMixedConfig :

MixedConfiguration { public string Setting1 { get; private

set; } public string Setting2 { get; private

set; } } } 18

Page 19: Fx.configuration

READ MIXED CONFIGURATIONusing System;

namespace ConsoleApplication12 { class Program { static void Main(string[] args) { var config = new MyMixedConfig();

Console.WriteLine(config.Setting1); Console.WriteLine(config.Setting2); } } }

19

Page 20: Fx.configuration

REFERENCE20

Page 21: Fx.configuration

REFERENCE NuGet Gallery | FX.Configuration 0.4.1

https://www.nuget.org/packages/FX.Configuration/

friendlyx / fx.configuration — Bitbucket https://bitbucket.org/friendlyx/fx.configuration

21

Page 22: Fx.configuration

Q&A22

Page 23: Fx.configuration

QUESTION & ANSWER

23