Code Monkey home page Code Monkey logo

lsl.tags's Introduction

Build status Coveralls branch NuGet

LSL.Tags

This package provides a static class to build an enumerable list of strings that represent tags.

Quick Start

// basic setup example
var tags = BuildTags.With.Tag("my-tag").Build();
// tags will contain ["my-tag"]

// adding multiple tags
var tags2 = BuildTags.With.Tag("tag1").Tag("tag2").Build();
// tags2 will contain ["tag1", "tag2"]

// adding tags with a key and value
var tags3 = BuildTags.With.KeyAndValueTag("my-key", "my-value").Build();
// tags3 will contain ["my-key:my-value"]

// adding multiple tags with a key and value
var tags4 = BuildTags.With
    .KeyAndValueTag("my-key", "my-value")
    .KeyAndValueTag("my-other-key", "my-other-value")
    .Build();    
// tags4 will contain ["my-key:my-value", "my-other-key:my-other-value"]

// adding tags with a colon in the provided key and value
var tags5 = BuildTags.With.KeyAndValueTag("my-key:with-colon", "my-value:with-colon").Build();
// tags5 will contain ["my-key%3awith-colon:my-value%3awith-colon"]

// attempting to build an empty tag list
var tags6 = BuildTags.With.Build();
// this will throw an ArgumentException due to no tags being provided

// Build an empty tag list
var tags7 = BuildTags.Empty();
// this will return an empty tag list as we have explicitly asked for it
// NOTE: Enumerable.Empty<string>() could also be used here

// Setting an application tag using the Assembly name of a given type:
var tags = BuildTags.ApplicationTagForAssemblyOfType(typeof(Program))
    .Build();
// tags will contain ["Application:MyAssemblyName"]
// NOTE: This assumes the name of the assemby containing Program is called MyAssemblyName

// Setting an application tag using the Assembly name of a given type:
var tags = BuildTags.ApplicationTagForAssemblyOf<Program>()
    .Build();    
// tags will contain ["Application:MyAssemblyName"]
// NOTE: This assumes the name of the assemby containing Program is called MyAssemblyName

// Parsing an encoded key/value tag
var keyValuePair = TagBuilder.Parse("my-key:my-value");
// keyValuePair.Key == "my-key"
// keyValuePair.Value == "my-value"

lsl.tags's People

Watchers

 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.