Skip to content

Commit

Permalink
Command
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCancio committed Jan 14, 2021
1 parent 24b21a9 commit df77c48
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 0 deletions.
18 changes: 18 additions & 0 deletions PatternsComportamentais/Command/Command.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Command
{
public abstract class Command
{
protected Receiver receiver;

protected Command(Receiver receiver)
{
this.receiver = receiver;
}

public abstract void Execute();
}
}
8 changes: 8 additions & 0 deletions PatternsComportamentais/Command/Command.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
16 changes: 16 additions & 0 deletions PatternsComportamentais/Command/ConcreteCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace Command
{
public class ConcreteCommand : Command
{
public ConcreteCommand(Receiver receiver) : base(receiver)
{
}

public override void Execute()
{
this.receiver.Action();
}
}
}
14 changes: 14 additions & 0 deletions PatternsComportamentais/Command/Invoker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace Command
{
public class Invoker
{
public Command command { private get; set; }

public void ExecuteCommand()
{
this.command.Execute();
}
}
}
18 changes: 18 additions & 0 deletions PatternsComportamentais/Command/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace Command
{
class Program
{
static void Main(string[] args)
{
Receiver receiver = new Receiver();
Command command = new ConcreteCommand(receiver);

Invoker invoker = new Invoker();

invoker.command = command;
invoker.ExecuteCommand();
}
}
}
12 changes: 12 additions & 0 deletions PatternsComportamentais/Command/Receiver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Command
{
public class Receiver
{
public void Action()
{
Console.WriteLine("Chamando o Reicever.Action()");
}
}
}
6 changes: 6 additions & 0 deletions PatternsComportamentais/PatternsComportamentais.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainOfResponsibility", "ChainOfResponsibility\ChainOfResponsibility.csproj", "{192EB634-E358-4B2E-8D18-8C975B167E33}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Command", "Command\Command.csproj", "{0F54B039-B529-4FB1-BEE8-87D210A08952}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{192EB634-E358-4B2E-8D18-8C975B167E33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{192EB634-E358-4B2E-8D18-8C975B167E33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{192EB634-E358-4B2E-8D18-8C975B167E33}.Release|Any CPU.Build.0 = Release|Any CPU
{0F54B039-B529-4FB1-BEE8-87D210A08952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F54B039-B529-4FB1-BEE8-87D210A08952}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F54B039-B529-4FB1-BEE8-87D210A08952}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F54B039-B529-4FB1-BEE8-87D210A08952}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit df77c48

Please sign in to comment.