forked from sheng-jie/Design-Pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
31 lines (29 loc) · 795 Bytes
/
Copy pathProgram.cs
File metadata and controls
31 lines (29 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxyPattern
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("直接访问Google:");
Google google = new Google();
try
{
google.Search("特朗普");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("----------------------------");
Console.WriteLine("使用代理访问Google:");
ISearchEngine searchEngine = new GoogleProxy();
searchEngine.Search("特朗普");
Console.ReadLine();
}
}
}