DesignPattern/Program.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FactoryMethod;
using SampleFactory;
using Strategy;
using Singleton;
using Builder;
using Prototype;
namespace DesignPattern
{
class Program
{
static void Main(string[] args)
{
#region 创建型
//简单工厂模式
ISender send = SendFactory.ProduceMail();
send.Send();
//工厂方法模式
IFactory fac = new MailSenderFactory();
Common.ISender sen=fac.CreateSender();
sen.Send("Factory Method ");
//单例模式
SingletonClass sc = SingletonClass.GetInstance();
SingletonClass scClone = SingletonClass.GetInstance();
if (sc == scClone)
{
Console.WriteLine("sc==scClone");
}
Console.WriteLine("-------------Builder模式---------------");
Director dir = new Director();
BuilderA A=new BuilderA();
dir.Construct(A);
Product pd = A.GetResult();
pd.Show();
Console.WriteLine("-------------Prototype模式---------------");
Resume re = new Resume("superman");
re.SetPersonInfo("13", "男");
re.SetWorkExpress("0-11111", "地球");
re.Display();
Resume reClone = (Resume)re.Clone();
reClone.SetWorkExpress("1111-20000", "火星");
reClone.Display();
#endregion
后面还有 27 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。