This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.AddHttpClient("myclient"); | |
| // Global header propagation for any HttpClient that comes from HttpClientFactory | |
| services.AddHeaderPropagation(options => | |
| { | |
| options.HeaderNames.Add("Correlation-Id"); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Buffers; | |
| using System.Net.WebSockets; | |
| var builder = WebApplication.CreateBuilder(args); | |
| var app = builder.Build(); | |
| app.MapGet("/ws", async (HttpContext context) => | |
| { | |
| var ws = await context.WebSockets.AcceptWebSocketAsync(); | |
| var incomingMessages = new MessagePipe<WebSocketMessageType>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Analogy | |
| { | |
| /// <summary> | |
| /// This example shows that a library that needs access to target .NET Standard 1.3 | |
| /// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET | |
| /// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library. | |
| /// </summary>INetCoreApp10 | |
| class Example1 | |
| { | |
| public void Net45Application(INetFramework45 platform) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null) | |
| { | |
| using (db.Connection.EnsureOpen()) | |
| { | |
| try | |
| { | |
| return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList(); | |
| } | |
| catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906)) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AES | |
| { | |
| //http://boywhy.blogspot.tw/2015/04/c-aes.html | |
| public static Byte[] generateKey() | |
| { | |
| var AESObject = new RijndaelManaged() { KeySize = 128 }; | |
| AESObject.GenerateKey(); | |
| return AESObject.Key; | |
| } | |
| public static Byte[] encrypt(Byte[] data, Byte[] key) |