jeffrey 9 vuotta sitten
vanhempi
sitoutus
778ec1300c

+ 2 - 2
BuilderPattern/Director.cs

@@ -69,7 +69,7 @@ namespace BuilderPattern
             hp.AssemblePart("键鼠");
         }
 
-        public override Computer GetComputer()
+        public Computer GetComputer()
         {
             return hp;
         }
@@ -97,7 +97,7 @@ namespace BuilderPattern
             dell.AssemblePart("键鼠");
         }
 
-        public override Computer GetComputer()
+        public Computer GetComputer()
         {
             return dell;
         }

+ 6 - 0
DesignPattern.sln

@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingletonPattern", "Singlet
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuilderPattern", "BuilderPattern\BuilderPattern.csproj", "{F24EFFF3-8FE3-49C6-90E8-252AAB8A3332}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrototypePattern", "PrototypePattern\PrototypePattern.csproj", "{F702AE63-86D1-4396-B0D6-E448903C0139}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -25,6 +27,10 @@ Global
 		{F24EFFF3-8FE3-49C6-90E8-252AAB8A3332}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{F24EFFF3-8FE3-49C6-90E8-252AAB8A3332}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{F24EFFF3-8FE3-49C6-90E8-252AAB8A3332}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F702AE63-86D1-4396-B0D6-E448903C0139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F702AE63-86D1-4396-B0D6-E448903C0139}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F702AE63-86D1-4396-B0D6-E448903C0139}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F702AE63-86D1-4396-B0D6-E448903C0139}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 6 - 0
PrototypePattern/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 26 - 0
PrototypePattern/Email.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrototypePattern
+{
+    public class Email : ICloneable
+    {
+        public string Receiver { get; set; }
+        public string Sender { get; set; }
+        public string Subject { get; set; }
+        public string Name { get; set; }
+
+        public string Content { get; set; }
+
+        public string Footer { get; set; }
+
+
+        public object Clone()
+        {
+            return this.MemberwiseClone();
+        }
+    }
+}

+ 40 - 0
PrototypePattern/Program.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrototypePattern
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            Console.WriteLine("原型模式:");
+
+            Email email = new Email()
+            {
+                Sender = "[email protected]",
+                Subject = "招商银行月开鑫基金上线啦,最低年化收益7%,速速抢购!",
+                Content = "招商银行月开鑫基金上线啦,最低年化收益7%,速速抢购,手慢无,每人限购1万,详情咨询95555!",
+                Footer = "招商银行"
+            };
+
+            for (int i = 0; i < 10000; i++)
+            {
+                string receiver = string.Format("kehu{0}@qq.com", i);
+                string name = string.Format("尊敬的客户『{0}』:", i);
+                var cloneEmail = email.Clone() as Email;
+                cloneEmail.Receiver = receiver;
+                cloneEmail.Name = name;
+
+                SendEmail(cloneEmail);
+            }
+        }
+
+        private static void SendEmail(Email email)
+        {
+            Console.WriteLine(string.Format("邮件已发送至:『{0}』", email.Receiver));
+        }
+    }
+}

+ 36 - 0
PrototypePattern/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("PrototypePattern")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("PrototypePattern")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("3c2371ee-138f-4424-a7dc-daf82794fbdd")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 59 - 0
PrototypePattern/PrototypePattern.csproj

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{F702AE63-86D1-4396-B0D6-E448903C0139}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>PrototypePattern</RootNamespace>
+    <AssemblyName>PrototypePattern</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Email.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>