-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
49 lines (37 loc) · 1.52 KB
/
Program.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
namespace SOLID
{
class Program
{
static void Main(string[] args)
{
IEnumerable<IRectangle> rectangles = new RectangleProvider().GetRectangles();
foreach (IRectangle rectangle in rectangles)
{
int startinArea = rectangle.Area;
int startingWidth = rectangle.Width;
int startingHeight = rectangle.Height;
rectangle.Width += 1;
if (rectangle.Area != startinArea + startingHeight)
{
throw new ApplicationException("Failed somehow");
}
}
// Now that we made DataMover follow the SOLID principles,
// we can move data in all sorts of way without ever actually
// touching the logic inside DataMover itself - just by adding
// new implementations of the IDataProvider and IDataSender
// interfaces! Go check out that file (DataMover.cs) for more info!
DataMover fileToIpMover = new DataMover(
new FileDataProvider("someFile.txt"),
new WebClientDataSender("192.168.0.10"));
DataMover webToFtpMover = new DataMover(
new WebClientDataProvider("google.com"),
new FtpDataSender());
Console.WriteLine("Hello World!");
}
}
}