Coder Social home page Coder Social logo

c-sharp-dynamic-configuration-parser's Introduction

Input format

UserName: super_user;
Password: top_secret_password;

TimeToLive: 10;
IsEnabled: false;

Assumption

  • A key name, colon then value
  • Key names are case sensitive
  • A key value can be a Boolean( true, false), an integer (e.g. 1, -2, 4) or a string
  • All values that are not Boolean or integer should be treated as strings
  • Integer values can be safely stored in int type. Integer values wil be written as a series of digits, with an additional minus sign at the begenning for negative numbers
  • A configuration file can contain empty lines.
  • Neither a key name nor a value will contain a colon.
  • Each line in a configuration file, except for empty lines will have a semicolon at the end

Specification

  • Every key name found in a config file should be exposed as a property of an object retured from a parser.
var r = parser.Parse(s)
Console.Writeline(r.TimeToLive);
  • These properties should be of an appropriate type i.e. bool, int or string
  • Parser should throw ArgumentExcption if input string is null or empty
  • Keys and Values should have whitespace trimmed.
  • If non existent property is read, UnknownKeyException should be thrown
  • If a key name is null or empty, EmptyKeyException should be thrown
  • If a key is found to be invalid C# Property Name, InvalidKeyException should be thrown.
  • If duplicates are detected, DuplicatedKeyException should be thrown.

c-sharp-dynamic-configuration-parser's People

Contributors

toelwin 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.