# CVSolution **Repository Path**: oyayao/cvsolution ## Basic Information - **Project Name**: CVSolution - **Description**: 尽可能的让开发人员专注于业务代码,其他的只需要Ctrl+C、Ctrl+V,改改参数就能跑 - **Primary Language**: C# - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-07-22 - **Last Updated**: 2025-02-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: Csharp ## README # CVSolution #### 介绍 尽可能的让开发人员专注于业务代码,其他的只需要Ctrl+C、Ctrl+V,改改参数就能跑。 平时新写一个程序的时候,需要从以往的程序中复制很多代码出来,比如数据库操作类,各种Extension及其他工具类,我是不想总是复制的,不仅是因为太过麻烦,更是因为时间久了后,各操作类的代码都可能不同了,所以我将平时可能用到的全部打包集成起来,按需要添加就好,方便又快捷~ #### 软件架构 1. CVSolution:主项目 2. [CVSolution.KafkaExtension:Kafka扩展](CVSolution/CVSolution.KafkaExtension/README.md) 3. [CVSolution.SocketExtension:Socket扩展](CVSolution/CVSolution.SocketExtension/README.md) 4. [CVSolution.SqlSugarExtension:SqlSugar扩展](CVSolution/CVSolution.SqlSugarExtension/README.md) 5. [CVSolution.NLogExtension:NLog扩展](CVSolution/CVSolution.NLogExtension/README.md) 6. [CVSolution.ElasticsearchExtension:Elasticsearch扩展](CVSolution/CVSolution.ElasticsearchExtension/README.md) 7. [CVSolution.SharpZipLibExtension:SharpZipLib扩展](CVSolution/CVSolution.SharpZipLibExtension/README.md) #### 使用说明 1. 开始(个人习惯) ```c# using CVSolution; public class Program { public static void Main(string[] args) { Console.Title = "程序名称"; Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN", true) { DateTimeFormat = { ShortDatePattern = "yyyy-MM-dd", FullDateTimePattern = "yyyy-MM-dd HH:mm:ss", LongTimePattern = "HH:mm:ss" } }; Console.WriteLine($"[{DateTime.Now.ToCstTime():yyyy-MM-dd HH:mm:ss}]程序开始"); CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } ``` 2. IOC注入 ```c# using CVSolution; private AppConfig appConfig; public void ConfigureServices(IServiceCollection services) { appConfig = ConfigTool.Instance.AddJsonFile("AppConfig", false, true); services.AddSingleton(appConfig); services.AddControllers(); // 控制器 services.AddHttpClient(); // Http客户端 //跨域 services.AddCors(options => { options.AddDefaultPolicy( builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod() //预检请求缓存时长 .SetPreflightMaxAge(new TimeSpan(0, 10, 0)); }); }); if (appConfig.IsSwagger) { services.AddSwaggerGen(); } } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); if (appConfig.IsSwagger) { app.UseSwagger(); app.UseSwaggerUI(); } //跨域 app.UseCors(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } ``` 3. xxxx #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)