Skip to content

Commit c65a7e3

Browse files
committed
add solution code v1.0
0 parents  commit c65a7e3

File tree

553 files changed

+9477
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

553 files changed

+9477
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Manulife.ChengDu.DesignPatterm.Decorator
8+
{
9+
/// <summary>
10+
/// 抽象界面构件类:抽象构件类
11+
/// </summary>
12+
public abstract class Component
13+
{
14+
public abstract void Display();
15+
}
16+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Manulife.ChengDu.DesignPatterm.Decorator
8+
{
9+
/// <summary>
10+
/// 构件装饰类:抽象装饰类
11+
/// </summary>
12+
public class ComponentDecorator : Component
13+
{
14+
private Component component;
15+
16+
public ComponentDecorator (Component component)
17+
{
18+
this.component = component;
19+
}
20+
21+
public override void Display()
22+
{
23+
component.Display();
24+
}
25+
}
26+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{E3E5A70E-E612-4C2F-8EF3-8092D77C1284}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Manulife.ChengDu.DesignPatterm.Decorator</RootNamespace>
11+
<AssemblyName>Manulife.ChengDu.DesignPatterm.Decorator</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Component.cs" />
47+
<Compile Include="ComponentDecorator.cs" />
48+
<Compile Include="Program.cs" />
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
<Compile Include="ScrollBarDecorator.cs" />
51+
<Compile Include="Window.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="App.config" />
55+
</ItemGroup>
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
58+
Other similar extension points exist, see Microsoft.Common.targets.
59+
<Target Name="BeforeBuild">
60+
</Target>
61+
<Target Name="AfterBuild">
62+
</Target>
63+
-->
64+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Manulife.ChengDu.DesignPatterm.Decorator
8+
{
9+
public class Program
10+
{
11+
public static void Main(string[] args)
12+
{
13+
Component component = new Window();
14+
// 一次装饰
15+
Component componentSB = new ScrollBarDecorator(component);
16+
componentSB.Display();
17+
18+
Console.WriteLine();
19+
// 二次装饰
20+
Component componentBB = new BlackBorderDecorator(componentSB);
21+
componentBB.Display();
22+
23+
Console.ReadKey();
24+
}
25+
}
26+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 有关程序集的一般信息由以下
6+
// 控制。更改这些特性值可修改
7+
// 与程序集关联的信息。
8+
[assembly: AssemblyTitle("Manulife.ChengDu.DesignPatterm.Decorator")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Manulife.ChengDu.DesignPatterm.Decorator")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
//将 ComVisible 设置为 false 将使此程序集中的类型
18+
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19+
//请将此类型的 ComVisible 特性设置为 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23+
[assembly: Guid("e3e5a70e-e612-4c2f-8ef3-8092d77c1284")]
24+
25+
// 程序集的版本信息由下列四个值组成:
26+
//
27+
// 主版本
28+
// 次版本
29+
// 生成号
30+
// 修订号
31+
//
32+
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33+
// 方法是按如下所示使用“*”: :
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Manulife.ChengDu.DesignPatterm.Decorator
8+
{
9+
/// <summary>
10+
/// 滚动条装饰类:具体装饰类
11+
/// </summary>
12+
public class ScrollBarDecorator : ComponentDecorator
13+
{
14+
public ScrollBarDecorator(Component component) : base(component)
15+
{
16+
17+
}
18+
19+
public override void Display()
20+
{
21+
this.SetScrollBar();
22+
base.Display();
23+
}
24+
25+
public void SetScrollBar()
26+
{
27+
Console.WriteLine("为构件增加滚动条!");
28+
}
29+
}
30+
31+
/// <summary>
32+
/// 黑色边框装饰类:具体装饰类
33+
/// </summary>
34+
public class BlackBorderDecorator : ComponentDecorator
35+
{
36+
public BlackBorderDecorator(Component component) : base(component)
37+
{
38+
39+
}
40+
41+
public override void Display()
42+
{
43+
this.SetScrollBar();
44+
base.Display();
45+
}
46+
47+
public void SetScrollBar()
48+
{
49+
Console.WriteLine("为构件增加黑色边框!");
50+
}
51+
}
52+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Manulife.ChengDu.DesignPatterm.Decorator
8+
{
9+
/// <summary>
10+
/// 窗体类:具体构件类
11+
/// </summary>
12+
public class Window : Component
13+
{
14+
public override void Display()
15+
{
16+
Console.WriteLine("显示窗体!");
17+
}
18+
}
19+
20+
/// <summary>
21+
/// 文本框类:具体构件类
22+
/// </summary>
23+
public class TextBox : Component
24+
{
25+
public override void Display()
26+
{
27+
Console.WriteLine("显示文本框!");
28+
}
29+
}
30+
31+
/// <summary>
32+
/// 列表框类:具体构件类
33+
/// </summary>
34+
public class ListBox : Component
35+
{
36+
public override void Display()
37+
{
38+
Console.WriteLine("显示列表框!");
39+
}
40+
}
41+
}
6 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

0 commit comments

Comments
 (0)