├── .DS_Store ├── .gitattributes ├── .gitignore ├── Design Patterns de Comportamento ├── Chain_of_Responsibility │ ├── App.config │ ├── Chain_of_Responsibility.csproj │ ├── Chain_of_Responsibility.sln │ ├── Manipulador.cs │ ├── PersonagemA.cs │ ├── PersonagemB.cs │ ├── PersonagemC.cs │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Command │ ├── App.config │ ├── Command.csproj │ ├── Command.sln │ ├── ComplexoComando.cs │ ├── Controle.cs │ ├── ICommand.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Receiver.cs │ └── SimplesComando.cs ├── IIterator │ ├── Aggregate.cs │ ├── App.config │ ├── IAggregate.cs │ ├── IIterator.cs │ ├── IIterator.csproj │ ├── IIterator.sln │ ├── Iterator.cs │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Interpreter │ ├── App.config │ ├── ArcoFlecha.cs │ ├── Binoculos.cs │ ├── Bussola.cs │ ├── Contexto.cs │ ├── Corda.cs │ ├── IArmamento.cs │ ├── IExpressao.cs │ ├── IFerramenta.cs │ ├── Interpreter.csproj │ ├── Interpreter.sln │ ├── Mochila.cs │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Mediator │ ├── App.config │ ├── Jogador.cs │ ├── Jogador1.cs │ ├── Jogador2.cs │ ├── Mediador.cs │ ├── MediadorConcreto.cs │ ├── Mediator.csproj │ ├── Mediator.sln │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Memento │ ├── Acao.cs │ ├── App.config │ ├── Armazena.cs │ ├── Memento.cs │ ├── Memento.csproj │ ├── Memento.sln │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Observer │ ├── App.config │ ├── Cody.cs │ ├── IObservador.cs │ ├── IPersonagem.cs │ ├── Inimigo.cs │ ├── Observer.csproj │ ├── Observer.sln │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── State │ ├── App.config │ ├── Contexto.cs │ ├── PersonagemA.cs │ ├── PersonagemB.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── State.cs │ ├── State.csproj │ └── State.sln ├── Strategy │ ├── Ajuda.cs │ ├── App.config │ ├── IAjuda.cs │ ├── Papagaio.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sapo.cs │ ├── Strategy.csproj │ └── Strategy.sln ├── TemplateMethod │ ├── App.config │ ├── Jogo.cs │ ├── ModoDificil.cs │ ├── ModoFacil.cs │ ├── ModoNormal.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── TemplateMethod.csproj │ └── TemplateMethod.sln └── Visitor │ ├── App.config │ ├── Chefao.cs │ ├── FaseJogo.cs │ ├── IJogo.cs │ ├── IVisitor.cs │ ├── NivelVisitor.cs │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Visitor.csproj │ └── Visitor.sln ├── Design Patterns de Criação ├── .DS_Store ├── AbstractFactory │ ├── AbstractFactory.sln │ └── AbstractFactory │ │ ├── AbstractFactory.csproj │ │ ├── App.config │ │ ├── EnergiaBaseProtoss.cs │ │ ├── EnergiaBaseTerran.cs │ │ ├── EnergiaBaseZerg.cs │ │ ├── FabricaBaseProtoss.cs │ │ ├── FabricaBaseTerran.cs │ │ ├── FabricaBaseZerg.cs │ │ ├── IEnergia.cs │ │ ├── IFabricaBases.cs │ │ ├── IRevestimento.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── RevestimentoBaseProtoss.cs │ │ ├── RevestimentoBaseTerran.cs │ │ └── RevestimentoBaseZerg.cs ├── Builder │ ├── Builder.sln │ └── Builder │ │ ├── App.config │ │ ├── Builder.csproj │ │ ├── CriadorDeInfantariaLeve.cs │ │ ├── CriadorDeSoldado.cs │ │ ├── CriadorForcasEspeciais.cs │ │ ├── Exercito.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── SoldadeDeInfantariaLeve.cs │ │ ├── Soldado.cs │ │ └── SoldadoDeForcasEspeciais.cs ├── FactoryMethod │ ├── .vs │ │ └── FactoryMethod │ │ │ └── v15 │ │ │ ├── .suo │ │ │ └── Server │ │ │ └── sqlite3 │ │ │ ├── db.lock │ │ │ ├── storage.ide │ │ │ ├── storage.ide-shm │ │ │ └── storage.ide-wal │ ├── App.config │ ├── FactoryMethod.cs │ ├── FactoryMethod.csproj │ ├── FactoryMethod.sln │ ├── IPersonagem.cs │ ├── LiuKang.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Scorpion.cs │ └── SubZero.cs ├── Prototype │ ├── Prototype.sln │ └── Prototype │ │ ├── App.config │ │ ├── GerenciadorNuvens.cs │ │ ├── NuvemConcreta.cs │ │ ├── NuvemMolde.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── Prototype.csproj │ │ ├── Prototype.sln │ │ └── Prototype │ │ ├── App.config │ │ ├── GerenciadorNuvens.cs │ │ ├── Nuvem.cs │ │ ├── NuvemUm.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── Prototype.csproj └── Singleton │ ├── .vs │ └── Singleton │ │ └── v15 │ │ ├── .suo │ │ └── Server │ │ └── sqlite3 │ │ ├── db.lock │ │ ├── storage.ide │ │ ├── storage.ide-shm │ │ └── storage.ide-wal │ ├── Singleton.sln │ └── Singleton │ ├── App.config │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Singleton.cs │ ├── Singleton.csproj │ ├── bin │ └── Debug │ │ ├── Singleton.exe │ │ ├── Singleton.exe.config │ │ └── Singleton.pdb │ └── obj │ ├── Debug │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ ├── Singleton.csproj.CoreCompileInputs.cache │ ├── Singleton.csproj.FileListAbsolute.txt │ ├── Singleton.csprojAssemblyReference.cache │ ├── Singleton.exe │ ├── Singleton.pdb │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs │ └── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs │ └── Release │ └── Singleton.csproj.CoreCompileInputs.cache ├── Design Patterns de Estrutura ├── .DS_Store ├── Adapter │ ├── Adapter.sln │ └── Adapter │ │ ├── Adapter.cs │ │ ├── Adapter.csproj │ │ ├── App.config │ │ ├── Aviao.cs │ │ ├── IAcao.cs │ │ ├── Personagem.cs │ │ ├── Program.cs │ │ └── Properties │ │ └── AssemblyInfo.cs ├── Bridge │ ├── App.config │ ├── Bridge.cs │ ├── Bridge.csproj │ ├── Bridge.sln │ ├── Forma1.cs │ ├── Forma2.cs │ ├── ICor.cs │ ├── IForma.cs │ ├── Laranja.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Rosa.cs │ └── Verde.cs ├── Composite │ ├── App.config │ ├── ComponenteFase.cs │ ├── Composite.cs │ ├── Composite.csproj │ ├── Composite.sln │ ├── FaseJogo.cs │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Decorator │ ├── App.config │ ├── ArmaduraPadrao.cs │ ├── Capacete.cs │ ├── Decorator.csproj │ ├── Decorator.sln │ ├── DecoratorArmadura.cs │ ├── Espada.cs │ ├── MoldeArmadura.cs │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Facade │ ├── App.config │ ├── Facade.cs │ ├── Facade.csproj │ ├── Facade.sln │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SubSistemaDois.cs │ ├── SubSistemaTres.cs │ └── SubSistemaUm.cs ├── Flyweight │ ├── App.config │ ├── Azul.cs │ ├── Flyweight.cs │ ├── Flyweight.csproj │ ├── Flyweight.sln │ ├── Laranja.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Tartaruga.cs │ ├── Verde.cs │ ├── Vermelha.cs │ └── bloco.cs └── Proxy │ ├── App.config │ ├── FaseJogo.cs │ ├── IFase.cs │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Proxy.csproj │ ├── Proxy.sln │ └── ProxyFase.cs └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/Chain_of_Responsibility.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chain_of_Responsibility", "Chain_of_Responsibility.csproj", "{8C32B2B6-2D55-45C6-AD77-6B17FA1E21A6}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8C32B2B6-2D55-45C6-AD77-6B17FA1E21A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8C32B2B6-2D55-45C6-AD77-6B17FA1E21A6}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8C32B2B6-2D55-45C6-AD77-6B17FA1E21A6}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8C32B2B6-2D55-45C6-AD77-6B17FA1E21A6}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {2D4889E6-9594-497F-9793-678C52137CDB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/Manipulador.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Chain_of_Responsibility 4 | { 5 | public abstract class Manipulador 6 | { 7 | protected Manipulador sucessor; 8 | 9 | public void defineSucessor(Manipulador sucessor) 10 | { 11 | this.sucessor = sucessor; 12 | } 13 | 14 | public abstract void Convoca(int quantidadePoder); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/PersonagemA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Chain_of_Responsibility 4 | { 5 | public class PersonagemA : Manipulador 6 | { 7 | public override void Convoca(int quantidadePoder) 8 | { 9 | if (quantidadePoder >= 0 && quantidadePoder < 10) 10 | Console.WriteLine("{0} convocado para uma força de poder de {1}", this.GetType().Name, quantidadePoder); 11 | else if (sucessor != null) 12 | sucessor.Convoca(quantidadePoder); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/PersonagemB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Chain_of_Responsibility 4 | { 5 | public class PersonagemB : Manipulador 6 | { 7 | public override void Convoca(int quantidadePoder) 8 | { 9 | if (quantidadePoder >= 10 && quantidadePoder < 20) 10 | Console.WriteLine("{0} convocado para uma força de poder de {1}", this.GetType().Name, quantidadePoder); 11 | else if (sucessor != null) 12 | sucessor.Convoca(quantidadePoder); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/PersonagemC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Chain_of_Responsibility 4 | { 5 | public class PersonagemC : Manipulador 6 | { 7 | public override void Convoca(int quantidadePoder) 8 | { 9 | if (quantidadePoder >= 20 && quantidadePoder < 30) 10 | Console.WriteLine("{0} convocado para uma força de poder de {1}", this.GetType().Name, quantidadePoder); 11 | else if (sucessor != null) 12 | sucessor.Convoca(quantidadePoder); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Chain_of_Responsibility 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Manipulador pA = new PersonagemA(); 10 | Manipulador pB = new PersonagemB(); 11 | Manipulador pC = new PersonagemC(); 12 | 13 | pA.defineSucessor(pB); 14 | pB.defineSucessor(pC); 15 | 16 | int[] requisicoes = { 5, 8, 15, 20, 18, 3, 27, 20 }; 17 | 18 | foreach (int req in requisicoes) 19 | { 20 | pA.Convoca(req); 21 | } 22 | 23 | Console.ReadKey(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Chain_of_Responsibility/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Chain_of_Responsibility")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Chain_of_Responsibility")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("8c32b2b6-2d55-45c6-ad77-6b17fa1e21a6")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/Command.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Command", "Command.csproj", "{3F369268-29AC-4073-9D65-BAF5CDEFAE1D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3F369268-29AC-4073-9D65-BAF5CDEFAE1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3F369268-29AC-4073-9D65-BAF5CDEFAE1D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3F369268-29AC-4073-9D65-BAF5CDEFAE1D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3F369268-29AC-4073-9D65-BAF5CDEFAE1D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {277A47A0-FF64-4D36-B5A2-81C79E46D85E} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/ComplexoComando.cs: -------------------------------------------------------------------------------- 1 |  namespace Command 2 | { 3 | public class ComplexoComando : ICommand 4 | { 5 | private Receiver _receiver; 6 | private string _a; 7 | private string _b; 8 | 9 | public ComplexoComando(Receiver receiver, string a, string b) 10 | { 11 | this._receiver = receiver; 12 | this._a = a; 13 | this._b = b; 14 | } 15 | 16 | public void Executar() 17 | { 18 | this._receiver.PrimeiroPedido(this._a); 19 | this._receiver.SegundoPedido(this._b); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/Controle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Command 4 | { 5 | public class Controle 6 | { 7 | private ICommand comandoSimples; 8 | private ICommand comandoComplexo; 9 | 10 | public void EnviarComandoSimples(ICommand command) 11 | { 12 | this.comandoSimples = command; 13 | } 14 | 15 | public void EnviarComandoComplexo(ICommand command) 16 | { 17 | this.comandoComplexo = command; 18 | } 19 | 20 | public void Fazer() 21 | { 22 | Console.WriteLine("Ok, vou executar para você!"); 23 | if (this.comandoSimples is ICommand) 24 | this.comandoSimples.Executar(); 25 | 26 | if (this.comandoComplexo is ICommand) 27 | this.comandoComplexo.Executar(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/ICommand.cs: -------------------------------------------------------------------------------- 1 | namespace Command 2 | { 3 | public interface ICommand 4 | { 5 | void Executar(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Command 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Controle controle = new Controle(); 10 | controle.EnviarComandoSimples(new SimplesComando("Dizer Oi!")); 11 | 12 | Receiver receiver = new Receiver(); 13 | controle.EnviarComandoComplexo(new ComplexoComando(receiver, "Abastecer o carro", "Calibrar os pneus do carro")); 14 | 15 | controle.Fazer(); 16 | Console.ReadKey(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Command")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Command")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("3f369268-29ac-4073-9d65-baf5cdefae1d")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/Receiver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Command 4 | { 5 | public class Receiver 6 | { 7 | public void PrimeiroPedido(string a) 8 | { 9 | Console.WriteLine("Comando Recebido: " + a); 10 | } 11 | 12 | public void SegundoPedido(string b) 13 | { 14 | Console.WriteLine("Outro Comando Recebido: " + b); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Command/SimplesComando.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Command 4 | { 5 | public class SimplesComando : ICommand 6 | { 7 | private string _solicitacao = string.Empty; 8 | 9 | public SimplesComando(string solicitacao) 10 | { 11 | this._solicitacao = solicitacao; 12 | } 13 | 14 | public void Executar() 15 | { 16 | Console.WriteLine("Estou executando Comando de " + this._solicitacao); 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/Aggregate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace IIterator 4 | { 5 | public class Aggregate : IAggregate 6 | { 7 | List colecao = null; 8 | 9 | public Aggregate() 10 | { 11 | colecao = new List(); 12 | } 13 | 14 | public IIterator GetIterator() 15 | { 16 | return new Iterator(this); 17 | } 18 | 19 | public string this[int indexItem] 20 | { 21 | get 22 | { 23 | if (indexItem < colecao.Count) 24 | { 25 | return colecao[indexItem]; 26 | } 27 | else 28 | { 29 | return string.Empty; 30 | } 31 | } 32 | set 33 | { 34 | colecao.Add(value); 35 | } 36 | } 37 | 38 | public int Contador 39 | { 40 | get 41 | { 42 | return colecao.Count; 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/IAggregate.cs: -------------------------------------------------------------------------------- 1 | namespace IIterator 2 | { 3 | public interface IAggregate 4 | { 5 | IIterator GetIterator(); 6 | string this[int indexItem] { set; get; } 7 | int Contador { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/IIterator.cs: -------------------------------------------------------------------------------- 1 | namespace IIterator 2 | { 3 | public interface IIterator 4 | { 5 | string primeiroItem { get; } 6 | string proximoItem { get; } 7 | string atualItem { get; } 8 | bool estaPronto { get; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/IIterator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B81769B6-2297-47BC-A369-356F2EE5F202} 8 | Exe 9 | IIterator 10 | IIterator 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/IIterator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IIterator", "IIterator.csproj", "{B81769B6-2297-47BC-A369-356F2EE5F202}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B81769B6-2297-47BC-A369-356F2EE5F202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B81769B6-2297-47BC-A369-356F2EE5F202}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B81769B6-2297-47BC-A369-356F2EE5F202}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B81769B6-2297-47BC-A369-356F2EE5F202}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {DD4F7655-7AE3-497A-9FFB-6C72AC3CFF9A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/Iterator.cs: -------------------------------------------------------------------------------- 1 | namespace IIterator 2 | { 3 | public class Iterator : IIterator 4 | { 5 | IAggregate colecao = null; 6 | int atualIndex = 0; 7 | 8 | public Iterator(IAggregate colecao) 9 | { 10 | this.colecao = colecao; 11 | } 12 | 13 | public string primeiroItem 14 | { 15 | get 16 | { 17 | atualIndex = 0; 18 | return colecao[atualIndex]; 19 | } 20 | } 21 | 22 | public string proximoItem 23 | { 24 | get 25 | { 26 | atualIndex += 1; 27 | 28 | if (estaPronto == false) 29 | { 30 | return colecao[atualIndex]; 31 | } 32 | else 33 | { 34 | return string.Empty; 35 | } 36 | } 37 | } 38 | 39 | public string atualItem 40 | { 41 | get 42 | { 43 | return colecao[atualIndex]; 44 | } 45 | } 46 | 47 | public bool estaPronto 48 | { 49 | get 50 | { 51 | if (atualIndex < colecao.Contador) 52 | { 53 | return false; 54 | } 55 | return true; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IIterator 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Aggregate colecaoDeFases = new Aggregate(); 10 | 11 | colecaoDeFases[0] = "Fase 1"; 12 | colecaoDeFases[1] = "Fase 2"; 13 | colecaoDeFases[2] = "Fase 3"; 14 | colecaoDeFases[3] = "Fase 4"; 15 | colecaoDeFases[4] = "Fase 5"; 16 | 17 | IIterator iterator = colecaoDeFases.GetIterator(); 18 | 19 | for (string s = iterator.primeiroItem; iterator.estaPronto == false; s = iterator.proximoItem) 20 | { 21 | Console.WriteLine(s); 22 | } 23 | 24 | Console.ReadKey(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/IIterator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("IIterator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IIterator")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("b81769b6-2297-47bc-a369-356f2ee5f202")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/ArcoFlecha.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public class ArcoFlecha : IArmamento 4 | { 5 | public void Interpretar(Contexto contexto) 6 | { 7 | contexto.Conteudo += string.Format(" {0} ", " Arco e Flecha "); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Binoculos.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public class Binoculos : IFerramenta 4 | { 5 | public void Interpretar(Contexto contexto) 6 | { 7 | contexto.Conteudo += string.Format(" {0} ", " Binóculos "); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Bussola.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public class Bussola : IFerramenta 4 | { 5 | public void Interpretar(Contexto contexto) 6 | { 7 | contexto.Conteudo += string.Format(" {0} ", " Bússola "); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Contexto.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public class Contexto 4 | { 5 | public string Conteudo { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Corda.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public class Corda : IFerramenta 4 | { 5 | public void Interpretar(Contexto contexto) 6 | { 7 | contexto.Conteudo += string.Format(" {0} ", " Corda "); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/IArmamento.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public interface IArmamento : IExpressao 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/IExpressao.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public interface IExpressao 4 | { 5 | void Interpretar(Contexto contexto); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/IFerramenta.cs: -------------------------------------------------------------------------------- 1 | namespace Interpreter 2 | { 3 | public interface IFerramenta : IExpressao 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Interpreter.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interpreter", "Interpreter.csproj", "{C4640493-A618-4013-9F9D-E8DC34E6761F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C4640493-A618-4013-9F9D-E8DC34E6761F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C4640493-A618-4013-9F9D-E8DC34E6761F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C4640493-A618-4013-9F9D-E8DC34E6761F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C4640493-A618-4013-9F9D-E8DC34E6761F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {B192B110-2BDC-4A8D-9EDB-A433A72BB872} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Mochila.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Interpreter 4 | { 5 | public class Mochila : IExpressao 6 | { 7 | private IFerramenta ferramenta_principal; 8 | private IFerramenta ferramenta_secundaria; 9 | private IArmamento armamento; 10 | 11 | public Mochila(IFerramenta ferramenta_principal, IFerramenta ferramenta_secundaria, IArmamento armamento) 12 | { 13 | this.ferramenta_principal = ferramenta_principal; 14 | this.ferramenta_secundaria = ferramenta_secundaria; 15 | this.armamento = armamento; 16 | } 17 | 18 | public void Interpretar(Contexto contexto) 19 | { 20 | contexto.Conteudo += "Abrindo mochila... \n"; 21 | armamento.Interpretar(contexto); 22 | contexto.Conteudo += "- 1º Ferramenta"; 23 | ferramenta_principal.Interpretar(contexto); 24 | contexto.Conteudo += "- 2º Ferramenta"; 25 | ferramenta_secundaria.Interpretar(contexto); 26 | contexto.Conteudo += "\n... Fechando mochila"; 27 | 28 | Console.WriteLine(contexto.Conteudo); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Interpreter 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Mochila mochila = new Mochila(new Corda(), new Binoculos(), new ArcoFlecha()); 10 | mochila.Interpretar(new Contexto()); 11 | Console.ReadKey(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Interpreter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Interpreter2")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Interpreter2")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("c4640493-a618-4013-9f9d-e8dc34e6761f")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/Jogador.cs: -------------------------------------------------------------------------------- 1 | namespace Mediator 2 | { 3 | public abstract class Jogador 4 | { 5 | protected Mediador mediador; 6 | 7 | public Jogador(Mediador mediador) 8 | { 9 | this.mediador = mediador; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/Jogador1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mediator 4 | { 5 | public class Jogador1 : Jogador 6 | { 7 | public Jogador1(Mediador mediador) : base(mediador) {} 8 | 9 | public void Enviar(string mensagem) 10 | { 11 | mediador.Enviar(mensagem, this); 12 | } 13 | 14 | public void Notificar(string mensagem) 15 | { 16 | Console.WriteLine("Mensagem do Jogador 1: " + mensagem); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/Jogador2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mediator 4 | { 5 | public class Jogador2 : Jogador 6 | { 7 | public Jogador2(Mediador mediador) : base(mediador) {} 8 | 9 | public void Enviar(string mensagem) 10 | { 11 | mediador.Enviar(mensagem, this); 12 | } 13 | 14 | public void Notificar(string mensagem) 15 | { 16 | Console.WriteLine("Mensagem do Jogador 2: " + mensagem); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/Mediador.cs: -------------------------------------------------------------------------------- 1 | namespace Mediator 2 | { 3 | public abstract class Mediador 4 | { 5 | public abstract void Enviar(string mensagem, Jogador jogador); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/MediadorConcreto.cs: -------------------------------------------------------------------------------- 1 | namespace Mediator 2 | { 3 | public class MediadorConcreto : Mediador 4 | { 5 | private Jogador1 j1; 6 | private Jogador2 j2; 7 | 8 | public Jogador1 Jogador1 9 | { 10 | set { j1 = value; } 11 | } 12 | 13 | public Jogador2 Jogador2 14 | { 15 | set { j2 = value; } 16 | } 17 | 18 | public override void Enviar(string mensagem, Jogador jogador) 19 | { 20 | if (jogador == j2) 21 | j1.Notificar(mensagem); 22 | else 23 | j2.Notificar(mensagem); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/Mediator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mediator", "Mediator.csproj", "{C80F2498-2CED-4B3A-8A86-1DC736A01A8F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C80F2498-2CED-4B3A-8A86-1DC736A01A8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C80F2498-2CED-4B3A-8A86-1DC736A01A8F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C80F2498-2CED-4B3A-8A86-1DC736A01A8F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C80F2498-2CED-4B3A-8A86-1DC736A01A8F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {7C10CE73-5ECD-4428-9182-6F0B727E5241} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mediator 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | MediadorConcreto mediador = new MediadorConcreto(); 10 | 11 | Jogador1 j1 = new Jogador1(mediador); 12 | Jogador2 j2 = new Jogador2(mediador); 13 | 14 | mediador.Jogador1 = j1; 15 | mediador.Jogador2 = j2; 16 | 17 | j1.Enviar("Essa partida foi muito boa!"); 18 | j2.Enviar("Foi sensacional. Conseguimos uma ótima pontuação!"); 19 | 20 | Console.ReadKey(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Mediator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Mediator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Mediator")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("c80f2498-2ced-4b3a-8a86-1dc736a01a8f")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/Acao.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Memento 4 | { 5 | public class Acao 6 | { 7 | private string _estado; 8 | 9 | public string Estado 10 | { 11 | get { return _estado; } 12 | set 13 | { 14 | _estado = value; 15 | Console.WriteLine("Estado do Jogo = " + _estado); 16 | } 17 | } 18 | 19 | public Memento CriarMemento() 20 | { 21 | return (new Memento(_estado)); 22 | } 23 | 24 | public void RestaurarEstado(Memento memento) 25 | { 26 | Console.WriteLine("Restaurando o estado..."); 27 | Estado = memento.Estado; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/Armazena.cs: -------------------------------------------------------------------------------- 1 | namespace Memento 2 | { 3 | public class Armazena 4 | { 5 | public Memento Memento { get; set; } 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/Memento.cs: -------------------------------------------------------------------------------- 1 | namespace Memento 2 | { 3 | public class Memento 4 | { 5 | private string _estado; 6 | 7 | public Memento(string estado) 8 | { 9 | this._estado = estado; 10 | } 11 | 12 | public string Estado 13 | { 14 | get { return _estado; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/Memento.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {0635436A-FBAC-4268-8DF5-D08446271FE1} 8 | Exe 9 | Memento 10 | Memento 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/Memento.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Memento", "Memento.csproj", "{0635436A-FBAC-4268-8DF5-D08446271FE1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {0635436A-FBAC-4268-8DF5-D08446271FE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {0635436A-FBAC-4268-8DF5-D08446271FE1}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {0635436A-FBAC-4268-8DF5-D08446271FE1}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {0635436A-FBAC-4268-8DF5-D08446271FE1}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {F61F8FA3-A787-4E50-88B1-BF791993E26B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Memento 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Acao acao = new Acao(); 10 | acao.Estado = "play"; 11 | 12 | Armazena armazena = new Armazena(); 13 | armazena.Memento = acao.CriarMemento(); 14 | 15 | acao.Estado = "pause"; 16 | acao.RestaurarEstado(armazena.Memento); 17 | 18 | Console.ReadKey(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Memento/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Memento")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Memento")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("0635436a-fbac-4268-8df5-d08446271fe1")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/Cody.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Observer 4 | { 5 | public class Cody : IPersonagem 6 | { 7 | private List inimigos = new List(); 8 | public int vida = 100; 9 | 10 | public void NotificarPersonagens() 11 | { 12 | foreach (IObservador i in inimigos) 13 | { 14 | i.Avisar(this); 15 | } 16 | } 17 | 18 | public void RegistrarObservador(IObservador i) 19 | { 20 | inimigos.Add(i); 21 | } 22 | 23 | public void Golpe_Acertado(bool golpe) 24 | { 25 | if (golpe) 26 | vida -= 10; 27 | 28 | NotificarPersonagens(); 29 | } 30 | 31 | public int getVida() 32 | { 33 | return vida; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/IObservador.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace Observer 5 | { 6 | public interface IObservador 7 | { 8 | void Avisar(IPersonagem personagem); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/IPersonagem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Observer 4 | { 5 | public interface IPersonagem 6 | { 7 | void RegistrarObservador(IObservador observador); 8 | void NotificarPersonagens(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/Inimigo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Observer 4 | { 5 | class Inimigo : IObservador 6 | { 7 | 8 | private Cody personagemObservado; 9 | 10 | public void Avisar(IPersonagem personagem) 11 | { 12 | if (personagem == personagemObservado) 13 | { 14 | Console.WriteLine("o Cody foi acertado com um golpe, agora sua vida de jogo é de: " + personagemObservado.getVida()); 15 | } 16 | } 17 | 18 | public Inimigo(Cody cody) 19 | { 20 | personagemObservado = cody; 21 | personagemObservado.RegistrarObservador(this); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/Observer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {DDA7E893-D9CA-4FC3-AC45-48E4805347C1} 8 | Exe 9 | Observer 10 | Observer 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/Observer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Observer", "Observer.csproj", "{DDA7E893-D9CA-4FC3-AC45-48E4805347C1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {DDA7E893-D9CA-4FC3-AC45-48E4805347C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {DDA7E893-D9CA-4FC3-AC45-48E4805347C1}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {DDA7E893-D9CA-4FC3-AC45-48E4805347C1}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {DDA7E893-D9CA-4FC3-AC45-48E4805347C1}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3954DA20-CFBB-4F08-B09D-C281E371BE52} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Observer 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Cody cody = new Cody(); 10 | 11 | Inimigo inimigo1 = new Inimigo(cody); 12 | Inimigo inimigo2 = new Inimigo(cody); 13 | Inimigo inimigo3 = new Inimigo(cody); 14 | 15 | while(true) 16 | { 17 | Console.WriteLine("Acertar o Cody com um golpe (S ou N)?"); 18 | 19 | if (Console.ReadLine() == "s") 20 | cody.Golpe_Acertado(true); 21 | else 22 | Console.WriteLine("Você não acertou o Cody!"); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Observer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Observer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Observer")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("dda7e893-d9ca-4fc3-ac45-48e4805347c1")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/Contexto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace State 4 | { 5 | public class Contexto 6 | { 7 | private State _estado; 8 | 9 | public Contexto(State estado) 10 | { 11 | this._estado = estado; 12 | } 13 | 14 | public State State 15 | { 16 | get { return _estado; } 17 | set 18 | { 19 | _estado = value; 20 | Console.WriteLine("Agora o comportamento é de: " + _estado.GetType().Name); 21 | } 22 | } 23 | 24 | public void Troca() 25 | { 26 | _estado.Acao(this); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/PersonagemA.cs: -------------------------------------------------------------------------------- 1 | namespace State 2 | { 3 | public class PersonagemA : State 4 | { 5 | public override void Acao(Contexto contexto) 6 | { 7 | contexto.State = new PersonagemB(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/PersonagemB.cs: -------------------------------------------------------------------------------- 1 | namespace State 2 | { 3 | public class PersonagemB : State 4 | { 5 | public override void Acao(Contexto contexto) 6 | { 7 | contexto.State = new PersonagemA(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace State 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Contexto contexto = new Contexto(new PersonagemA()); 10 | 11 | contexto.Troca(); 12 | contexto.Troca(); 13 | contexto.Troca(); 14 | contexto.Troca(); 15 | 16 | Console.ReadKey(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("State")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("State")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("c9b88c63-8abd-40ee-9496-c63fc5a48f95")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/State.cs: -------------------------------------------------------------------------------- 1 | namespace State 2 | { 3 | public abstract class State 4 | { 5 | public abstract void Acao(Contexto contexto); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/State.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C9B88C63-8ABD-40EE-9496-C63FC5A48F95} 8 | Exe 9 | State 10 | State 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/State/State.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "State", "State.csproj", "{C9B88C63-8ABD-40EE-9496-C63FC5A48F95}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C9B88C63-8ABD-40EE-9496-C63FC5A48F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C9B88C63-8ABD-40EE-9496-C63FC5A48F95}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C9B88C63-8ABD-40EE-9496-C63FC5A48F95}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C9B88C63-8ABD-40EE-9496-C63FC5A48F95}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {E9E99104-4CB9-4D9B-B7DF-2E7FC9A98590} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/Ajuda.cs: -------------------------------------------------------------------------------- 1 | namespace Strategy 2 | { 3 | public class Ajuda 4 | { 5 | private IAjuda _IAjuda; 6 | 7 | public Ajuda(IAjuda ajuda) 8 | { 9 | _IAjuda = ajuda; 10 | } 11 | 12 | public string Ajudar() 13 | { 14 | return _IAjuda.Ajudar(this); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/IAjuda.cs: -------------------------------------------------------------------------------- 1 | namespace Strategy 2 | { 3 | public interface IAjuda 4 | { 5 | string Ajudar(Ajuda pedido); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/Papagaio.cs: -------------------------------------------------------------------------------- 1 | namespace Strategy 2 | { 3 | public class Papagaio : IAjuda 4 | { 5 | public string Ajudar(Ajuda pedido) 6 | { 7 | return "Sou um Papagaio e posso ajudar você a vooar!"; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Strategy 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var papagaio = new Ajuda(new Papagaio()); 10 | Console.WriteLine(papagaio.Ajudar()); 11 | 12 | var sapo = new Ajuda(new Sapo()); 13 | Console.WriteLine(sapo.Ajudar()); 14 | 15 | Console.ReadKey(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Strategy")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Strategy")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("34898974-4f8b-44d3-9170-deb7d79bff46")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/Sapo.cs: -------------------------------------------------------------------------------- 1 | namespace Strategy 2 | { 3 | public class Sapo : IAjuda 4 | { 5 | public string Ajudar(Ajuda pedido) 6 | { 7 | return "Sou um sapo e posso ajudar você a pular bem alto!"; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/Strategy.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {34898974-4F8B-44D3-9170-DEB7D79BFF46} 8 | Exe 9 | Strategy 10 | Strategy 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Strategy/Strategy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Strategy", "Strategy.csproj", "{34898974-4F8B-44D3-9170-DEB7D79BFF46}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {34898974-4F8B-44D3-9170-DEB7D79BFF46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {34898974-4F8B-44D3-9170-DEB7D79BFF46}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {34898974-4F8B-44D3-9170-DEB7D79BFF46}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {34898974-4F8B-44D3-9170-DEB7D79BFF46}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {70304C0A-60CF-4092-BB33-528288B4776B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/Jogo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TemplateMethod 4 | { 5 | public abstract class Jogo 6 | { 7 | public Jogo() 8 | { 9 | TrilhaSonora(); 10 | PrimeiraFase(); 11 | SegundaFase(); 12 | } 13 | 14 | public abstract void PrimeiraFase(); 15 | public abstract void SegundaFase(); 16 | 17 | private void TrilhaSonora() 18 | { 19 | Console.WriteLine("Música emocionante"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/ModoDificil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TemplateMethod 4 | { 5 | public class ModoDificil : Jogo 6 | { 7 | public override void PrimeiraFase() 8 | { 9 | Console.WriteLine("Adicionar obstáculo na pista"); 10 | } 11 | 12 | public override void SegundaFase() 13 | { 14 | Console.WriteLine("Carros adversário devem correr mais"); 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/ModoFacil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TemplateMethod 4 | { 5 | public class ModoFacil : Jogo 6 | { 7 | public override void PrimeiraFase() 8 | { 9 | Console.WriteLine("Combustível para a corrida toda"); 10 | } 11 | 12 | public override void SegundaFase() 13 | { 14 | Console.WriteLine("Carros adversários devem correr menos"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/ModoNormal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TemplateMethod 4 | { 5 | public class ModoNormal : Jogo 6 | { 7 | public override void PrimeiraFase() 8 | { 9 | Console.WriteLine("O carro precisa abastecer uma vez"); 10 | } 11 | 12 | public override void SegundaFase() 13 | { 14 | Console.WriteLine("Os carros devem correr a mesma velocidade"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TemplateMethod 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("### Escolha o modo de corrida ###"); 10 | Console.WriteLine("1-Fácil | 2-Normal | 3-Díficil"); 11 | 12 | Console.WriteLine("Suas condições de jogo são: "); 13 | Jogo jogo = null; 14 | 15 | switch (Console.ReadLine()) 16 | { 17 | case "1": jogo = new ModoFacil(); break; 18 | case "2": jogo = new ModoNormal(); break; 19 | case "3": jogo = new ModoDificil(); break; 20 | } 21 | 22 | Console.ReadKey(); 23 | 24 | 25 | 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("TemplateMethod")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TemplateMethod")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("a741bb01-3287-4d90-8e18-b093671f3fa4")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/TemplateMethod.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A741BB01-3287-4D90-8E18-B093671F3FA4} 8 | Exe 9 | TemplateMethod 10 | TemplateMethod 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/TemplateMethod/TemplateMethod.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplateMethod", "TemplateMethod.csproj", "{A741BB01-3287-4D90-8E18-B093671F3FA4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A741BB01-3287-4D90-8E18-B093671F3FA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A741BB01-3287-4D90-8E18-B093671F3FA4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A741BB01-3287-4D90-8E18-B093671F3FA4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A741BB01-3287-4D90-8E18-B093671F3FA4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {72D58227-CABE-4A8E-972B-A655D983E764} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/Chefao.cs: -------------------------------------------------------------------------------- 1 | namespace Visitor 2 | { 3 | public class Chefao : IJogo 4 | { 5 | public string NomeChefao { get; set; } 6 | public int PontosVida { get; set; } 7 | 8 | public void Visitante(IVisitor visitante) 9 | { 10 | visitante.Identificar(this); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/FaseJogo.cs: -------------------------------------------------------------------------------- 1 | namespace Visitor 2 | { 3 | public class FaseJogo : IJogo 4 | { 5 | public string NomeFase { get; set; } 6 | 7 | public void Visitante(IVisitor visitor) 8 | { 9 | visitor.Identificar(this); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/IJogo.cs: -------------------------------------------------------------------------------- 1 | namespace Visitor 2 | { 3 | public interface IJogo 4 | { 5 | void Visitante(IVisitor visitante); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/IVisitor.cs: -------------------------------------------------------------------------------- 1 | namespace Visitor 2 | { 3 | public interface IVisitor 4 | { 5 | void Identificar(Chefao chefao); 6 | void Identificar(FaseJogo fasejogo); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/NivelVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Visitor 4 | { 5 | public class NivelVisitor : IVisitor 6 | { 7 | public void Identificar(FaseJogo fase) 8 | { 9 | switch (fase.NomeFase) 10 | { 11 | case "Floresta": 12 | Console.WriteLine("A fase {0} no jogo é {1}% difícil", fase.NomeFase, 70); 13 | break; 14 | case "Caverna": 15 | Console.WriteLine("A fase {0} no jogo é {1}% difícil", fase.NomeFase, 30); 16 | break; 17 | } 18 | } 19 | 20 | public void Identificar(Chefao chefao) 21 | { 22 | switch (chefao.NomeChefao) 23 | { 24 | case "Boss 1": 25 | Console.WriteLine("O chefão {0} é {1}% difícil e tem {2} pontos de vida.", chefao.NomeChefao, 25, chefao.PontosVida); 26 | break; 27 | case "Boss 2": 28 | Console.WriteLine("O chefão {0} é {1}% difícil e tem {2} pontos de vida.", chefao.NomeChefao, 50, chefao.PontosVida); 29 | break; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Visitor 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | List jogo = new List(); 11 | jogo.Add(new FaseJogo() { NomeFase = "Floresta"}); 12 | jogo.Add(new FaseJogo() { NomeFase = "Caverna" }); 13 | jogo.Add(new Chefao() { NomeChefao = "Boss 1", PontosVida = 30 }); 14 | jogo.Add(new Chefao() { NomeChefao = "Boss 2", PontosVida = 50 }); 15 | 16 | NivelVisitor niveis = new NivelVisitor(); 17 | foreach (var etapa in jogo) 18 | { 19 | etapa.Visitante(niveis); 20 | } 21 | 22 | Console.ReadLine(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Visitor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Visitor")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("1f5ad8f1-9fd3-4ce9-af1b-bc3524a4751a")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/Visitor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1F5AD8F1-9FD3-4CE9-AF1B-BC3524A4751A} 8 | Exe 9 | Visitor 10 | Visitor 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Design Patterns de Comportamento/Visitor/Visitor.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Visitor", "Visitor.csproj", "{1F5AD8F1-9FD3-4CE9-AF1B-BC3524A4751A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F5AD8F1-9FD3-4CE9-AF1B-BC3524A4751A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F5AD8F1-9FD3-4CE9-AF1B-BC3524A4751A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F5AD8F1-9FD3-4CE9-AF1B-BC3524A4751A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F5AD8F1-9FD3-4CE9-AF1B-BC3524A4751A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {838EC8F1-6339-410E-8820-DB58BD6C0FCA} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Criação/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/.DS_Store -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2037 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractFactory", "AbstractFactory\AbstractFactory.csproj", "{27DB1A8A-CA28-40CF-9DF2-8B857D720FEF}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {27DB1A8A-CA28-40CF-9DF2-8B857D720FEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {27DB1A8A-CA28-40CF-9DF2-8B857D720FEF}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {27DB1A8A-CA28-40CF-9DF2-8B857D720FEF}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {27DB1A8A-CA28-40CF-9DF2-8B857D720FEF}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {E9ABBCC5-CD0E-49BD-8490-ED2A085EB72C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/EnergiaBaseProtoss.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class EnergiaBaseProtoss : IEnergia 6 | { 7 | public void Composicao() 8 | { 9 | Console.WriteLine("Energia de sustentação da base com cristais"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/EnergiaBaseTerran.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class EnergiaBaseTerran : IEnergia 6 | { 7 | public void Composicao() 8 | { 9 | Console.WriteLine("Energia de sustentação da base mecânica"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/EnergiaBaseZerg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace AbstractFactory 5 | { 6 | public class EnergiaBaseZerg : IEnergia 7 | { 8 | public void Composicao() 9 | { 10 | Console.WriteLine("Energia de sustentação da base pela terra"); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/FabricaBaseProtoss.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class FabricaBaseProtoss : IFabricaBases 6 | { 7 | public FabricaBaseProtoss() 8 | { 9 | CriarBase(); 10 | } 11 | 12 | public void CriarBase() 13 | { 14 | Console.WriteLine("Base Protoss criada com sucesso!"); 15 | 16 | RevestimentoBaseProtoss revestimento = new RevestimentoBaseProtoss(); 17 | revestimento.Composicao(); 18 | 19 | EnergiaBaseProtoss energia = new EnergiaBaseProtoss(); 20 | energia.Composicao(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/FabricaBaseTerran.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class FabricaBaseTerran : IFabricaBases 6 | { 7 | public FabricaBaseTerran() 8 | { 9 | CriarBase(); 10 | } 11 | public void CriarBase() 12 | { 13 | Console.WriteLine("Base Terran criada com sucesso!"); 14 | 15 | RevestimentoBaseTerran revestimento = new RevestimentoBaseTerran(); 16 | revestimento.Composicao(); 17 | 18 | EnergiaBaseTerran energia = new EnergiaBaseTerran(); 19 | energia.Composicao(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/FabricaBaseZerg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class FabricaBaseZerg : IFabricaBases 6 | { 7 | public FabricaBaseZerg() 8 | { 9 | CriarBase(); 10 | } 11 | 12 | public void CriarBase() 13 | { 14 | Console.WriteLine("Base Zerg criada com sucesso!"); 15 | 16 | RevestimentoBaseZerg revestimento = new RevestimentoBaseZerg(); 17 | revestimento.Composicao(); 18 | 19 | EnergiaBaseZerg energia = new EnergiaBaseZerg(); 20 | energia.Composicao(); 21 | 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/IEnergia.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public interface IEnergia 6 | { 7 | void Composicao(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/IFabricaBases.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace AbstractFactory 5 | { 6 | public interface IFabricaBases 7 | { 8 | void CriarBase(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/IRevestimento.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace AbstractFactory 5 | { 6 | public interface IRevestimento 7 | { 8 | void Composicao(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace AbstractFactory 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | IFabricaBases fabrica; 11 | Console.Write("Escolha um dos personagens: 1-Protoss | 2-Zergs | 3-Terranos: "); 12 | 13 | switch (Console.ReadLine()) 14 | { 15 | case "1": 16 | fabrica = new FabricaBaseProtoss(); 17 | break; 18 | case "2": 19 | fabrica = new FabricaBaseZerg(); 20 | break; 21 | case "3": 22 | fabrica = new FabricaBaseTerran(); 23 | break; 24 | } 25 | 26 | Console.ReadLine(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("AbstractFactory")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AbstractFactory")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("27db1a8a-ca28-40cf-9df2-8b857d720fef")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/RevestimentoBaseProtoss.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class RevestimentoBaseProtoss : IRevestimento 6 | { 7 | public void Composicao() 8 | { 9 | Console.WriteLine("Base revestida pela cor amarela"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/RevestimentoBaseTerran.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class RevestimentoBaseTerran : IRevestimento 6 | { 7 | public void Composicao() 8 | { 9 | Console.WriteLine("Base revestida pela cor verde"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/AbstractFactory/AbstractFactory/RevestimentoBaseZerg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AbstractFactory 4 | { 5 | public class RevestimentoBaseZerg : IRevestimento 6 | { 7 | public void Composicao() 8 | { 9 | Console.WriteLine("Base revestida pela cor vermelha"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{CC6CA7BD-8A65-4E04-BFA1-502B7F126B69}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CC6CA7BD-8A65-4E04-BFA1-502B7F126B69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {CC6CA7BD-8A65-4E04-BFA1-502B7F126B69}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {CC6CA7BD-8A65-4E04-BFA1-502B7F126B69}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {CC6CA7BD-8A65-4E04-BFA1-502B7F126B69}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {E45B7395-7155-4988-9424-DBACE92B4E07} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/CriadorDeInfantariaLeve.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Builder 4 | { 5 | public class CriadorDeInfantariaLeve : CriadorDeSoldado 6 | { 7 | public CriadorDeInfantariaLeve() 8 | { 9 | _soldado = new SoldadeDeInfantariaLeve(); 10 | } 11 | 12 | public override void Arma() 13 | { 14 | _soldado.EscolherArma("Ataque aéreo"); 15 | } 16 | 17 | public override void Transporte() 18 | { 19 | _soldado.EscolherTransporte("Helicóptero de ataque do Exército"); 20 | } 21 | 22 | public override void Foco() 23 | { 24 | _soldado.DefinirFoco("resposta rápida aérea"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/CriadorDeSoldado.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Builder 4 | { 5 | public abstract class CriadorDeSoldado 6 | { 7 | protected Soldado _soldado; 8 | 9 | public Soldado ObterSoldado() 10 | { 11 | return _soldado; 12 | } 13 | 14 | public abstract void Arma(); 15 | public abstract void Transporte(); 16 | public abstract void Foco(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/CriadorForcasEspeciais.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Builder 4 | { 5 | public class CriadorForcasEspeciais : CriadorDeSoldado 6 | { 7 | public CriadorForcasEspeciais() 8 | { 9 | _soldado = new SoldadoDeForcasEspeciais(); 10 | } 11 | 12 | public override void Arma() 13 | { 14 | _soldado.EscolherArma("Fuzil"); 15 | } 16 | 17 | public override void Transporte() 18 | { 19 | _soldado.EscolherTransporte("Carro de operações especiais"); 20 | } 21 | 22 | public override void Foco() 23 | { 24 | _soldado.DefinirFoco("combate em solo"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/Exercito.cs: -------------------------------------------------------------------------------- 1 |  using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Builder 5 | { 6 | public class Exercito 7 | { 8 | public void ConstruirSoldado(CriadorDeSoldado criadorDeSoldado) 9 | { 10 | criadorDeSoldado.Arma(); 11 | criadorDeSoldado.Transporte(); 12 | criadorDeSoldado.Foco(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Builder 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var exercito = new Exercito(); 10 | CriadorDeSoldado criadorDeSoldado; 11 | Soldado soldado; 12 | 13 | // criando um soldado das Forças Especiais 14 | criadorDeSoldado = new CriadorForcasEspeciais(); 15 | exercito.ConstruirSoldado(criadorDeSoldado); 16 | soldado = criadorDeSoldado.ObterSoldado(); 17 | Console.WriteLine("Soldado com as características: {0}, {1}, {2}", 18 | soldado.Arma, soldado.Transporte, soldado.Foco); 19 | 20 | // criando o soldado de Infantaria Leve 21 | criadorDeSoldado = new CriadorDeInfantariaLeve(); 22 | exercito.ConstruirSoldado(criadorDeSoldado); 23 | soldado = criadorDeSoldado.ObterSoldado(); 24 | Console.WriteLine("Soldado com as características: {0}, {1}, {2}", 25 | soldado.Arma, soldado.Transporte, soldado.Foco); 26 | 27 | Console.ReadKey(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Builder")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Builder")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("cc6ca7bd-8a65-4e04-bfa1-502b7f126b69")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/SoldadeDeInfantariaLeve.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Builder 4 | { 5 | public class SoldadeDeInfantariaLeve : Soldado 6 | { 7 | public override void EscolherArma(string arma) 8 | { 9 | Arma = arma; 10 | } 11 | 12 | public override void EscolherTransporte(string transporte) 13 | { 14 | Transporte = transporte; 15 | } 16 | 17 | public override void DefinirFoco(string foco) 18 | { 19 | Foco = foco; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/Soldado.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Builder 4 | { 5 | public abstract class Soldado 6 | { 7 | public string Arma { get; protected set; } 8 | public string Transporte { get; protected set; } 9 | public string Foco { get; protected set; } 10 | 11 | public abstract void EscolherArma(string arma); 12 | public abstract void EscolherTransporte(string transporte); 13 | public abstract void DefinirFoco(string foco); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Builder/Builder/SoldadoDeForcasEspeciais.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Builder 4 | { 5 | public class SoldadoDeForcasEspeciais : Soldado 6 | { 7 | public override void EscolherArma(string arma) 8 | { 9 | Arma = arma; 10 | } 11 | 12 | public override void EscolherTransporte(string transporte) 13 | { 14 | Transporte = transporte; 15 | } 16 | 17 | public override void DefinirFoco(string foco) 18 | { 19 | Foco = foco; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/.suo -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/db.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/db.lock -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/storage.ide: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/storage.ide -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/storage.ide-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/storage.ide-shm -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/storage.ide-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/FactoryMethod/.vs/FactoryMethod/v15/Server/sqlite3/storage.ide-wal -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/FactoryMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FactoryMethod 4 | { 5 | public class FactoryMethod 6 | { 7 | public IPersonagem Escolher_Personagem(string personagem) 8 | { 9 | switch (personagem) 10 | { 11 | case "Liu Kang": return new LiuKang(); 12 | case "SubZero": return new SubZero(); 13 | case "Scorpion": return new Scorpion(); 14 | default: return null; 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/FactoryMethod.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryMethod", "FactoryMethod.csproj", "{8D956611-2FBB-4DA0-BEF7-1CE31418980F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8D956611-2FBB-4DA0-BEF7-1CE31418980F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8D956611-2FBB-4DA0-BEF7-1CE31418980F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8D956611-2FBB-4DA0-BEF7-1CE31418980F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8D956611-2FBB-4DA0-BEF7-1CE31418980F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {F5BAC804-5868-4878-B5B6-C49CB7640B88} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/IPersonagem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FactoryMethod 4 | { 5 | public interface IPersonagem 6 | { 7 | void Escolhido(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/LiuKang.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FactoryMethod 4 | { 5 | public class LiuKang : IPersonagem 6 | { 7 | public void Escolhido() 8 | { 9 | Console.Write("Liu Kang"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FactoryMethod 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | FactoryMethod fm = new FactoryMethod(); 10 | 11 | 12 | Console.WriteLine("Liu Kang | SubZero | Scorpion"); 13 | Console.WriteLine(); 14 | 15 | Console.Write("Escolha seu Personagem: "); 16 | string escolha = Console.ReadLine(); 17 | 18 | IPersonagem personagem = fm.Escolher_Personagem(escolha); 19 | Console.WriteLine(); 20 | Console.Write("Você vai jogar com "); 21 | personagem.Escolhido(); 22 | 23 | 24 | Console.ReadKey(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("FactoryMethod")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FactoryMethod")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("8d956611-2fbb-4da0-bef7-1ce31418980f")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/Scorpion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FactoryMethod 4 | { 5 | public class Scorpion : IPersonagem 6 | { 7 | public void Escolhido() 8 | { 9 | Console.Write("Scorpion"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/FactoryMethod/SubZero.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FactoryMethod 4 | { 5 | public class SubZero : IPersonagem 6 | { 7 | public void Escolhido() 8 | { 9 | Console.Write("Zub Zero"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2037 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Prototype\Prototype.csproj", "{5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {4793A980-035D-4FE9-80F9-D79D4393F23B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/GerenciadorNuvens.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Prototype 5 | { 6 | public class GerenciadorNuvens 7 | { 8 | private Dictionary nuvens = new Dictionary(); 9 | 10 | public NuvemMolde this[string key] 11 | { 12 | get { return nuvens[key]; } 13 | set { nuvens.Add(key, value); } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/NuvemConcreta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace Prototype 5 | { 6 | public class NuvemConcreta : NuvemMolde 7 | { 8 | private string cor_preenchimento; 9 | private string cor_contorno; 10 | 11 | public NuvemConcreta(string preenchimento, string contorno) 12 | { 13 | this.cor_preenchimento = preenchimento; 14 | this.cor_contorno = contorno; 15 | } 16 | 17 | public override NuvemMolde Clone() 18 | { 19 | Console.WriteLine("A nuvem clonada tem contorno " + this.cor_contorno + " e preenchimento " + this.cor_preenchimento); 20 | return this.MemberwiseClone() as NuvemMolde; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/NuvemMolde.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Prototype 4 | { 5 | public abstract class NuvemMolde 6 | { 7 | public abstract NuvemMolde Clone(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace Prototype 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | GerenciadorNuvens gerenciador_de_nuvens = new GerenciadorNuvens(); 11 | 12 | gerenciador_de_nuvens["padrão"] = new NuvemConcreta("branco", "azul"); 13 | gerenciador_de_nuvens["personalizada"] = new NuvemConcreta("branco", "laranja"); 14 | 15 | NuvemConcreta um = gerenciador_de_nuvens["padrão"].Clone() as NuvemConcreta; 16 | NuvemConcreta dois = gerenciador_de_nuvens["padrão"].Clone() as NuvemConcreta; 17 | NuvemConcreta tres = gerenciador_de_nuvens["personalizada"].Clone() as NuvemConcreta; 18 | 19 | Console.ReadKey(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Prototype")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Prototype")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("5e0a8c16-cf8e-43b8-90ee-0fdf31ae8950")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950} 8 | Exe 9 | Prototype 10 | Prototype 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2037 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Prototype\Prototype.csproj", "{5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {4793A980-035D-4FE9-80F9-D79D4393F23B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype/GerenciadorNuvens.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Prototype 5 | { 6 | public class GerenciadorNuvens 7 | { 8 | private Dictionary nuvens = new Dictionary(); 9 | 10 | public Nuvem this[string key] 11 | { 12 | get { return nuvens[key]; } 13 | set { nuvens.Add(key, value); } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype/Nuvem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Prototype 4 | { 5 | public abstract class Nuvem 6 | { 7 | public abstract Nuvem Clone(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype/NuvemUm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace Prototype 5 | { 6 | public class NuvemUm : Nuvem 7 | { 8 | private string cor_preenchimento; 9 | private string cor_contorno; 10 | 11 | public NuvemUm(string preenchimento, string contorno) 12 | { 13 | this.cor_preenchimento = preenchimento; 14 | this.cor_contorno = contorno; 15 | } 16 | 17 | public override Nuvem Clone() 18 | { 19 | Console.WriteLine("A nuvem clonada tem contorno " + this.cor_contorno + " e preenchimento " + this.cor_preenchimento); 20 | return this.MemberwiseClone() as Nuvem; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace Prototype 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | GerenciadorNuvens gerenciador_de_nuvens = new GerenciadorNuvens(); 11 | 12 | gerenciador_de_nuvens["padrão"] = new NuvemUm("branco", "azul"); 13 | gerenciador_de_nuvens["personalizada"] = new NuvemUm("branco", "laranja"); 14 | 15 | NuvemUm um = gerenciador_de_nuvens["padrão"].Clone() as NuvemUm; 16 | NuvemUm dois = gerenciador_de_nuvens["padrão"].Clone() as NuvemUm; 17 | NuvemUm tres = gerenciador_de_nuvens["personalizada"].Clone() as NuvemUm; 18 | 19 | Console.ReadKey(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Prototype")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Prototype")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("5e0a8c16-cf8e-43b8-90ee-0fdf31ae8950")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Prototype/Prototype/Prototype/Prototype.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5E0A8C16-CF8E-43B8-90EE-0FDF31AE8950} 8 | Exe 9 | Prototype 10 | Prototype 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/.vs/Singleton/v15/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/.vs/Singleton/v15/.suo -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/db.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/db.lock -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/storage.ide: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/storage.ide -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/storage.ide-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/storage.ide-shm -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/storage.ide-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/.vs/Singleton/v15/Server/sqlite3/storage.ide-wal -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Singleton", "Singleton\Singleton.csproj", "{A1CCF477-35A3-458B-83D2-B3D0988A3934}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A1CCF477-35A3-458B-83D2-B3D0988A3934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A1CCF477-35A3-458B-83D2-B3D0988A3934}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A1CCF477-35A3-458B-83D2-B3D0988A3934}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A1CCF477-35A3-458B-83D2-B3D0988A3934}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {58A676B9-51E6-4C02-BB66-35B7F4AFF4B7} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Singleton 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Singleton jogador_1 = Singleton.GetInstancia; 10 | jogador_1.Mensagem("Jogador 1: A bola está comigo no meio do campo."); 11 | 12 | Singleton jogador_2 = Singleton.GetInstancia; 13 | jogador_2.Mensagem("Jogador 2: recebeu a bola."); 14 | 15 | Singleton jogador_3 = Singleton.GetInstancia; 16 | jogador_3.Mensagem("Jogador 3: recebeu o lançamento na linha de fundo."); 17 | 18 | Console.ReadKey(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Singleton")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Singleton")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("a1ccf477-35a3-458b-83d2-b3d0988a3934")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/Singleton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Singleton 4 | { 5 | public sealed class Singleton 6 | { 7 | private static Singleton instancia = null; 8 | 9 | public static Singleton GetInstancia 10 | { 11 | get 12 | { 13 | if (instancia == null) 14 | { 15 | instancia = new Singleton(); 16 | Console.WriteLine("Bola em Jogo"); 17 | } 18 | 19 | return instancia; 20 | } 21 | } 22 | 23 | public void Mensagem(string msg) 24 | { 25 | Console.WriteLine(msg); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/Singleton.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A1CCF477-35A3-458B-83D2-B3D0988A3934} 8 | Exe 9 | Singleton 10 | Singleton 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/bin/Debug/Singleton.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/bin/Debug/Singleton.exe -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/bin/Debug/Singleton.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/bin/Debug/Singleton.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/bin/Debug/Singleton.pdb -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 7cf2b7d133470cf4c999fd2cfb53ddb9bb3bafee 2 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | \\Mac\Home\Desktop\Pattners Update\Singleton\Singleton\Singleton\bin\Debug\Singleton.exe.config 2 | \\Mac\Home\Desktop\Pattners Update\Singleton\Singleton\Singleton\bin\Debug\Singleton.exe 3 | \\Mac\Home\Desktop\Pattners Update\Singleton\Singleton\Singleton\bin\Debug\Singleton.pdb 4 | \\Mac\Home\Desktop\Pattners Update\Singleton\Singleton\Singleton\obj\Debug\Singleton.csprojAssemblyReference.cache 5 | \\Mac\Home\Desktop\Pattners Update\Singleton\Singleton\Singleton\obj\Debug\Singleton.csproj.CoreCompileInputs.cache 6 | \\Mac\Home\Desktop\Pattners Update\Singleton\Singleton\Singleton\obj\Debug\Singleton.exe 7 | \\Mac\Home\Desktop\Pattners Update\Singleton\Singleton\Singleton\obj\Debug\Singleton.pdb 8 | \\Mac\Home\Downloads\Singleton\Singleton\Singleton\Singleton\bin\Debug\Singleton.exe.config 9 | \\Mac\Home\Downloads\Singleton\Singleton\Singleton\Singleton\bin\Debug\Singleton.exe 10 | \\Mac\Home\Downloads\Singleton\Singleton\Singleton\Singleton\bin\Debug\Singleton.pdb 11 | \\Mac\Home\Downloads\Singleton\Singleton\Singleton\Singleton\obj\Debug\Singleton.csprojAssemblyReference.cache 12 | \\Mac\Home\Downloads\Singleton\Singleton\Singleton\Singleton\obj\Debug\Singleton.csproj.CoreCompileInputs.cache 13 | \\Mac\Home\Downloads\Singleton\Singleton\Singleton\Singleton\obj\Debug\Singleton.exe 14 | \\Mac\Home\Downloads\Singleton\Singleton\Singleton\Singleton\obj\Debug\Singleton.pdb 15 | -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.exe -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/obj/Debug/Singleton.pdb -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Criação/Singleton/Singleton/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -------------------------------------------------------------------------------- /Design Patterns de Criação/Singleton/Singleton/obj/Release/Singleton.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 7cf2b7d133470cf4c999fd2cfb53ddb9bb3bafee 2 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodrigogoncalvessantana/aprendendo-design-patterns-com-games-csharp/bf50bb4d7eb0c34ac01f3d8bed72a3578ae65dcb/Design Patterns de Estrutura/.DS_Store -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2037 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{619A9F7D-8ECC-420F-8EE1-514D2043A0B0}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {619A9F7D-8ECC-420F-8EE1-514D2043A0B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {619A9F7D-8ECC-420F-8EE1-514D2043A0B0}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {619A9F7D-8ECC-420F-8EE1-514D2043A0B0}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {619A9F7D-8ECC-420F-8EE1-514D2043A0B0}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3C549B35-6B90-4EB0-B92C-56BAFE25413C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/Adapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Adapter 4 | { 5 | public class Adapter : IAcao 6 | { 7 | Aviao aviao; 8 | 9 | public Adapter(Aviao novo_aviao) 10 | { 11 | this.aviao = novo_aviao; 12 | } 13 | 14 | public void Andar(string jogador) 15 | { 16 | this.aviao.Voar("Rodrigo"); 17 | } 18 | 19 | public void Atirar() 20 | { 21 | this.aviao.SoltarMissil(); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/Adapter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {619A9F7D-8ECC-420F-8EE1-514D2043A0B0} 8 | Exe 9 | Adapter 10 | Adapter 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/Aviao.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Adapter 4 | { 5 | public class Aviao 6 | { 7 | public void Voar(string personagem) 8 | { 9 | Console.WriteLine(personagem + " VOOU PARA FRENTE!"); 10 | } 11 | 12 | public void SoltarMissil() 13 | { 14 | Console.WriteLine("Soltou um míssil no jogo!"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/IAcao.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Adapter 4 | { 5 | public interface IAcao 6 | { 7 | void Andar(string jogador); 8 | void Atirar(); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/Personagem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Adapter 4 | { 5 | public class Personagem : IAcao 6 | { 7 | public void Atirar() 8 | { 9 | Console.WriteLine("Atirou no jogo!"); 10 | } 11 | 12 | public void Andar(string personagem) 13 | { 14 | Console.WriteLine(personagem + " ANDOU PARA FRENTE!"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Adapter 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Personagem rodrigo = new Personagem(); 10 | Aviao aviao_de_batalha = new Aviao(); 11 | 12 | IAcao adaptador = new Adapter(aviao_de_batalha); 13 | 14 | Console.WriteLine("--- CAMINHANDO ---"); 15 | rodrigo.Andar("Rodrigo"); 16 | rodrigo.Atirar(); 17 | 18 | Console.WriteLine(); 19 | 20 | Console.WriteLine("--- PEGOU UM AVIÃO NO JOGO ---"); 21 | adaptador.Andar("Rodrigo"); 22 | adaptador.Atirar(); 23 | 24 | Console.ReadKey(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Adapter/Adapter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Adapter")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Adapter")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("619a9f7d-8ecc-420f-8ee1-514d2043a0b0")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Bridge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Bridge 4 | { 5 | public class Bridge 6 | { 7 | public IForma forma_solicitada { get; set; } 8 | 9 | public void ExibeQualFormaEstaDescendoNaTela() 10 | { 11 | Console.WriteLine(forma_solicitada.Descer()); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Bridge.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bridge", "Bridge.csproj", "{C0BAA962-4496-40DD-B2A5-416C8772A709}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C0BAA962-4496-40DD-B2A5-416C8772A709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C0BAA962-4496-40DD-B2A5-416C8772A709}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C0BAA962-4496-40DD-B2A5-416C8772A709}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C0BAA962-4496-40DD-B2A5-416C8772A709}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0E0E91C1-8EAE-4F31-ADEF-68A536E8E38C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Forma1.cs: -------------------------------------------------------------------------------- 1 | namespace Bridge 2 | { 3 | public class Forma1 : IForma 4 | { 5 | public ICor ICor { get; set; } 6 | 7 | public string Descer() 8 | { 9 | return "T - " + ICor.Cor(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Forma2.cs: -------------------------------------------------------------------------------- 1 | namespace Bridge 2 | { 3 | public class Forma2 : IForma 4 | { 5 | public ICor ICor { get; set; } 6 | 7 | public string Descer() 8 | { 9 | return "U - " + ICor.Cor(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/ICor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Bridge 4 | { 5 | public interface ICor 6 | { 7 | string Cor(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/IForma.cs: -------------------------------------------------------------------------------- 1 | namespace Bridge 2 | { 3 | public interface IForma 4 | { 5 | string Descer(); 6 | ICor ICor { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Laranja.cs: -------------------------------------------------------------------------------- 1 | namespace Bridge 2 | { 3 | public class Laranja : ICor 4 | { 5 | public string Cor() 6 | { 7 | return "Laranja"; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Bridge 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Bridge bridge = new Bridge(); 10 | Random random = new Random(); 11 | 12 | void Sortear() 13 | { 14 | if (random.Next(2) == 1) 15 | bridge.forma_solicitada = new Forma1(); 16 | else 17 | bridge.forma_solicitada = new Forma2(); 18 | 19 | 20 | if (random.Next(1,3) == 1) 21 | bridge.forma_solicitada.ICor = new Verde(); 22 | else if (random.Next(1,3) == 2) 23 | bridge.forma_solicitada.ICor = new Laranja(); 24 | else 25 | bridge.forma_solicitada.ICor = new Rosa(); 26 | } 27 | 28 | Console.WriteLine("Pressione ENTER para enviar uma forma"); 29 | 30 | while (1 > 0) 31 | { 32 | ConsoleKeyInfo input = Console.ReadKey(); 33 | if (input.KeyChar == 13) 34 | Sortear(); 35 | 36 | Console.WriteLine(); 37 | bridge.ExibeQualFormaEstaDescendoNaTela(); 38 | } 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Bridge")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Bridge")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("c0baa962-4496-40dd-b2a5-416c8772a709")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Rosa.cs: -------------------------------------------------------------------------------- 1 | namespace Bridge 2 | { 3 | public class Rosa : ICor 4 | { 5 | public string Cor() 6 | { 7 | return "Rosa"; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Bridge/Verde.cs: -------------------------------------------------------------------------------- 1 | namespace Bridge 2 | { 3 | public class Verde : ICor 4 | { 5 | public string Cor() 6 | { 7 | return "Verde"; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/ComponenteFase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Composite 4 | { 5 | public abstract class ComponenteFase 6 | { 7 | protected string nome; 8 | 9 | public ComponenteFase(string nome) 10 | { 11 | this.nome = nome; 12 | } 13 | 14 | public abstract void Adicionar(ComponenteFase c); 15 | public abstract void Remover(ComponenteFase c); 16 | public abstract void Mostrar(int profundidade); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/Composite.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Composite 5 | { 6 | public class Composite : ComponenteFase 7 | { 8 | 9 | private List fasesjogo = new List(); 10 | 11 | public Composite(string nome): base(nome) 12 | { 13 | 14 | } 15 | 16 | public override void Adicionar(ComponenteFase c) 17 | { 18 | this.fasesjogo.Add(c); 19 | } 20 | 21 | public override void Mostrar(int profundidade) 22 | { 23 | Console.WriteLine(new string('-', profundidade) + nome); 24 | 25 | foreach (ComponenteFase item in this.fasesjogo) 26 | { 27 | item.Mostrar(profundidade + 2); 28 | } 29 | } 30 | 31 | public override void Remover(ComponenteFase c) 32 | { 33 | this.fasesjogo.Remove(c); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/Composite.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {6BFBCA2F-11FF-4666-AB15-CCC4C9C6623C} 8 | Exe 9 | Composite 10 | Composite 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/Composite.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite", "Composite.csproj", "{6BFBCA2F-11FF-4666-AB15-CCC4C9C6623C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6BFBCA2F-11FF-4666-AB15-CCC4C9C6623C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6BFBCA2F-11FF-4666-AB15-CCC4C9C6623C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6BFBCA2F-11FF-4666-AB15-CCC4C9C6623C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6BFBCA2F-11FF-4666-AB15-CCC4C9C6623C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {6E49C3DA-1AB8-4013-A73F-893BA100386D} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/FaseJogo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Composite 4 | { 5 | public class FaseJogo : ComponenteFase 6 | { 7 | public FaseJogo(string nome) : base(nome) 8 | { 9 | 10 | } 11 | 12 | public override void Adicionar(ComponenteFase c) 13 | { 14 | Console.WriteLine("Não é possível adicionar a fase no jogo!"); 15 | } 16 | 17 | public override void Mostrar(int profundidade) 18 | { 19 | Console.WriteLine(new string('-', profundidade) + nome); 20 | } 21 | 22 | public override void Remover(ComponenteFase c) 23 | { 24 | Console.WriteLine("Não é possível remover a fase do jogo!"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Composite 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Composite mapa = new Composite("MAPA DAS CAVERNAS"); 10 | 11 | Composite caverna1 = new Composite("Caverna 1"); 12 | caverna1.Adicionar(new FaseJogo("Sub Fase 1")); 13 | caverna1.Adicionar(new FaseJogo("Sub Fase 2")); 14 | caverna1.Adicionar(new FaseJogo("Sub Fase 3")); 15 | 16 | Composite caverna2 = new Composite("Caverna 2"); 17 | caverna2.Adicionar(new FaseJogo("Sub Fase 4")); 18 | caverna2.Adicionar(new FaseJogo("Sub Fase 5")); 19 | 20 | Composite porta_secreta = new Composite("Porta Secreta"); 21 | porta_secreta.Adicionar(new FaseJogo("Sub Fase Secreta X")); 22 | 23 | mapa.Adicionar(caverna1); 24 | mapa.Adicionar(caverna2); 25 | caverna2.Adicionar(porta_secreta); 26 | 27 | //root.Adicionar(folha); 28 | //root.Remover(folha); 29 | 30 | mapa.Mostrar(1); 31 | 32 | Console.ReadKey(); 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Composite/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Composite")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Composite")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("6bfbca2f-11ff-4666-ab15-ccc4c9c6623c")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/ArmaduraPadrao.cs: -------------------------------------------------------------------------------- 1 | namespace Decorator 2 | { 3 | public class ArmaduraPadrao : MoldeArmadura 4 | { 5 | string _descricao = "Proteção Simples, "; 6 | 7 | public override string Descricao 8 | { 9 | get 10 | { 11 | return _descricao; 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/Capacete.cs: -------------------------------------------------------------------------------- 1 | namespace Decorator 2 | { 3 | public class Capacete : DecoratorArmadura 4 | { 5 | string _descricao = "Capacte, "; 6 | MoldeArmadura _moldeArmadura; 7 | 8 | public Capacete(MoldeArmadura moldeArmadura) 9 | { 10 | _moldeArmadura = moldeArmadura; 11 | } 12 | 13 | public override string Descricao 14 | { 15 | get 16 | { 17 | return _moldeArmadura.Descricao + _descricao; 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/Decorator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decorator", "Decorator.csproj", "{ED72453F-860C-4CF9-9823-69BBA1879B01}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {ED72453F-860C-4CF9-9823-69BBA1879B01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {ED72453F-860C-4CF9-9823-69BBA1879B01}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {ED72453F-860C-4CF9-9823-69BBA1879B01}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {ED72453F-860C-4CF9-9823-69BBA1879B01}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {69093E3B-70A3-414F-A58A-0C2B5269E3A4} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/DecoratorArmadura.cs: -------------------------------------------------------------------------------- 1 | namespace Decorator 2 | { 3 | public class DecoratorArmadura : MoldeArmadura 4 | { 5 | string _descricao = "Decorador Abstrato da Armadura do Persoangem"; 6 | 7 | public override string Descricao 8 | { 9 | get { return _descricao; } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/Espada.cs: -------------------------------------------------------------------------------- 1 | namespace Decorator 2 | { 3 | public class Espada : DecoratorArmadura 4 | { 5 | string _descricao = "Espada Ultra Forte, "; 6 | MoldeArmadura _moldeArmadura; 7 | 8 | public Espada(MoldeArmadura moldeArmadura) 9 | { 10 | _moldeArmadura = moldeArmadura; 11 | } 12 | 13 | public override string Descricao 14 | { 15 | get 16 | { 17 | return _moldeArmadura.Descricao + _descricao; 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/MoldeArmadura.cs: -------------------------------------------------------------------------------- 1 | namespace Decorator 2 | { 3 | public abstract class MoldeArmadura 4 | { 5 | private string _descricao = "Armadura do Personagem Abstrata"; 6 | 7 | public virtual string Descricao 8 | { 9 | get { return _descricao; } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Decorator 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine(" ### Veste Armadura Padrão ###"); 10 | MoldeArmadura armadura = new ArmaduraPadrao(); 11 | Console.WriteLine("Descrição: " + armadura.Descricao.TrimEnd(' ', ',')); 12 | 13 | Console.WriteLine(); 14 | 15 | Console.WriteLine(" ### Incluir Novos Itens na Armadura (Decorar) ###"); 16 | armadura = new Capacete(armadura); 17 | armadura = new Espada(armadura); 18 | 19 | Console.WriteLine("Descrição: " + armadura.Descricao.TrimEnd(' ', ',')); 20 | 21 | Console.ReadKey(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Decorator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Decorator2")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Decorator2")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("ed72453f-860c-4cf9-9823-69bba1879b01")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/Facade.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | //Facade é a base de Centro de Comando 4 | namespace Facade 5 | { 6 | public class Facade 7 | { 8 | private SubSistemaUm um; 9 | private SubSistemaDois dois; 10 | private SubSistemaTres tres; 11 | 12 | public Facade() 13 | { 14 | this.um = new SubSistemaUm(); 15 | this.dois = new SubSistemaDois(); 16 | this.tres = new SubSistemaTres(); 17 | } 18 | 19 | public void OperacaoA() 20 | { 21 | Console.WriteLine("\nOperação A ------- "); 22 | this.um.Responsabilidade(); 23 | this.dois.Responsabilidade(); 24 | } 25 | 26 | public void OperacaoB() 27 | { 28 | Console.WriteLine("\nOperação B ------- "); 29 | this.tres.Responsabilidade(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/Facade.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E4E41C7C-C9AE-4188-91F0-064D4FB1B96F} 8 | Exe 9 | Facade 10 | Facade 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/Facade.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facade", "Facade.csproj", "{E4E41C7C-C9AE-4188-91F0-064D4FB1B96F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E4E41C7C-C9AE-4188-91F0-064D4FB1B96F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E4E41C7C-C9AE-4188-91F0-064D4FB1B96F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E4E41C7C-C9AE-4188-91F0-064D4FB1B96F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E4E41C7C-C9AE-4188-91F0-064D4FB1B96F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {B4E0BF72-94BA-495B-8927-D332159A5F08} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Facade 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Facade facade = new Facade(); 10 | facade.OperacaoA(); 11 | facade.OperacaoB(); 12 | 13 | Console.ReadKey(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Facade")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Facade")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("e4e41c7c-c9ae-4188-91f0-064d4fb1b96f")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/SubSistemaDois.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Facade 4 | { 5 | public class SubSistemaDois 6 | { 7 | public void Responsabilidade() 8 | { 9 | Console.WriteLine("Produzir Armamento para Guereiros"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/SubSistemaTres.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Facade 4 | { 5 | public class SubSistemaTres 6 | { 7 | public void Responsabilidade() 8 | { 9 | Console.WriteLine("Treinar Guerreiros"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Facade/SubSistemaUm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Facade 4 | { 5 | public class SubSistemaUm 6 | { 7 | public void Responsabilidade() 8 | { 9 | Console.WriteLine("Coletar Recursos de Energia para a base"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Azul.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Flyweight 4 | { 5 | //Nossa classe concreta, aquela que estamos implementando. 6 | public class Azul : Tartaruga 7 | { 8 | public Azul() 9 | { 10 | this.condicao = "tartaruga dentro do casco, "; 11 | this.acao = "rodando no chão - "; 12 | } 13 | 14 | public override void Mostra(string qualcor) 15 | { 16 | this.cor = qualcor; 17 | Console.WriteLine(condicao + acao + cor.ToUpper()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Flyweight.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Flyweight 5 | { 6 | public class Flyweight 7 | { 8 | private Dictionary lista_de_tartarugas = new Dictionary(); 9 | 10 | public Tartaruga GetTartaruga(string cor) 11 | { 12 | Tartaruga t = null; 13 | 14 | if (lista_de_tartarugas.ContainsKey(cor)) 15 | { 16 | t = lista_de_tartarugas[cor]; 17 | } 18 | else 19 | { 20 | switch (cor) 21 | { 22 | case "azul": t = new Azul(); break; 23 | case "verde": t = new Verde(); break; 24 | case "laranja": t = new Laranja(); break; 25 | case "vermelha": t = new Vermelha(); break; 26 | } 27 | 28 | lista_de_tartarugas.Add(cor, t); 29 | } 30 | 31 | return t; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Flyweight.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flyweight", "Flyweight.csproj", "{3B4E53FE-017E-4401-A109-11E191BCF2AE}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3B4E53FE-017E-4401-A109-11E191BCF2AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3B4E53FE-017E-4401-A109-11E191BCF2AE}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3B4E53FE-017E-4401-A109-11E191BCF2AE}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3B4E53FE-017E-4401-A109-11E191BCF2AE}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {459FBEF8-81F7-4993-AB9F-7C5EB7710AD7} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Laranja.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Flyweight 4 | { 5 | //Nossa classe concreta, aquela que estamos implementando. 6 | public class Laranja : Tartaruga 7 | { 8 | public Laranja() 9 | { 10 | this.condicao = "tartaruga dentro do casco, "; 11 | this.acao = "rodando no chão - "; 12 | } 13 | 14 | public override void Mostra(string qualcor) 15 | { 16 | this.cor = qualcor; 17 | Console.WriteLine(condicao + acao + cor.ToUpper()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Flyweight 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | // Console.WriteLine("--------### Design Patterns Flyweight By Prof. Rodrigo Gonçalves ###--------"); 10 | 11 | Flyweight flyweight = new Flyweight(); 12 | string cor = string.Empty; 13 | 14 | Tartaruga tartaruga; 15 | 16 | while (true) 17 | { 18 | Console.WriteLine(); 19 | 20 | Console.Write("Qual tartaruga enviar para tela: "); 21 | //Extrínseco 22 | cor = Console.ReadLine(); 23 | 24 | tartaruga = flyweight.GetTartaruga(cor); 25 | tartaruga.Mostra(cor); 26 | 27 | Console.WriteLine(); 28 | Console.WriteLine("------------------------"); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Flyweight")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Flyweight")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("3b4e53fe-017e-4401-a109-11e191bcf2ae")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Tartaruga.cs: -------------------------------------------------------------------------------- 1 | namespace Flyweight 2 | { 3 | //Nossa clase abstrata. 4 | public abstract class Tartaruga 5 | { 6 | //PROTECTED da acesso somente a quem o herdou. 7 | protected string condicao; //Aqui temos, nosso atributo Intrínseco. 8 | protected string acao; //Aqui temos, nosso atributo Intrínseco. 9 | public string cor { get; set; } //Aqui temos, nosso atributo *Extrínseco. 10 | 11 | //Coloca na tela a tartaruga. 12 | public abstract void Mostra (string cor); 13 | 14 | 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Verde.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Flyweight 4 | { 5 | //Nossa classe concreta, aquela que estamos implementando. 6 | public class Verde : Tartaruga 7 | { 8 | public Verde() 9 | { 10 | this.condicao = "tartaruga dentro do casco, "; 11 | this.acao = "rodando no chão - "; 12 | } 13 | 14 | public override void Mostra(string qualcor) 15 | { 16 | this.cor = qualcor; 17 | Console.WriteLine(condicao + acao + cor.ToUpper()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/Vermelha.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Flyweight 4 | { 5 | //Nossa classe concreta, aquela que estamos implementando. 6 | public class Vermelha : Tartaruga 7 | { 8 | public Vermelha() 9 | { 10 | this.condicao = "tartaruga dentro do casco, "; 11 | this.acao = "rodando no chão - "; 12 | } 13 | 14 | public override void Mostra(string qualcor) 15 | { 16 | this.cor = qualcor; 17 | Console.WriteLine(condicao + acao + cor.ToUpper()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Flyweight/bloco.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Flyweight 8 | { 9 | public static class bloco 10 | { 11 | public void Faca_alguma_coisa() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/FaseJogo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Proxy 4 | { 5 | public class FaseJogo 6 | { 7 | public string Jogar() 8 | { 9 | return "Você está de volta a fase do jogo!"; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/IFase.cs: -------------------------------------------------------------------------------- 1 | namespace Proxy 2 | { 3 | public interface IFase 4 | { 5 | string Jogar(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Proxy 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("#### Acessando a Fase do Jogo sem o Proxy ####"); 10 | FaseJogo fase = new FaseJogo(); 11 | Console.WriteLine(fase.Jogar()); 12 | Console.WriteLine(); 13 | 14 | Console.WriteLine("----- Usando o Proxy para controlar o acesso a fase do jogo -----"); 15 | Console.WriteLine(); 16 | 17 | ProxyFase proxy = new ProxyFase(); 18 | 19 | Console.WriteLine("#### Tentando acessar a fase do jogo sem informar o Password ####"); 20 | Console.WriteLine(proxy.Jogar()); 21 | 22 | Console.WriteLine(); 23 | 24 | Console.WriteLine("#### Tentando acessar a fase do jogo com Password incorreto ####"); 25 | Console.WriteLine(proxy.InformarPassword("465")); 26 | Console.WriteLine(proxy.Jogar()); 27 | 28 | Console.WriteLine(); 29 | 30 | Console.WriteLine("#### Tentando acessar a fase do jogo com Password correto ####"); 31 | Console.WriteLine(proxy.InformarPassword("123")); 32 | Console.WriteLine(proxy.Jogar()); 33 | Console.WriteLine(); 34 | 35 | Console.ReadKey(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("Proxy2")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Proxy2")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("cf5a3042-3db4-484f-8612-554417294877")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/Proxy.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CF5A3042-3DB4-484F-8612-554417294877} 8 | Exe 9 | Proxy2 10 | Proxy2 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/Proxy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proxy", "Proxy.csproj", "{CF5A3042-3DB4-484F-8612-554417294877}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CF5A3042-3DB4-484F-8612-554417294877}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {CF5A3042-3DB4-484F-8612-554417294877}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {CF5A3042-3DB4-484F-8612-554417294877}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {CF5A3042-3DB4-484F-8612-554417294877}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {453CB1BF-BED0-4AF3-ACCE-60FA4CA9AD6B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Design Patterns de Estrutura/Proxy/ProxyFase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Proxy 4 | { 5 | public class ProxyFase : IFase 6 | { 7 | FaseJogo fasejogo; 8 | string password = "123"; 9 | 10 | public string Jogar() 11 | { 12 | if (this.fasejogo != null) 13 | return fasejogo.Jogar(); 14 | 15 | return "Informe o PASSWORD correto para abrir a fase do jogo!"; 16 | } 17 | 18 | public string InformarPassword(string codigo) 19 | { 20 | if(codigo == this.password) 21 | { 22 | this.fasejogo = new FaseJogo(); 23 | return "Password Correto!"; 24 | } 25 | 26 | return "Password Incorreto!"; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Aprendendo Design Patterns com jogos clássicos em C# 2 | 3 | Código Fonte do Livro 4 | --------------------------------------------------------------------------------