背景 最先采用的是 Maui + Blazor 开发,使用社区热度比较高的 Blazor UI 框架。 可是开发进行过程中, Maui 巨多坑,Blazor UI 框架也是巨多坑,使用 Blazor UI 写的页面和样式,过不了设计师和产品经理的是法眼。 最终决定使用原生前端结合,生成静态内容放到 Maui 中,然后将两者结合起来打包发布。 先搞前端 对于前端来说,按照正常的开发模式就行,不对对前端的代码产生污染。 可以使用 VS 创建前端项目,将其放到解决方案中,也可以单独创建一个目录,将前端代码放到里面。 创建…

2022年10月17日 0条评论 3986点热度 2人点赞 痴者工良 阅读全文

bool IsDefine<T1, T2>(T2 t) where T1 : Enum where T2 : Enum { var value = Unsafe.As<T2, T1>(ref t); var array = Enum.GetValues(typeof(T1)); return (Array.BinarySearch(array, value) >= 0); } public static class EnumTool<T1, T2> where T1 : E…

2022年10月13日 0条评论 2697点热度 0人点赞 痴者工良 阅读全文

bool IsDefine<T1, T2>(T2 t) where T1 : Enum where T2 : Enum { var value = Unsafe.As<T2, T1>(ref t); var array = Enum.GetValues(typeof(T1)); return (Array.BinarySearch(array, value) >= 0); } public static class EnumTool<T1, T2> where T1 : E…

2022年10月13日 0条评论 2777点热度 0人点赞 痴者工良 阅读全文

In projects using partial classes, such as Razor, Blazor, WPF, etc., the compilation will generate .g.cs files. However, if there are issues that prevent successful compilation, and examining the source code does not reveal any errors, one can begin outputting…

2022年10月13日 0条评论 3217点热度 0人点赞 痴者工良 阅读全文

在项目使用分部类,如 Razor、Blazor、Wpf 等项目中,编译会生成 .g.cs 文件,但是因为出现了问题,不能编译成功,查看源代码,找不出错误,只能开始输出 .g.cs ,查看文件进行检查。 <PropertyGroup> <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> </PropertyGroup> https://stackoverflow.com/questions/7117…

2022年10月13日 0条评论 3155点热度 0人点赞 痴者工良 阅读全文

Fast speed and good performance through DNS. dig ANY +short @resolver2.opendns.com myip.opendns.com dig ANY +short @resolver2.opendns.com myip.opendns.com dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net [......] 继续阅读

2022年10月12日 0条评论 1122点热度 0人点赞 痴者工良 阅读全文

通过 DNS 方式,速度快,性能好。 dig ANY +short @resolver2.opendns.com myip.opendns.com dig ANY +short @resolver2.opendns.com myip.opendns.com dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net [......] 继续阅读

2022年10月12日 0条评论 2756点热度 0人点赞 痴者工良 阅读全文

// json => Dictionary static Dictionary<string, string> Read(string jsonData) { var reader = new Utf8JsonReader(Encoding.Default.GetBytes(jsonData), _jsonReaderOptions); var map = new Dictionary<string, string>(); BuildMap(r[......]继续阅读

2022年10月10日 0条评论 1104点热度 0人点赞 痴者工良 阅读全文

// json => Dictionary static Dictionary<string, string> Read(string jsonData) { var reader = new Utf8JsonReader(Encoding.Default.GetBytes(jsonData), _jsonReaderOptions); var map = new Dictionary<string, string>(); BuildMap(r[......]继续阅读

2022年10月10日 0条评论 3132点热度 0人点赞 痴者工良 阅读全文

private static void RunPowershellScript(string scriptFile) { ProcessStartInfo ps = new ProcessStartInfo(@"powershell.exe", scriptFile) { RedirectStandardOutput = true }; //ps.CreateNoWindow = true; var proc = Process.Start(ps); proc.OutputDataReceive…

2022年10月9日 0条评论 1734点热度 0人点赞 痴者工良 阅读全文

private static void RunPowershellScript(string scriptFile) { ProcessStartInfo ps = new ProcessStartInfo(@"powershell.exe",scriptFile) { RedirectStandardOutput = true }; //ps.CreateNoWindow = true; var proc = Process.Start(ps); proc.OutputDataReceived += (s, e)…

2022年10月9日 0条评论 3544点热度 0人点赞 痴者工良 阅读全文

using System.Resources; var assembly = typeof(Program).Assembly; ResourceManager resourceManager = new ResourceManager("update.Properties.Resources", assembly); var host = resourceManager.GetString("host"); You can retrieve a list of resour…

2022年10月8日 0条评论 5548点热度 0人点赞 痴者工良 阅读全文

using System.Resources; var assembly = typeof(Program).Assembly; ResourceManager resourceManager = new ResourceManager("update.Properties.Resources", assembly); var host = resourceManager.GetString("host"); 可以通过 typeof(Program).Assembly.GetManifestResourceName…

2022年10月8日 0条评论 8054点热度 0人点赞 痴者工良 阅读全文

Project publish parameters: dotnet publish -c Release -r win-x64 -p:PublishProfile=FolderProfile --no-self-contained dotnet publish -c Release -r win-x64 -p:PublishProfile=FolderProfile -p:PublishReadyToRun=true -p:PublishTrimmed=true --self-contained false En…

2022年10月8日 0条评论 6416点热度 2人点赞 痴者工良 阅读全文

项目发布参数: dotnet publish -c Release -r win-x64 -p:PublishProfile=FolderProfile --no-self-contained dotnet publish -c Release -r win-x64 -p:PublishProfile=FolderProfile -p:PublishReadyToRun=true -p:PublishTrimmed=true --self-contained false 开启裁剪: 关闭反射: <IlcDis…

2022年10月8日 0条评论 4130点热度 2人点赞 痴者工良 阅读全文

ASP.NET Core Response.Body is by default an HttpResponseStream, which is characterized by allowing writes only in append mode, and it cannot be read or modified. Therefore, the fundamental method is to replace the HttpResponseStream. You can set up a middlewar…

2022年9月30日 0条评论 10672点热度 0人点赞 痴者工良 阅读全文

ASP.NET Core Response.Body 默认是 HttpResponseStream,其主要特征是只能追加写,不能读取也不能修改。 所以最根本方法是替换 HttpResponseStream。 随便设置一个中间件,或者将 HttpContext 拿出来,定义变量 context。 替换 Body: var responseOriginalBody = context.Response.Body; var memStream = new MemoryStream(); context.Response.…

2022年9月30日 0条评论 4420点热度 0人点赞 痴者工良 阅读全文

When performing unit tests, libraries such as Moq are often used to mock the code. However, in some cases, we want to not only mock methods but also determine if the passed parameters are correct within the mock methods. This is because conventional mocking si…

2022年9月26日 0条评论 1248点热度 0人点赞 痴者工良 阅读全文

做单元测试的时候往往会使用 Moq 等库,对代码进行 Mock。 但是有些过程,我们希望除了 Mock 方法之外,能够在 Mock 方法中,判断传递的参数是否正确。 因为常规的 Mock ,是返回一个值。 var mock = new Mock<Test>(); mock.Setup<xxxx>(x => Get).... var obj = mock.Object; var result = obj.Get(); 在这个时候,是忽略参数和计算过程,返回一个值。 但是我们如果需要一个参…

2022年9月26日 0条评论 4500点热度 0人点赞 痴者工良 阅读全文

Windows.ApplicationModel.Package.Current.InstalledLocation.Path [......] 继续阅读

2022年9月23日 0条评论 1140点热度 0人点赞 痴者工良 阅读全文
1151617181955