Code Monkey home page Code Monkey logo

microex.common's Introduction

Microex.Common

Common extensions & tools to speed up coding

Packages

Microex.Common

this package defined some prefered SerializeSettings and extension method of Json.Net

DefaultSerializeSettings for common use case:

ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
TypeNameHandling = TypeNameHandling.Auto,
TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
DateFormatString = "yyyy-MM-dd HH:mm:ss",
Converters = new List<JsonConverter>()
{
    new StringEnumConverter()
}

IgnoreErrorSerializeSettings for complicate serialization(eg: serialize exception for logging):

ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
Error = (sender, args) =>
{
    args.ErrorContext.Handled = true;
},
TypeNameHandling = TypeNameHandling.Auto,
TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
DateFormatString = "yyyy-MM-dd HH:mm:ss",
Converters = new List<JsonConverter>()
{
    new StringEnumConverter()
}

Usage:

override JsonConvert.DefaultSerializeSettings or use obj.ToJson() & json.ToObject<T>()

Microex.Common.Mvc

this package defined some prefered extension method for aspnet core project especially for angular4

Angular Spa Integration

perform iApplicationBuilder.AddAngularRoute() to integrate angular index.html at one line of code for something like this

app.Run(async (context) =>
{
    context.Response.ContentType = "text/html";
    await context.Response.SendFileAsync(Path.Combine(wwwrootPath, angularIndexName));
});

Preffered Json Serialize Settings(damed JavaScript datetime, I want something like 2017-01-01 00:00:00)

perform iMvcBuilder.AddPrefferedJsonSettings() to override mvc default json serialize settings.


add support for json-like params of http get request(when should we have a body in http get?)

backend is like this

[HttpGet("{startTime}/{endTime}")]
public List<FooDto> Get(DateTime startTime, DateTime endTime, [TypeConverter(typeof(JObjectConverter))] JObject json)
{
    var tags = json.ToObject<Dictionary<string, string>>();
    return _fooService.GetFoos(startTime, endTime, tags);
}

then request: http://www.wtf.com/foos/2017-01-01/2019-01-01?tags=%7B%22what%22%3A%22the%20fuck%22%7D

Microex.Common.Abstractions

Todo

Documentation

microex.common's People

Contributors

snys98 avatar zlulus avatar

Stargazers

 avatar  avatar  avatar

Watchers

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