{"id":78704,"date":"2024-10-01T17:43:46","date_gmt":"2024-10-01T14:13:46","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/c-design-pattern-composite-portugues-5b2n\/"},"modified":"2024-10-01T17:43:46","modified_gmt":"2024-10-01T14:13:46","slug":"c-design-pattern-composite-portugues-5b2n","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/c-design-pattern-composite-portugues-5b2n\/","title":{"rendered":"\u0627\u0644\u06af\u0648\u06cc \u0637\u0631\u0627\u062d\u06cc \u0633\u06cc \u0634\u0627\u0631\u067e: \u06a9\u0627\u0645\u067e\u0648\u0632\u06cc\u062a (\u067e\u0631\u062a\u063a\u0627\u0644)"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u0627\u0644\u06af\u0648\u06cc \u062a\u0631\u06a9\u06cc\u0628\u06cc \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u06a9\u0647 \u0627\u0634\u06cc\u0627\u06cc\u06cc \u062f\u0627\u0631\u06cc\u062f \u06a9\u0647 \u0645\u06cc \u062a\u0648\u0627\u0646\u0646\u062f \u062f\u0631 \u0633\u0627\u062e\u062a\u0627\u0631\u0647\u0627\u06cc \u0633\u0644\u0633\u0644\u0647 \u0645\u0631\u0627\u062a\u0628\u06cc \u0645\u0627\u0646\u0646\u062f \u062f\u0631\u062e\u062a\u0627\u0646 \u0633\u0627\u0632\u0645\u0627\u0646\u062f\u0647\u06cc \u0634\u0648\u0646\u062f. \u0627\u06cc\u0646 \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc \u062f\u0647\u062f \u0628\u0627 \u0627\u0634\u06cc\u0627 \u0648 \u062a\u0631\u06a9\u06cc\u0628\u0627\u062a \u0627\u0634\u06cc\u0627\u0621 \u0628\u0647 \u0637\u0648\u0631 \u06cc\u06a9\u0633\u0627\u0646 \u0631\u0641\u062a\u0627\u0631 \u06a9\u0646\u06cc\u062f. \u06cc\u06a9 \u0645\u062b\u0627\u0644 \u0639\u0645\u0644\u06cc \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u06cc\u06a9 \u0633\u06cc\u0633\u062a\u0645 \u0641\u0627\u06cc\u0644 \u0628\u0627\u0634\u062f\u060c \u06a9\u0647 \u062f\u0631 \u0622\u0646 \u067e\u0648\u0634\u0647\u200c\u0647\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u0646\u062f \u062d\u0627\u0648\u06cc \u0641\u0627\u06cc\u0644\u200c\u0647\u0627 \u06cc\u0627 \u067e\u0648\u0634\u0647\u200c\u0647\u0627\u06cc \u062f\u06cc\u06af\u0631 \u0628\u0627\u0634\u0646\u062f\u060c \u0648 \u0634\u0645\u0627 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u062f \u0628\u062a\u0648\u0627\u0646\u06cc\u062f \u0639\u0645\u0644\u06cc\u0627\u062a\u200c\u0647\u0627 \u0631\u0627 \u0628\u0631 \u0631\u0648\u06cc \u0647\u0631 \u06cc\u06a9 \u0627\u0632 \u0622\u0646\u0647\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u06cc\u06a9\u0646\u0648\u0627\u062e\u062a \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u062f.<\/p>\n<p>\u0645\u062b\u0627\u0644 \u06a9\u062f \u062f\u0631 \u0633\u06cc \u0634\u0627\u0631\u067e:<\/p>\n<p>\/\/ Componente base<br \/>\npublic interface IComponente<br \/>\n{<br \/>\n    void Exibir();<br \/>\n}<\/p>\n<p>\/\/ Objeto folha (um arquivo, por exemplo)<br \/>\npublic class Arquivo : IComponente<br \/>\n{<br \/>\n    private string _nome;<\/p>\n<p>    public Arquivo(string nome)<br \/>\n    {<br \/>\n        _nome = nome;<br \/>\n    }<\/p>\n<p>    public void Exibir()<br \/>\n    {<br \/>\n        Console.WriteLine($&#8221;Arquivo: {_nome}&#8221;);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ Objeto composto (uma pasta, por exemplo)<br \/>\npublic class Pasta : IComponente<br \/>\n{<br \/>\n    private string _nome;<br \/>\n    private List&lt;IComponente&gt; _componentes = new List&lt;IComponente&gt;();<\/p>\n<p>    public Pasta(string nome)<br \/>\n    {<br \/>\n        _nome = nome;<br \/>\n    }<\/p>\n<p>    public void Adicionar(IComponente componente)<br \/>\n    {<br \/>\n        _componentes.Add(componente);<br \/>\n    }<\/p>\n<p>    public void Exibir()<br \/>\n    {<br \/>\n        Console.WriteLine($&#8221;Pasta: {_nome}&#8221;);<br \/>\n        foreach (var componente in _componentes)<br \/>\n        {<br \/>\n            componente.Exibir();<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>class Program<br \/>\n{<br \/>\n    static void Main(string[] args)<br \/>\n    {<br \/>\n        \/\/ Criar arquivos e pastas<br \/>\n        Arquivo arquivo1 = new Arquivo(&#8220;arquivo1.txt&#8221;);<br \/>\n        Arquivo arquivo2 = new Arquivo(&#8220;arquivo2.txt&#8221;);<\/p>\n<p>        Pasta pasta1 = new Pasta(&#8220;Documentos&#8221;);<br \/>\n        pasta1.Adicionar(arquivo1);<br \/>\n        pasta1.Adicionar(arquivo2);<\/p>\n<p>        \/\/ Exibir estrutura da pasta<br \/>\n        pasta1.Exibir();<br \/>\n    }<br \/>\n}<\/p>\n<p>\u062a\u0648\u0636\u06cc\u062d \u06a9\u062f:<\/p>\n<p>\u062f\u0631 \u0645\u062b\u0627\u0644\u060c File \u06cc\u06a9 \u0634\u06cc\u0621 \u0633\u0627\u062f\u0647 (\u0635\u0641\u062d\u0647) \u0627\u0633\u062a\u060c \u062f\u0631 \u062d\u0627\u0644\u06cc \u06a9\u0647 Folder \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u062d\u0627\u0648\u06cc \u0641\u0627\u06cc\u0644\u200c\u0647\u0627 \u06cc\u0627 \u067e\u0648\u0634\u0647\u200c\u0647\u0627\u06cc \u062f\u06cc\u06af\u0631\u06cc (\u062a\u0631\u06a9\u06cc\u0628) \u0628\u0627\u0634\u062f. \u0647\u0631 \u062f\u0648 \u0631\u0627\u0628\u0637 IComponente \u0631\u0627 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0645\u06cc\u200c\u06a9\u0646\u0646\u062f \u0648 \u0628\u0647 \u0622\u0646\u200c\u0647\u0627 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc\u200c\u062f\u0647\u0646\u062f \u0628\u0647 \u0637\u0648\u0631 \u06cc\u06a9\u0633\u0627\u0646 \u0631\u0641\u062a\u0627\u0631 \u0634\u0648\u0646\u062f. \u062f\u0631 \u06a9\u062f \u0627\u0635\u0644\u06cc\u060c \u06cc\u06a9 \u067e\u0648\u0634\u0647 \u062d\u0627\u0648\u06cc \u062f\u0648 \u0641\u0627\u06cc\u0644 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc \u0634\u0648\u062f \u0648 \u0633\u0627\u062e\u062a\u0627\u0631 \u0628\u0647 \u0635\u0648\u0631\u062a \u0633\u0644\u0633\u0644\u0647 \u0645\u0631\u0627\u062a\u0628\u06cc \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f.<\/p>\n<p>\u0646\u062a\u06cc\u062c\u0647 \u06af\u06cc\u0631\u06cc:<\/p>\n<p>\u0627\u0644\u06af\u0648\u06cc \u062a\u0631\u06a9\u06cc\u0628\u06cc \u0632\u0645\u0627\u0646\u06cc \u0645\u0641\u06cc\u062f \u0627\u0633\u062a \u06a9\u0647 \u0628\u0627\u06cc\u062f \u0628\u0627 \u0633\u0627\u062e\u062a\u0627\u0631\u0647\u0627\u06cc \u0633\u0644\u0633\u0644\u0647 \u0645\u0631\u0627\u062a\u0628\u06cc \u0645\u0627\u0646\u0646\u062f \u0633\u06cc\u0633\u062a\u0645 \u0647\u0627\u06cc \u0641\u0627\u06cc\u0644 \u06cc\u0627 \u0645\u0646\u0648\u0647\u0627\u06cc \u0646\u0627\u0648\u0628\u0631\u06cc \u0633\u0631 \u0648 \u06a9\u0627\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u0648 \u0628\u0647 \u0634\u0645\u0627 \u0627\u06cc\u0646 \u0627\u0645\u06a9\u0627\u0646 \u0631\u0627 \u0645\u06cc \u062f\u0647\u062f \u06a9\u0647 \u0628\u0627 \u0627\u0634\u06cc\u0627\u0621 \u0633\u0627\u062f\u0647 \u0648 \u062a\u0631\u06a9\u06cc\u0628\u0627\u062a \u0627\u0634\u06cc\u0627\u0621 \u0628\u0647 \u0647\u0645\u0627\u0646 \u0634\u06cc\u0648\u0647 \u0631\u0641\u062a\u0627\u0631 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u06a9\u062f \u0645\u0646\u0628\u0639: GitHub<\/p>\n<p>\u0627\u0644\u06af\u0648\u06cc \u062a\u0631\u06a9\u06cc\u0628\u06cc \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u06a9\u0647 \u0627\u0634\u06cc\u0627\u06cc\u06cc \u062f\u0627\u0631\u06cc\u062f \u06a9\u0647 \u0645\u06cc \u062a\u0648\u0627\u0646\u0646\u062f \u062f\u0631 \u0633\u0627\u062e\u062a\u0627\u0631\u0647\u0627\u06cc \u0633\u0644\u0633\u0644\u0647 \u0645\u0631\u0627\u062a\u0628\u06cc \u0645\u0627\u0646\u0646\u062f \u062f\u0631\u062e\u062a\u0627\u0646 \u0633\u0627\u0632\u0645\u0627\u0646\u062f\u0647\u06cc \u0634\u0648\u0646\u062f. \u0627\u06cc\u0646 \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc \u062f\u0647\u062f \u0628\u0627 \u0627\u0634\u06cc\u0627 \u0648 \u062a\u0631\u06a9\u06cc\u0628\u0627\u062a \u0627\u0634\u06cc\u0627\u0621 \u0628\u0647 \u0637\u0648\u0631 \u06cc\u06a9\u0633\u0627\u0646 \u0631\u0641\u062a\u0627\u0631 \u06a9\u0646\u06cc\u062f. \u06cc\u06a9 \u0645\u062b\u0627\u0644 \u0639\u0645\u0644\u06cc \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u06cc\u06a9 \u0633\u06cc\u0633\u062a\u0645 \u0641\u0627\u06cc\u0644 \u0628\u0627\u0634\u062f\u060c \u06a9\u0647 \u062f\u0631 \u0622\u0646 \u067e\u0648\u0634\u0647\u200c\u0647\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u0646\u062f \u062d\u0627\u0648\u06cc \u0641\u0627\u06cc\u0644\u200c\u0647\u0627 \u06cc\u0627 \u067e\u0648\u0634\u0647\u200c\u0647\u0627\u06cc \u062f\u06cc\u06af\u0631 \u0628\u0627\u0634\u0646\u062f\u060c \u0648 \u0634\u0645\u0627 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u062f \u0628\u062a\u0648\u0627\u0646\u06cc\u062f \u0639\u0645\u0644\u06cc\u0627\u062a\u200c\u0647\u0627 \u0631\u0627 \u0628\u0631 \u0631\u0648\u06cc \u0647\u0631 \u06cc\u06a9 \u0627\u0632 \u0622\u0646\u0647\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u06cc\u06a9\u0646\u0648\u0627\u062e\u062a \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u062f.<\/p>\n<p>\u0645\u062b\u0627\u0644 \u06a9\u062f \u062f\u0631 \u0633\u06cc \u0634\u0627\u0631\u067e:\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\/\/ Componente base\npublic interface IComponente\n{\n    void Exibir();\n}\n\n\/\/ Objeto folha (um arquivo, por exemplo)\npublic class Arquivo : IComponente\n{\n    private string _nome;\n\n    public Arquivo(string nome)\n    {\n        _nome = nome;\n    }\n\n    public void Exibir()\n    {\n        Console.WriteLine($\"Arquivo: {_nome}\");\n    }\n}\n\n\/\/ Objeto composto (uma pasta, por exemplo)\npublic class Pasta : IComponente\n{\n    private string _nome;\n    private List&lt;IComponente&gt; _componentes = new List&lt;IComponente&gt;();\n\n    public Pasta(string nome)\n    {\n        _nome = nome;\n    }\n\n    public void Adicionar(IComponente componente)\n    {\n        _componentes.Add(componente);\n    }\n\n    public void Exibir()\n    {\n        Console.WriteLine($\"Pasta: {_nome}\");\n        foreach (var componente in _componentes)\n        {\n            componente.Exibir();\n        }\n    }\n}\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        \/\/ Criar arquivos e pastas\n        Arquivo arquivo1 = new Arquivo(\"arquivo1.txt\");\n        Arquivo arquivo2 = new Arquivo(\"arquivo2.txt\");\n\n        Pasta pasta1 = new Pasta(\"Documentos\");\n        pasta1.Adicionar(arquivo1);\n        pasta1.Adicionar(arquivo2);\n\n        \/\/ Exibir estrutura da pasta\n        pasta1.Exibir();\n    }\n}\n<\/code><\/pre>\n<\/div>\n<p>\u062a\u0648\u0636\u06cc\u062d \u06a9\u062f:<\/p>\n<p>\u062f\u0631 \u0645\u062b\u0627\u0644\u060c File \u06cc\u06a9 \u0634\u06cc\u0621 \u0633\u0627\u062f\u0647 (\u0635\u0641\u062d\u0647) \u0627\u0633\u062a\u060c \u062f\u0631 \u062d\u0627\u0644\u06cc \u06a9\u0647 Folder \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u062d\u0627\u0648\u06cc \u0641\u0627\u06cc\u0644\u200c\u0647\u0627 \u06cc\u0627 \u067e\u0648\u0634\u0647\u200c\u0647\u0627\u06cc \u062f\u06cc\u06af\u0631\u06cc (\u062a\u0631\u06a9\u06cc\u0628) \u0628\u0627\u0634\u062f. \u0647\u0631 \u062f\u0648 \u0631\u0627\u0628\u0637 IComponente \u0631\u0627 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0645\u06cc\u200c\u06a9\u0646\u0646\u062f \u0648 \u0628\u0647 \u0622\u0646\u200c\u0647\u0627 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc\u200c\u062f\u0647\u0646\u062f \u0628\u0647 \u0637\u0648\u0631 \u06cc\u06a9\u0633\u0627\u0646 \u0631\u0641\u062a\u0627\u0631 \u0634\u0648\u0646\u062f. \u062f\u0631 \u06a9\u062f \u0627\u0635\u0644\u06cc\u060c \u06cc\u06a9 \u067e\u0648\u0634\u0647 \u062d\u0627\u0648\u06cc \u062f\u0648 \u0641\u0627\u06cc\u0644 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc \u0634\u0648\u062f \u0648 \u0633\u0627\u062e\u062a\u0627\u0631 \u0628\u0647 \u0635\u0648\u0631\u062a \u0633\u0644\u0633\u0644\u0647 \u0645\u0631\u0627\u062a\u0628\u06cc \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f.<\/p>\n<p>\u0646\u062a\u06cc\u062c\u0647 \u06af\u06cc\u0631\u06cc:<\/p>\n<p>\u0627\u0644\u06af\u0648\u06cc \u062a\u0631\u06a9\u06cc\u0628\u06cc \u0632\u0645\u0627\u0646\u06cc \u0645\u0641\u06cc\u062f \u0627\u0633\u062a \u06a9\u0647 \u0628\u0627\u06cc\u062f \u0628\u0627 \u0633\u0627\u062e\u062a\u0627\u0631\u0647\u0627\u06cc \u0633\u0644\u0633\u0644\u0647 \u0645\u0631\u0627\u062a\u0628\u06cc \u0645\u0627\u0646\u0646\u062f \u0633\u06cc\u0633\u062a\u0645 \u0647\u0627\u06cc \u0641\u0627\u06cc\u0644 \u06cc\u0627 \u0645\u0646\u0648\u0647\u0627\u06cc \u0646\u0627\u0648\u0628\u0631\u06cc \u0633\u0631 \u0648 \u06a9\u0627\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u0648 \u0628\u0647 \u0634\u0645\u0627 \u0627\u06cc\u0646 \u0627\u0645\u06a9\u0627\u0646 \u0631\u0627 \u0645\u06cc \u062f\u0647\u062f \u06a9\u0647 \u0628\u0627 \u0627\u0634\u06cc\u0627\u0621 \u0633\u0627\u062f\u0647 \u0648 \u062a\u0631\u06a9\u06cc\u0628\u0627\u062a \u0627\u0634\u06cc\u0627\u0621 \u0628\u0647 \u0647\u0645\u0627\u0646 \u0634\u06cc\u0648\u0647 \u0631\u0641\u062a\u0627\u0631 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u06a9\u062f \u0645\u0646\u0628\u0639: GitHub<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u0627\u0644\u06af\u0648\u06cc \u062a\u0631\u06a9\u06cc\u0628\u06cc \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u06a9\u0647 \u0627\u0634\u06cc\u0627\u06cc\u06cc \u062f\u0627\u0631\u06cc\u062f \u06a9\u0647 \u0645\u06cc \u062a\u0648\u0627\u0646\u0646\u062f \u062f\u0631 \u0633\u0627\u062e\u062a\u0627\u0631\u0647\u0627\u06cc \u0633\u0644\u0633\u0644\u0647 \u0645\u0631\u0627\u062a\u0628\u06cc \u0645\u0627\u0646\u0646\u062f \u062f\u0631\u062e\u062a\u0627\u0646 \u0633\u0627\u0632\u0645\u0627\u0646\u062f\u0647\u06cc \u0634\u0648\u0646\u062f. \u0627\u06cc\u0646 \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc \u062f\u0647\u062f \u0628\u0627 \u0627\u0634\u06cc\u0627 \u0648 \u062a\u0631\u06a9\u06cc\u0628\u0627\u062a \u0627\u0634\u06cc\u0627\u0621 \u0628\u0647 \u0637\u0648\u0631 \u06cc\u06a9\u0633\u0627\u0646 \u0631\u0641\u062a\u0627\u0631 \u06a9\u0646\u06cc\u062f. \u06cc\u06a9 \u0645\u062b\u0627\u0644 \u0639\u0645\u0644\u06cc \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u06cc\u06a9 \u0633\u06cc\u0633\u062a\u0645 \u0641\u0627\u06cc\u0644 \u0628\u0627\u0634\u062f\u060c \u06a9\u0647 \u062f\u0631 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-78704","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/78704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=78704"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/78704\/revisions"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=78704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=78704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=78704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}