Skip to content

Commit 162b577

Browse files
committed
update solution to .NET 6
1 parent 608a1d9 commit 162b577

File tree

125 files changed

+1996
-2289
lines changed

Some content is hidden

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

125 files changed

+1996
-2289
lines changed

CommandPattern/CommandPattern.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
68
</PropertyGroup>
79

810
</Project>

CommandPattern/Program.cs

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
using CommandPattern.RemoteControl;
2-
using System;
32

4-
namespace CommandPattern
5-
{
6-
internal class Program
7-
{
8-
private static void Main()
9-
{
10-
SimpleRemoteControlTest.Test();
3+
SimpleRemoteControlTest.Test();
114

12-
RemoteLoader.Test();
13-
Console.ReadKey();
14-
}
15-
}
16-
}
5+
RemoteLoader.Test();
6+
Console.ReadKey();
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
using System;
1+
namespace CommandPattern.RemoteControl.Commands.CeilingFanCommands;
22

3-
namespace CommandPattern.RemoteControl.Commands.CeilingFanCommands
3+
public class CeilingFan
44
{
5-
public class CeilingFan
6-
{
7-
private readonly string _name;
5+
private readonly string _name;
86

9-
public CeilingFan(string name = "")
10-
{
11-
_name = name;
12-
}
7+
public CeilingFan(string name = "")
8+
{
9+
_name = name;
10+
}
1311

14-
public void On()
15-
{
16-
Console.WriteLine($"{_name} Fan is On.");
17-
}
12+
public void On()
13+
{
14+
Console.WriteLine($"{_name} Fan is On.");
15+
}
1816

19-
public void Off()
20-
{
21-
Console.WriteLine($"{_name} Fan is Off");
22-
}
17+
public void Off()
18+
{
19+
Console.WriteLine($"{_name} Fan is Off");
2320
}
24-
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
namespace CommandPattern.RemoteControl.Commands.CeilingFanCommands
1+
namespace CommandPattern.RemoteControl.Commands.CeilingFanCommands;
2+
3+
public class CeilingFanOffCommand : ICommand
24
{
3-
public class CeilingFanOffCommand : ICommand
4-
{
5-
private readonly CeilingFan _ceilingFan;
5+
private readonly CeilingFan _ceilingFan;
66

7-
public CeilingFanOffCommand(CeilingFan ceilingFan)
8-
{
9-
_ceilingFan = ceilingFan;
10-
}
7+
public CeilingFanOffCommand(CeilingFan ceilingFan)
8+
{
9+
_ceilingFan = ceilingFan;
10+
}
1111

12-
public void Execute()
13-
{
14-
_ceilingFan.Off();
15-
}
12+
public void Execute()
13+
{
14+
_ceilingFan.Off();
15+
}
1616

17-
public void Undo()
18-
{
19-
_ceilingFan.On();
20-
}
17+
public void Undo()
18+
{
19+
_ceilingFan.On();
2120
}
22-
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
namespace CommandPattern.RemoteControl.Commands.CeilingFanCommands
1+
namespace CommandPattern.RemoteControl.Commands.CeilingFanCommands;
2+
3+
public class CeilingFanOnCommand : ICommand
24
{
3-
public class CeilingFanOnCommand : ICommand
4-
{
5-
private readonly CeilingFan _ceilingFan;
5+
private readonly CeilingFan _ceilingFan;
66

7-
public CeilingFanOnCommand(CeilingFan ceilingFan)
8-
{
9-
_ceilingFan = ceilingFan;
10-
}
7+
public CeilingFanOnCommand(CeilingFan ceilingFan)
8+
{
9+
_ceilingFan = ceilingFan;
10+
}
1111

12-
public void Execute()
13-
{
14-
_ceilingFan.On();
15-
}
12+
public void Execute()
13+
{
14+
_ceilingFan.On();
15+
}
1616

17-
public void Undo()
18-
{
19-
_ceilingFan.Off();
20-
}
17+
public void Undo()
18+
{
19+
_ceilingFan.Off();
2120
}
22-
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
using System;
1+
namespace CommandPattern.RemoteControl.Commands.GarageDoorCommands;
22

3-
namespace CommandPattern.RemoteControl.Commands.GarageDoorCommands
3+
public class GarageDoor
44
{
5-
public class GarageDoor
5+
public void Open()
66
{
7-
public void Open()
8-
{
9-
Console.WriteLine("Garage Door is opened.");
10-
}
7+
Console.WriteLine("Garage Door is opened.");
8+
}
119

12-
public void Close()
13-
{
14-
Console.WriteLine("Garage Door is closed.");
15-
}
10+
public void Close()
11+
{
12+
Console.WriteLine("Garage Door is closed.");
1613
}
17-
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
namespace CommandPattern.RemoteControl.Commands.GarageDoorCommands
1+
namespace CommandPattern.RemoteControl.Commands.GarageDoorCommands;
2+
3+
public class GarageDoorCloseCommand : ICommand
24
{
3-
public class GarageDoorCloseCommand : ICommand
4-
{
5-
private readonly GarageDoor _garageDoor;
5+
private readonly GarageDoor _garageDoor;
66

7-
public GarageDoorCloseCommand(GarageDoor garageDoor)
8-
{
9-
_garageDoor = garageDoor;
10-
}
7+
public GarageDoorCloseCommand(GarageDoor garageDoor)
8+
{
9+
_garageDoor = garageDoor;
10+
}
1111

12-
public void Execute()
13-
{
14-
_garageDoor.Close();
15-
}
12+
public void Execute()
13+
{
14+
_garageDoor.Close();
15+
}
1616

17-
public void Undo()
18-
{
19-
_garageDoor.Open();
20-
}
17+
public void Undo()
18+
{
19+
_garageDoor.Open();
2120
}
22-
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
namespace CommandPattern.RemoteControl.Commands.GarageDoorCommands
1+
namespace CommandPattern.RemoteControl.Commands.GarageDoorCommands;
2+
3+
public class GarageDoorOpenCommand : ICommand
24
{
3-
public class GarageDoorOpenCommand : ICommand
4-
{
5-
private readonly GarageDoor _garageDoor;
5+
private readonly GarageDoor _garageDoor;
66

7-
public GarageDoorOpenCommand(GarageDoor garageDoor)
8-
{
9-
_garageDoor = garageDoor;
10-
}
7+
public GarageDoorOpenCommand(GarageDoor garageDoor)
8+
{
9+
_garageDoor = garageDoor;
10+
}
1111

12-
public void Execute()
13-
{
14-
_garageDoor.Open();
15-
}
12+
public void Execute()
13+
{
14+
_garageDoor.Open();
15+
}
1616

17-
public void Undo()
18-
{
19-
_garageDoor.Close();
20-
}
17+
public void Undo()
18+
{
19+
_garageDoor.Close();
2120
}
22-
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
namespace CommandPattern.RemoteControl.Commands
1+
namespace CommandPattern.RemoteControl.Commands;
2+
3+
public interface ICommand
24
{
3-
public interface ICommand
4-
{
5-
void Execute();
6-
void Undo();
7-
}
8-
}
5+
void Execute();
6+
void Undo();
7+
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
using System;
1+
namespace CommandPattern.RemoteControl.Commands.LightCommands;
22

3-
namespace CommandPattern.RemoteControl.Commands.LightCommands
3+
public class Light
44
{
5-
public class Light
6-
{
7-
private readonly string _name;
5+
private readonly string _name;
86

9-
public Light(string name = "")
10-
{
11-
_name = name;
12-
}
7+
public Light(string name = "")
8+
{
9+
_name = name;
10+
}
1311

14-
public void On()
15-
{
16-
Console.WriteLine($"{_name} Light is On.");
17-
}
12+
public void On()
13+
{
14+
Console.WriteLine($"{_name} Light is On.");
15+
}
1816

19-
public void Off()
20-
{
21-
Console.WriteLine($"{_name} Light is Off.");
22-
}
17+
public void Off()
18+
{
19+
Console.WriteLine($"{_name} Light is Off.");
2320
}
2421
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
namespace CommandPattern.RemoteControl.Commands.LightCommands
1+
namespace CommandPattern.RemoteControl.Commands.LightCommands;
2+
3+
public class LightOffCommand : ICommand
24
{
3-
public class LightOffCommand : ICommand
4-
{
5-
private readonly Light _light;
5+
private readonly Light _light;
66

7-
public LightOffCommand(Light light)
8-
{
9-
_light = light;
10-
}
7+
public LightOffCommand(Light light)
8+
{
9+
_light = light;
10+
}
1111

12-
public void Execute()
13-
{
14-
_light.Off();
15-
}
12+
public void Execute()
13+
{
14+
_light.Off();
15+
}
1616

17-
public void Undo()
18-
{
19-
_light.On();
20-
}
17+
public void Undo()
18+
{
19+
_light.On();
2120
}
22-
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
namespace CommandPattern.RemoteControl.Commands.LightCommands
1+
namespace CommandPattern.RemoteControl.Commands.LightCommands;
2+
3+
public class LightOnCommand : ICommand
24
{
3-
public class LightOnCommand : ICommand
4-
{
5-
private readonly Light _light;
5+
private readonly Light _light;
66

7-
public LightOnCommand(Light light)
8-
{
9-
_light = light;
10-
}
7+
public LightOnCommand(Light light)
8+
{
9+
_light = light;
10+
}
1111

12-
public void Execute()
13-
{
14-
_light.On();
15-
}
12+
public void Execute()
13+
{
14+
_light.On();
15+
}
1616

17-
public void Undo()
18-
{
19-
_light.Off();
20-
}
17+
public void Undo()
18+
{
19+
_light.Off();
2120
}
22-
}
21+
}

0 commit comments

Comments
 (0)