.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
C#与SMTP服务简单应用代码如下: 主要是注意记得去开启SMTP服务,和获取授权码(开启服务后,会自动给用户)。
123456789101112131415161718192021222324252627282930313233343536373839404142using System;using System.Net;using System.Net.Mail;class Program{ public static string mailLocalAdd ;/ ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
装饰者模式:动态扩展对象功能主要代码:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455public abstract class Beverage { public string description = "Unknown Beverage"; public virtual s ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
桥接模式:将抽象部分与它的实现部分分离,使它们都可以独立地变化。主要代码
123456789101112131415161718192021222324252627282930313233343536///<桥接模式>public interface TV{ public void TuneChannel();}public abstract class RemoteControl{ public TV _tv; publi ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
适配器模式:将一个类的接口转换成客户希望的另外一个接口,即接口转换的桥梁。代码:
12345678910111213141516171819202122///<适配器模式>public interface ITarget{ void Request();}public class Adaptee{ public void SpecificRequest() { Console.WriteLine(& ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
观察者模式代码:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061///<观察者模式>//1. 定义观察者接口public interface IObserver { void Update(string message);}//2. 定义主题(被观察者)接口public ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
当对象需要根据内部状态改变行为时,常见做法:
12345switch(currentState) { case "New": ProcessNew(); break; case "Shipped": ProcessShipped(); break; case "Delivered": ProcessDelivered(); break;}
问题:
状态转换逻辑散落在各处
新增状态需修 ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
策略模式:动态切换算法当业务需要支持多种算法变体时,常见做法:
12if(paymentMethod == "Cash") ProcessCash();else if(paymentMethod == "CreditCard") ProcessCreditCard();
但是这样容易出现一些问题:
新增支付方式需修改核心代码
支付逻辑与控制器耦合
难以单独测试支付算法
解决方案:策略模式
123456789101112131415161 ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
文心一言API小后端(.Net 7)我没有写什么详细的介绍,这是流水账记录,里面有很多代码是没有用的,但是我懒得删,就当是记录自己的问题吧。
这是之前写过的一个ASP.NET Core的文心一言API,后面过了将近一年又拿出来修改了一下,部署在云服务上了,当时写这玩意的目的是为了Linux和一些写代码考试去作弊用的,因为我发现学校使用极域管理机房电脑,禁止浏览器访问页面是封的80标准端口,所以就写了个API,把它部署在非80端口上,就绕过极域的封禁去使用ai,但考试改成笔试了,手写 ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
简单工厂模式:用多态优化对象创建(基于订单处理系统案例)问题场景当业务需要根据不同条件创建不同对象时,常见做法是使用switch或if-else分支:
12if(orderType == "Book") CreateBookHandler();else if(orderType == "Video") CreateVideoHandler();
这种写法会导致:
新增类型需修改核心逻辑
创建逻辑散落在各处
单元测试困难
解决方案:简单工 ...



