博文

目前显示的是 六月, 2018的博文

CorrelationId in .Net Core and Java

1. In Java https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/java segmentfault.com/a/1190000012690912 2. .Net Core 1. set up reference in *. csproj file   <ItemGroup>   <PackageReference Include="CorrelationId" Version="2.0.0" />     <PackageReference Include="Microsoft.AspNetCore.App" />   </ItemGroup>    <!--PackageReference Include="CorrelationId" Version="1.0.1" /-->   2. Add Extension methods: AddCorrelationId and  UseCorrelationId using CorrelationId ; in class Startup  public void ConfigureServices(IServiceCollection services)         {...             services. AddCorrelationId ();         }         public void Configure(IApplicationBuilder app)         {...             app. UseCorrelationId ("testRelationID");          ...         } 3. insert a ICorrelationContextAccessor   parameter,  into constructor of controller public TestController (TestCon

log4net in .Net Core

图片
Reference in .csproj  <ItemGroup>    <PackageReference Include="log4net" Version="2.0.8" />  </ItemGroup> log4net.Config. Assembly entryAssembly = Assembly.GetEntryAssembly() ; var logRepository = LogManager.GetRepository (entryAssembly); System.IO.FileInfo config = new System.IO.FileInfo(pathConfigFile); log4net.Config.XmlConfigurator.Configure( logRepository , config); https://msdn.microsoft.com/en-us/library/system.reflection.assembly(v=vs.110).aspx log4net.LogManager.GetLogger()            log4net.LogManager.GetLogger(typeof(T)); log4net. ILog log = log4net. LogManager .GetLogger( "testApp.Logging" ); log.Info( DateTime .Now.ToString() + ": login success" ); private log4net.ILog GetAppLogger<T>(T t) {    return log4net.LogManager.GetLogger(typeof(T)); } Content of configfile <?xml version="1.0" encoding="utf-8" ?> <configuration>     &

"this" in C#

1.Indexers Indexers allow instances of a class or struct to be indexed just like arrays. 2.Extension Methods Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. The most common extension methods are the LINQ standard query operators that add query functionality to the existing System.Collections.IEnumerable and System.Collections.Generic.IEnumerable<T> types. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/indexers/ https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/params ------------------------- 1.Indexers using System; class SampleCollection<T> {    // Declare an array to store the data elements.    private T[] arr = new T[100];    // Define the indexer to allow client code to use [] notation. //T

Swagger & Open API

Swashbuckle.AspNetCore   is an open source project for generating Swagger documents for ASP.NET Core Web APIs. Codes --> Swagger documents NSwag   is another open source project for integrating   Swagger UI   or   ReDoc   into ASP.NET Core Web APIs. It offers approaches to generate C# and TypeScript client code for your API. Swagger documents --> Codes Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md https://swagger.io/ https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger?view=aspnetcore-2.1 https://swagger.io/swagger-ui/ https://github.com/Rebilly/ReDoc

Create a Web API with ASP.NET Core and Visual Studio Code

图片
Create a Web API with ASP.NET Core and Visual Studio Code Reference: https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-vsc?view=aspnetcore-2.1#create-the-project Progress ⦁ Read through roughly this tutorial. I don't step into the other knowledge URLs in this tutorial. ⦁ Installed all tools. ⦁ Created a project TodoApi by Visual Studio Code. ⦁ Entered all codes into Visual Studio Code. ⦁ Running it in the Chrome browser and Visual Studio Code anytime. ⦁ Tested it by the Chrome browser and Postman. Summary ⦁ First install Node.js (8.11.1 or later) and Npm (5.6.0 or later) before installing C# for Visual Studio Code. ⦁ It is making slow in the action, “The TodoApi folder opens in Visual Studio Code (VS Code). Select the Startup.cs file.” in the section “⦁ Create the project”. Installing c# dependencies... Platform: win32, x86_64 Downloading package 'OmniSharp for Windows (.Net 4.6 / x64)' (22457 KB) ...... ⦁ Need to Stop and press

Speechlogger

https://speechlogger.appspot.com Speechlogger is a great speech recognition (speech to text) and instant voice translation web app. It runs Google's speech-to-text technologies for the best results. The only web app with auto-punctuation, auto-save, timestamps, in-text editing capability, transcription of audio files, export options (to text and captions) and more. No user registration needed & it's completely free!  https://speechnotes.co/

API Development Tools

Today I first used POSTMAN to test an API service which is good. https://www.getpostman.com/