随笔分类 -  代码集锦

摘要:internal class Program { static async Task Main(string[] args) { var filters = new List<IFilter> { new FilterA(), new FilterB(), }; Func<BackgroundJob 阅读全文
posted @ 2024-10-26 14:58 pojianbing 阅读(13) 评论(0) 推荐(0) 编辑
摘要:internal class Program { static async Task Main(string[] args) { var list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, }; var res = Pairwise<int, string>( 阅读全文
posted @ 2024-10-26 11:48 pojianbing 阅读(6) 评论(0) 推荐(0) 编辑
摘要:internal class Program { static void Main(string[] args) { var sTotal = 1; var total = 100; for (var t = sTotal; t <= total; t++) { for (var i = 1; i 阅读全文
posted @ 2024-10-25 15:34 pojianbing 阅读(4) 评论(0) 推荐(0) 编辑
摘要:创建控制台项目 使用类库项目,.net standard.2.0 nuget安装RazorGenerator.MsBuild 这样在项目的packages目录能看到RazorGenerator.MsBuild.2.5.0 razor页类定义 namespace RazorLib { public a 阅读全文
posted @ 2024-10-24 17:08 pojianbing 阅读(15) 评论(0) 推荐(0) 编辑
摘要:public class BinarSearchTree { private Node _tree; public BinarSearchTree(List<int> datas) { if (datas != null) { foreach (var item in datas) { Insert 阅读全文
posted @ 2024-10-19 14:22 pojianbing 阅读(3) 评论(0) 推荐(0) 编辑
摘要:创建Razor页面类库 创建Razor类库,命名为: DemoPlugin2 生成controller和razor页面 Plugin2Controller public class Plugin2Controller : Controller { public IActionResult Hello 阅读全文
posted @ 2024-10-16 16:20 pojianbing 阅读(2) 评论(0) 推荐(0) 编辑
摘要:PermissionRequirement public class PermissionRequirement : AuthorizationHandler<PermissionRequirement>, IAuthorizationRequirement { public string Perm 阅读全文
posted @ 2024-10-08 16:20 pojianbing 阅读(12) 评论(0) 推荐(0) 编辑
摘要:Program internal class Program { static async Task Main(string[] args) { DbContextOptionsBuilder<BloggingContext> optionsBuilder = new DbContextOption 阅读全文
posted @ 2024-10-07 16:30 pojianbing 阅读(18) 评论(0) 推荐(0) 编辑
摘要:读取固定长度 private static byte[] ReadBytes(Stream stream, int count) { var output = new byte[count]; var total = 0; while (total < count) { var read = str 阅读全文
posted @ 2024-09-30 17:47 pojianbing 阅读(3) 评论(0) 推荐(0) 编辑
摘要:using System.Security.Cryptography; using System.Text; namespace ConsoleApp7 { internal class Program { static void Main(string[] args) { var servers 阅读全文
posted @ 2024-09-26 16:09 pojianbing 阅读(7) 评论(0) 推荐(0) 编辑
摘要:internal class Program { static int WriteDelay = 50; static int ReadDelay = 20; static async Task Main(string[] args) { /* pauseWriterThreshold: 当Pipe 阅读全文
posted @ 2024-09-24 15:02 pojianbing 阅读(7) 评论(0) 推荐(0) 编辑
摘要:Server internal class Program { static async Task Main(string[] args) { var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5000); var socket 阅读全文
posted @ 2024-09-21 15:45 pojianbing 阅读(6) 评论(0) 推荐(0) 编辑
摘要:private static Task WriteResponse(HttpContext context, HealthReport healthReport) { context.Response.ContentType = "application/json; charset=utf-8"; 阅读全文
posted @ 2024-09-14 15:35 pojianbing 阅读(10) 评论(0) 推荐(0) 编辑
摘要:服务端 开启websocket中间件 // 需要UseWebSockets,否则无法使用WebSocket app.UseWebSockets(new WebSocketOptions() { KeepAliveInterval = TimeSpan.FromSeconds(60), }); // 阅读全文
posted @ 2024-09-13 17:14 pojianbing 阅读(3) 评论(0) 推荐(0) 编辑
摘要:using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using M 阅读全文
posted @ 2024-09-13 12:12 pojianbing 阅读(45) 评论(0) 推荐(0) 编辑
摘要:internal class Program { static async Task Main(string[] args) { var root = new Root { Demo1 = new Demo1 { Name = "Demo1", Data = new Demo2 { Name = " 阅读全文
posted @ 2024-09-11 21:55 pojianbing 阅读(4) 评论(0) 推荐(0) 编辑
摘要:ConfigurationRoot public interface IConfiguration { string? this[string key] { get; } IChangeToken GetReloadToken(); } public interface IConfiguration 阅读全文
posted @ 2024-09-11 17:56 pojianbing 阅读(26) 评论(0) 推荐(0) 编辑
摘要:public class Ioc : IServiceProvider { private Ioc _root; private ConcurrentDictionary<Type, ServiceRegistry> _registries = new ConcurrentDictionary<Ty 阅读全文
posted @ 2024-09-04 11:54 pojianbing 阅读(3) 评论(0) 推荐(0) 编辑
摘要:internal class Program { static async Task Main(string[] args) { var appBuilder = new AppBuilder(); appBuilder.Use(next => { return async context => { 阅读全文
posted @ 2024-09-03 10:25 pojianbing 阅读(2) 评论(0) 推荐(0) 编辑
摘要:internal class Program { static async Task Main(string[] args) { var a = new Item("A"); var c = new Item("C"); var f = new Item("F"); var h = new Item 阅读全文
posted @ 2024-09-03 10:07 pojianbing 阅读(8) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示