From 2f30db97ae6e3e9ecf6f86a28f646fa2bb5b4a85 Mon Sep 17 00:00:00 2001 From: Abishek Aditya Date: Sat, 6 May 2017 03:14:38 +0530 Subject: [PATCH 01/28] Created a simple intro text --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..548627b --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# DesignPatterns +Design patterns are solutions to recurring problems; guidelines on how to tackle certain problems +I have included implementations of some design patterns in C# to help beginners like me get their feet wet. +There are better alternatives available for some of them in the .NET Framework, so this is by no means a comprehensive tutorial + +Any comments and suggestions are welcome. If you want to add a new design pattern implementation, just follow the naming conversation, fork my repo and submit a pull request. Same goes for any improvements and modifications. + +## Types of Design Patterns +--------------------------- +There are three kinds of Design Patterns + +* Creational +* Structural +* Behavioral + +## List of Design Pattern Implementations +----------------------------------------- + +* [Adapter](/AdapterPattern) +* [Command](/CommandPattern) +* [Composite](/AdapterPattern) +* [Decorator](/DecoraterPattern) +* [Facade](/FacadePattern) +* [Factory](/FactoryPattern) +* [Iterator](/IteratorPattern) +* [Composite](/IteratorPattern) +* [Observer](/ObserverPattern) +* [Singleton](/SingletonPattern) +* [State](/SatePattern) +* [Strategy](/StrategyPattern) +* [Template](/TemplatePattern) From e62f439ca504f9f0d36f3b177f2a99937c4571a4 Mon Sep 17 00:00:00 2001 From: kokeiro001 Date: Sat, 6 May 2017 09:27:41 +0900 Subject: [PATCH 02/28] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 548627b..226b076 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,13 @@ There are three kinds of Design Patterns * [Adapter](/AdapterPattern) * [Command](/CommandPattern) -* [Composite](/AdapterPattern) -* [Decorator](/DecoraterPattern) +* [Composite](/CompositePattern) +* [Decorator](/DecoratorPattern) * [Facade](/FacadePattern) * [Factory](/FactoryPattern) * [Iterator](/IteratorPattern) -* [Composite](/IteratorPattern) * [Observer](/ObserverPattern) * [Singleton](/SingletonPattern) -* [State](/SatePattern) +* [State](/StatePattern) * [Strategy](/StrategyPattern) * [Template](/TemplatePattern) From f15de31a48d12b6bef141994c8cf7aa32d0caae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Deniel?= Date: Sat, 6 May 2017 09:56:42 +0200 Subject: [PATCH 03/28] Simplified implementation with the use of Lazy. --- SingletonPattern/ChocolateBoiler.cs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/SingletonPattern/ChocolateBoiler.cs b/SingletonPattern/ChocolateBoiler.cs index e1a34a6..eaaac44 100644 --- a/SingletonPattern/ChocolateBoiler.cs +++ b/SingletonPattern/ChocolateBoiler.cs @@ -4,9 +4,10 @@ namespace SingletonPattern { internal partial class ChocolateBoiler { - - private static volatile ChocolateBoiler _singleton; - private static readonly object Lock = new object(); + private static readonly Lazy _singleton = new Lazy(() => new ChocolateBoiler); + + public static ChocolateBoiler GetInstance() => _singleton.Value; + private Status _boiler; private ChocolateBoiler() @@ -15,23 +16,6 @@ private ChocolateBoiler() _boiler = Status.Empty; } - public static ChocolateBoiler GetInstance() - { - lock (Lock) - { - if (_singleton == null) - { - _singleton = new ChocolateBoiler(); - return _singleton; - } - else - { - throw new Exception(); - } - } - - } - public void Fill() { if (!IsEmpty) return; From b411d2bbf19ceea6ca7e3fea4a7d9befb354aa6d Mon Sep 17 00:00:00 2001 From: Abishek Aditya Date: Sat, 6 May 2017 18:41:14 +0530 Subject: [PATCH 04/28] Corrected the object creation for _singleton --- SingletonPattern/ChocolateBoiler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SingletonPattern/ChocolateBoiler.cs b/SingletonPattern/ChocolateBoiler.cs index eaaac44..35d3e15 100644 --- a/SingletonPattern/ChocolateBoiler.cs +++ b/SingletonPattern/ChocolateBoiler.cs @@ -4,7 +4,7 @@ namespace SingletonPattern { internal partial class ChocolateBoiler { - private static readonly Lazy _singleton = new Lazy(() => new ChocolateBoiler); + private static readonly Lazy _singleton = new Lazy(() => new ChocolateBoiler()); public static ChocolateBoiler GetInstance() => _singleton.Value; From c853d163efd1db9dfcb9d48fda931357b2785130 Mon Sep 17 00:00:00 2001 From: Ivan Rubanau Date: Tue, 16 May 2017 18:36:08 +0300 Subject: [PATCH 05/28] Fix java-like brace --- DecoratorPattern/MochaCondiment.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DecoratorPattern/MochaCondiment.cs b/DecoratorPattern/MochaCondiment.cs index 934bac1..ae2b45d 100644 --- a/DecoratorPattern/MochaCondiment.cs +++ b/DecoratorPattern/MochaCondiment.cs @@ -12,7 +12,8 @@ public MochaCondiment(Beverage beverage) public override string Description { get { - if (_beverage.Description.StartsWith("Mocha")){ + if (_beverage.Description.StartsWith("Mocha")) + { return "Double " + _beverage.Description; } else From 98a6940dda92450bf6a818ea94cc681c39d1c3d6 Mon Sep 17 00:00:00 2001 From: Abishek Aditya Date: Tue, 4 Jul 2017 14:49:39 +0530 Subject: [PATCH 06/28] create Liscence --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9cecc1d --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 838ae131b2ff250935cd9b86c2b0d1aeee3f626d Mon Sep 17 00:00:00 2001 From: Abishek Aditya Date: Tue, 4 Jul 2017 14:50:49 +0530 Subject: [PATCH 07/28] added code of conduct --- CODE_OF_CONDUCT.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..ffca93c --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at abishekaditya@outlook.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From cf112aa2f062044e544c6d8c289736b78eb4be39 Mon Sep 17 00:00:00 2001 From: Saurabh Mathur Date: Thu, 10 Aug 2017 16:15:28 +0530 Subject: [PATCH 08/28] Update Coffee.cs --- TemplatePattern/Beverages/Coffee.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TemplatePattern/Beverages/Coffee.cs b/TemplatePattern/Beverages/Coffee.cs index 87e4d1f..0462a22 100644 --- a/TemplatePattern/Beverages/Coffee.cs +++ b/TemplatePattern/Beverages/Coffee.cs @@ -6,7 +6,7 @@ class Coffee : Beverage { protected override void Brew() { - Console.WriteLine("Add Coffe Grounds to water and boil"); + Console.WriteLine("Add Coffee Grounds to water and boil"); } protected override void AddCondiments() @@ -15,4 +15,4 @@ protected override void AddCondiments() } } -} \ No newline at end of file +} From 07dd2f396e88471aa086a93d0d462e6e5c1c20e2 Mon Sep 17 00:00:00 2001 From: Ilker Halil Turer Date: Fri, 20 Jul 2018 23:29:10 +0300 Subject: [PATCH 09/28] add DotnetCore support and delete old files (#9) * add DotnetCore support * Delete old project --- .gitignore | 5 + AdapterPattern/AdapterPattern.csproj | 59 +----- AdapterPattern/App.config | 6 - AdapterPattern/Properties/AssemblyInfo.cs | 35 ---- CommandPattern/App.config | 7 - CommandPattern/CommandPattern.csproj | 59 +----- CommandPattern/Properties/AssemblyInfo.cs | 39 ---- CompositePattern/App.config | 6 - CompositePattern/CompositePattern.csproj | 58 +----- CompositePattern/Properties/AssemblyInfo.cs | 36 ---- DecoratorPattern/App.config | 6 - DecoratorPattern/DecoratorPattern.csproj | 61 +----- DecoratorPattern/Properties/AssemblyInfo.cs | 35 ---- DesignPatterns.sln | 88 --------- DesignPatternsDotNetCore.sln | 174 ++++++++++++++++++ FacadePattern/App.config | 6 - FacadePattern/FacadePattern.csproj | 58 +----- FacadePattern/Properties/AssemblyInfo.cs | 36 ---- .../ChicagoIngredientsFactory.cs | 36 ---- .../Abstract Factory/IIngredientsFactory.cs | 13 -- .../Ingredients/CherryTomato.cs | 7 - .../Abstract Factory/Ingredients/Cucumber.cs | 7 - .../Abstract Factory/Ingredients/DeepDish.cs | 7 - .../Abstract Factory/Ingredients/FreshClam.cs | 7 - .../Ingredients/FrozenClam.cs | 7 - .../Ingredients/Intefaces/ICheese.cs | 7 - .../Ingredients/Intefaces/IClam.cs | 7 - .../Ingredients/Intefaces/IDough.cs | 7 - .../Ingredients/Intefaces/ISauce.cs | 7 - .../Ingredients/Intefaces/IVeggies.cs | 7 - .../Abstract Factory/Ingredients/Mozarella.cs | 7 - .../Abstract Factory/Ingredients/Olive.cs | 7 - .../Abstract Factory/Ingredients/Onion.cs | 11 -- .../Abstract Factory/Ingredients/Parmesan.cs | 7 - .../Abstract Factory/Ingredients/Pepper.cs | 8 - .../Ingredients/PlumTomato.cs | 7 - .../Abstract Factory/Ingredients/ThinCrust.cs | 7 - .../Abstract Factory/NYIngredientsFactory.cs | 33 ---- FactoryPattern/App.config | 6 - .../Factory Method/ChicagoPizzaFactory.cs | 29 --- .../Factory Method/NYPizzaFactory.cs | 26 --- FactoryPattern/Factory Method/PizzaFactory.cs | 17 -- FactoryPattern/FactoryPattern.csproj | 80 -------- FactoryPattern/Pizza/CheesePizza.cs | 25 --- FactoryPattern/Pizza/ClamPizza.cs | 22 --- FactoryPattern/Pizza/Pizza.cs | 26 --- FactoryPattern/Pizza/VeggiePizza.cs | 25 --- FactoryPattern/Program.cs | 18 -- FactoryPattern/Properties/AssemblyInfo.cs | 35 ---- IteratorPattern/App.config | 6 - IteratorPattern/IteratorPattern.csproj | 62 +------ IteratorPattern/Properties/AssemblyInfo.cs | 36 ---- ObserverPattern/App.config | 6 - ObserverPattern/ObserverPattern.csproj | 58 +----- ObserverPattern/Properties/AssemblyInfo.cs | 36 ---- SingletonPattern/App.config | 6 - SingletonPattern/Properties/AssemblyInfo.cs | 35 ---- SingletonPattern/SingletonPattern.csproj | 56 +----- StatePattern/App.config | 6 - StatePattern/Properties/AssemblyInfo.cs | 35 ---- StatePattern/StatePattern.csproj | 63 +------ StrategyPattern/App.config | 6 - StrategyPattern/Properties/AssemblyInfo.cs | 35 ---- StrategyPattern/StrategyPattern.csproj | 61 +----- TemplatePattern/App.config | 6 - TemplatePattern/Properties/AssemblyInfo.cs | 35 ---- TemplatePattern/TemplatePattern.csproj | 58 +----- 67 files changed, 234 insertions(+), 1661 deletions(-) delete mode 100644 AdapterPattern/App.config delete mode 100644 AdapterPattern/Properties/AssemblyInfo.cs delete mode 100644 CommandPattern/App.config delete mode 100644 CommandPattern/Properties/AssemblyInfo.cs delete mode 100644 CompositePattern/App.config delete mode 100644 CompositePattern/Properties/AssemblyInfo.cs delete mode 100644 DecoratorPattern/App.config delete mode 100644 DecoratorPattern/Properties/AssemblyInfo.cs delete mode 100644 DesignPatterns.sln create mode 100644 DesignPatternsDotNetCore.sln delete mode 100644 FacadePattern/App.config delete mode 100644 FacadePattern/Properties/AssemblyInfo.cs delete mode 100644 FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs delete mode 100644 FactoryPattern/Abstract Factory/IIngredientsFactory.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Olive.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Onion.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/Pepper.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs delete mode 100644 FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs delete mode 100644 FactoryPattern/Abstract Factory/NYIngredientsFactory.cs delete mode 100644 FactoryPattern/App.config delete mode 100644 FactoryPattern/Factory Method/ChicagoPizzaFactory.cs delete mode 100644 FactoryPattern/Factory Method/NYPizzaFactory.cs delete mode 100644 FactoryPattern/Factory Method/PizzaFactory.cs delete mode 100644 FactoryPattern/FactoryPattern.csproj delete mode 100644 FactoryPattern/Pizza/CheesePizza.cs delete mode 100644 FactoryPattern/Pizza/ClamPizza.cs delete mode 100644 FactoryPattern/Pizza/Pizza.cs delete mode 100644 FactoryPattern/Pizza/VeggiePizza.cs delete mode 100644 FactoryPattern/Program.cs delete mode 100644 FactoryPattern/Properties/AssemblyInfo.cs delete mode 100644 IteratorPattern/App.config delete mode 100644 IteratorPattern/Properties/AssemblyInfo.cs delete mode 100644 ObserverPattern/App.config delete mode 100644 ObserverPattern/Properties/AssemblyInfo.cs delete mode 100644 SingletonPattern/App.config delete mode 100644 SingletonPattern/Properties/AssemblyInfo.cs delete mode 100644 StatePattern/App.config delete mode 100644 StatePattern/Properties/AssemblyInfo.cs delete mode 100644 StrategyPattern/App.config delete mode 100644 StrategyPattern/Properties/AssemblyInfo.cs delete mode 100644 TemplatePattern/App.config delete mode 100644 TemplatePattern/Properties/AssemblyInfo.cs diff --git a/.gitignore b/.gitignore index 3c4efe2..5ee0c0e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ *.userosscache *.sln.docstates + + + # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs @@ -27,6 +30,8 @@ bld/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ +# Visual Studio Code cache/options directory +.vscode/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* diff --git a/AdapterPattern/AdapterPattern.csproj b/AdapterPattern/AdapterPattern.csproj index c90d11b..ce1697a 100644 --- a/AdapterPattern/AdapterPattern.csproj +++ b/AdapterPattern/AdapterPattern.csproj @@ -1,57 +1,8 @@ - - - + + - Debug - AnyCPU - {68B119D1-3527-4356-946F-CEA179084C91} Exe - AdapterPattern - AdapterPattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/AdapterPattern/App.config b/AdapterPattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/AdapterPattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AdapterPattern/Properties/AssemblyInfo.cs b/AdapterPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 6b9c1c7..0000000 --- a/AdapterPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("AdapterPattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("AdapterPattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("68b119d1-3527-4356-946f-cea179084c91")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CommandPattern/App.config b/CommandPattern/App.config deleted file mode 100644 index 51fffc7..0000000 --- a/CommandPattern/App.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/CommandPattern/CommandPattern.csproj b/CommandPattern/CommandPattern.csproj index 1d6b215..ce1697a 100644 --- a/CommandPattern/CommandPattern.csproj +++ b/CommandPattern/CommandPattern.csproj @@ -1,57 +1,8 @@ - - - + + - Debug - AnyCPU - {8F58357D-C54F-4C07-A951-8A93B0520187} Exe - CommandPattern - CommandPattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/CommandPattern/Properties/AssemblyInfo.cs b/CommandPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index a23cf81..0000000 --- a/CommandPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("CommandPattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("CommandPattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("8f58357d-c54f-4c07-a951-8a93b0520187")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/CompositePattern/App.config b/CompositePattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/CompositePattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CompositePattern/CompositePattern.csproj b/CompositePattern/CompositePattern.csproj index 0baed4b..ce1697a 100644 --- a/CompositePattern/CompositePattern.csproj +++ b/CompositePattern/CompositePattern.csproj @@ -1,56 +1,8 @@ - - - + + - Debug - AnyCPU - {0D5AA731-03F0-4CF6-AEA3-254F06472911} Exe - CompositePattern - CompositePattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/CompositePattern/Properties/AssemblyInfo.cs b/CompositePattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 553b29b..0000000 --- a/CompositePattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("CompositePattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("CompositePattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0d5aa731-03f0-4cf6-aea3-254f06472911")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DecoratorPattern/App.config b/DecoratorPattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/DecoratorPattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DecoratorPattern/DecoratorPattern.csproj b/DecoratorPattern/DecoratorPattern.csproj index 713eb78..ce1697a 100644 --- a/DecoratorPattern/DecoratorPattern.csproj +++ b/DecoratorPattern/DecoratorPattern.csproj @@ -1,59 +1,8 @@ - - - + + - Debug - AnyCPU - {6E63BDD0-01A4-4A88-8A89-9B45D51B526D} Exe - DecoratorPattern - DecoratorPattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/DecoratorPattern/Properties/AssemblyInfo.cs b/DecoratorPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 8ad6185..0000000 --- a/DecoratorPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("DecoratorPattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DecoratorPattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6e63bdd0-01a4-4a88-8a89-9b45d51b526d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DesignPatterns.sln b/DesignPatterns.sln deleted file mode 100644 index 29eace1..0000000 --- a/DesignPatterns.sln +++ /dev/null @@ -1,88 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObserverPattern", "ObserverPattern\ObserverPattern.csproj", "{678581C4-15DC-4A01-93CD-76ACBD5B7462}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrategyPattern", "StrategyPattern\StrategyPattern.csproj", "{1F52949E-3569-44EC-8C1C-870D5B263694}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecoratorPattern", "DecoratorPattern\DecoratorPattern.csproj", "{6E63BDD0-01A4-4A88-8A89-9B45D51B526D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{D154B3A3-1C97-4B70-AD4F-DC4DB8F52300}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingletonPattern", "SingletonPattern\SingletonPattern.csproj", "{DF749AC5-3277-45B6-B39E-61E7D842B1BA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandPattern", "CommandPattern\CommandPattern.csproj", "{8F58357D-C54F-4C07-A951-8A93B0520187}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{68B119D1-3527-4356-946F-CEA179084C91}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FacadePattern", "FacadePattern\FacadePattern.csproj", "{C5CB5821-CC3B-4440-9CB9-A571A5D7B872}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplatePattern", "TemplatePattern\TemplatePattern.csproj", "{FCE8A301-EE20-42DB-82DD-47AB0B569BC9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IteratorPattern", "IteratorPattern\IteratorPattern.csproj", "{A3B8C12F-5DAC-4CEA-B039-C2CBD7A5C9AD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompositePattern", "CompositePattern\CompositePattern.csproj", "{0D5AA731-03F0-4CF6-AEA3-254F06472911}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatePattern", "StatePattern\StatePattern.csproj", "{974FE8E8-7379-4DCC-9D4F-763D60F5E708}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {678581C4-15DC-4A01-93CD-76ACBD5B7462}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {678581C4-15DC-4A01-93CD-76ACBD5B7462}.Debug|Any CPU.Build.0 = Debug|Any CPU - {678581C4-15DC-4A01-93CD-76ACBD5B7462}.Release|Any CPU.ActiveCfg = Release|Any CPU - {678581C4-15DC-4A01-93CD-76ACBD5B7462}.Release|Any CPU.Build.0 = Release|Any CPU - {1F52949E-3569-44EC-8C1C-870D5B263694}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1F52949E-3569-44EC-8C1C-870D5B263694}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1F52949E-3569-44EC-8C1C-870D5B263694}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1F52949E-3569-44EC-8C1C-870D5B263694}.Release|Any CPU.Build.0 = Release|Any CPU - {6E63BDD0-01A4-4A88-8A89-9B45D51B526D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6E63BDD0-01A4-4A88-8A89-9B45D51B526D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6E63BDD0-01A4-4A88-8A89-9B45D51B526D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6E63BDD0-01A4-4A88-8A89-9B45D51B526D}.Release|Any CPU.Build.0 = Release|Any CPU - {D154B3A3-1C97-4B70-AD4F-DC4DB8F52300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D154B3A3-1C97-4B70-AD4F-DC4DB8F52300}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D154B3A3-1C97-4B70-AD4F-DC4DB8F52300}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D154B3A3-1C97-4B70-AD4F-DC4DB8F52300}.Release|Any CPU.Build.0 = Release|Any CPU - {DF749AC5-3277-45B6-B39E-61E7D842B1BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DF749AC5-3277-45B6-B39E-61E7D842B1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DF749AC5-3277-45B6-B39E-61E7D842B1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DF749AC5-3277-45B6-B39E-61E7D842B1BA}.Release|Any CPU.Build.0 = Release|Any CPU - {8F58357D-C54F-4C07-A951-8A93B0520187}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F58357D-C54F-4C07-A951-8A93B0520187}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F58357D-C54F-4C07-A951-8A93B0520187}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F58357D-C54F-4C07-A951-8A93B0520187}.Release|Any CPU.Build.0 = Release|Any CPU - {68B119D1-3527-4356-946F-CEA179084C91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {68B119D1-3527-4356-946F-CEA179084C91}.Debug|Any CPU.Build.0 = Debug|Any CPU - {68B119D1-3527-4356-946F-CEA179084C91}.Release|Any CPU.ActiveCfg = Release|Any CPU - {68B119D1-3527-4356-946F-CEA179084C91}.Release|Any CPU.Build.0 = Release|Any CPU - {C5CB5821-CC3B-4440-9CB9-A571A5D7B872}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5CB5821-CC3B-4440-9CB9-A571A5D7B872}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C5CB5821-CC3B-4440-9CB9-A571A5D7B872}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C5CB5821-CC3B-4440-9CB9-A571A5D7B872}.Release|Any CPU.Build.0 = Release|Any CPU - {FCE8A301-EE20-42DB-82DD-47AB0B569BC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FCE8A301-EE20-42DB-82DD-47AB0B569BC9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FCE8A301-EE20-42DB-82DD-47AB0B569BC9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FCE8A301-EE20-42DB-82DD-47AB0B569BC9}.Release|Any CPU.Build.0 = Release|Any CPU - {A3B8C12F-5DAC-4CEA-B039-C2CBD7A5C9AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A3B8C12F-5DAC-4CEA-B039-C2CBD7A5C9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A3B8C12F-5DAC-4CEA-B039-C2CBD7A5C9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A3B8C12F-5DAC-4CEA-B039-C2CBD7A5C9AD}.Release|Any CPU.Build.0 = Release|Any CPU - {0D5AA731-03F0-4CF6-AEA3-254F06472911}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0D5AA731-03F0-4CF6-AEA3-254F06472911}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0D5AA731-03F0-4CF6-AEA3-254F06472911}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0D5AA731-03F0-4CF6-AEA3-254F06472911}.Release|Any CPU.Build.0 = Release|Any CPU - {974FE8E8-7379-4DCC-9D4F-763D60F5E708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {974FE8E8-7379-4DCC-9D4F-763D60F5E708}.Debug|Any CPU.Build.0 = Debug|Any CPU - {974FE8E8-7379-4DCC-9D4F-763D60F5E708}.Release|Any CPU.ActiveCfg = Release|Any CPU - {974FE8E8-7379-4DCC-9D4F-763D60F5E708}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln new file mode 100644 index 0000000..561d7c2 --- /dev/null +++ b/DesignPatternsDotNetCore.sln @@ -0,0 +1,174 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{79553F75-E8DC-4988-B511-A79CC6A9CDF7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandPattern", "CommandPattern\CommandPattern.csproj", "{AC6ED373-CE32-41E4-B38A-64B8700E46C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompositePattern", "CompositePattern\CompositePattern.csproj", "{21754CEF-8885-4EED-91AF-73FF2514553D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecoratorPattern", "DecoratorPattern\DecoratorPattern.csproj", "{5F9D7DA1-FA5E-477C-87D7-2A131C99D090}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FacadePattern", "FacadePattern\FacadePattern.csproj", "{CCDDFDE2-9958-476C-91DB-9F2907887ADE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IteratorPattern", "IteratorPattern\IteratorPattern.csproj", "{C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObserverPattern", "ObserverPattern\ObserverPattern.csproj", "{DDE34459-B244-43F9-8DE2-8D1E70CB6609}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingletonPattern", "SingletonPattern\SingletonPattern.csproj", "{FA82E572-FC03-4C87-86FA-660AF06AA24A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatePattern", "StatePattern\StatePattern.csproj", "{1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrategyPattern", "StrategyPattern\StrategyPattern.csproj", "{73D240B4-428D-4BC1-BC3C-C14D1D9D806E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplatePattern", "TemplatePattern\TemplatePattern.csproj", "{928CD7B2-BB6E-4E07-834E-67B20CA6D698}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x64.ActiveCfg = Debug|x64 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x64.Build.0 = Debug|x64 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x86.ActiveCfg = Debug|x86 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x86.Build.0 = Debug|x86 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|Any CPU.Build.0 = Release|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x64.ActiveCfg = Release|x64 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x64.Build.0 = Release|x64 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x86.ActiveCfg = Release|x86 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x86.Build.0 = Release|x86 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x64.ActiveCfg = Debug|x64 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x64.Build.0 = Debug|x64 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x86.ActiveCfg = Debug|x86 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x86.Build.0 = Debug|x86 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|Any CPU.Build.0 = Release|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x64.ActiveCfg = Release|x64 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x64.Build.0 = Release|x64 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x86.ActiveCfg = Release|x86 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x86.Build.0 = Release|x86 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x64.ActiveCfg = Debug|x64 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x64.Build.0 = Debug|x64 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x86.ActiveCfg = Debug|x86 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x86.Build.0 = Debug|x86 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|Any CPU.Build.0 = Release|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x64.ActiveCfg = Release|x64 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x64.Build.0 = Release|x64 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x86.ActiveCfg = Release|x86 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x86.Build.0 = Release|x86 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x64.ActiveCfg = Debug|x64 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x64.Build.0 = Debug|x64 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x86.ActiveCfg = Debug|x86 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x86.Build.0 = Debug|x86 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|Any CPU.Build.0 = Release|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x64.ActiveCfg = Release|x64 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x64.Build.0 = Release|x64 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x86.ActiveCfg = Release|x86 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x86.Build.0 = Release|x86 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x64.ActiveCfg = Debug|x64 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x64.Build.0 = Debug|x64 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x86.ActiveCfg = Debug|x86 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x86.Build.0 = Debug|x86 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|Any CPU.Build.0 = Release|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x64.ActiveCfg = Release|x64 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x64.Build.0 = Release|x64 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x86.ActiveCfg = Release|x86 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x86.Build.0 = Release|x86 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x64.ActiveCfg = Debug|x64 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x64.Build.0 = Debug|x64 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x86.ActiveCfg = Debug|x86 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x86.Build.0 = Debug|x86 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|Any CPU.Build.0 = Release|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x64.ActiveCfg = Release|x64 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x64.Build.0 = Release|x64 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x86.ActiveCfg = Release|x86 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x86.Build.0 = Release|x86 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x64.ActiveCfg = Debug|x64 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x64.Build.0 = Debug|x64 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x86.ActiveCfg = Debug|x86 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x86.Build.0 = Debug|x86 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|Any CPU.Build.0 = Release|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x64.ActiveCfg = Release|x64 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x64.Build.0 = Release|x64 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x86.ActiveCfg = Release|x86 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x86.Build.0 = Release|x86 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x64.ActiveCfg = Debug|x64 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x64.Build.0 = Debug|x64 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x86.ActiveCfg = Debug|x86 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x86.Build.0 = Debug|x86 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|Any CPU.Build.0 = Release|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x64.ActiveCfg = Release|x64 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x64.Build.0 = Release|x64 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x86.ActiveCfg = Release|x86 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x86.Build.0 = Release|x86 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x64.ActiveCfg = Debug|x64 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x64.Build.0 = Debug|x64 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x86.ActiveCfg = Debug|x86 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x86.Build.0 = Debug|x86 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|Any CPU.Build.0 = Release|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x64.ActiveCfg = Release|x64 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x64.Build.0 = Release|x64 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x86.ActiveCfg = Release|x86 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x86.Build.0 = Release|x86 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x64.ActiveCfg = Debug|x64 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x64.Build.0 = Debug|x64 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x86.ActiveCfg = Debug|x86 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x86.Build.0 = Debug|x86 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|Any CPU.Build.0 = Release|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x64.ActiveCfg = Release|x64 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x64.Build.0 = Release|x64 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x86.ActiveCfg = Release|x86 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x86.Build.0 = Release|x86 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|Any CPU.Build.0 = Debug|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x64.ActiveCfg = Debug|x64 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x64.Build.0 = Debug|x64 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x86.ActiveCfg = Debug|x86 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x86.Build.0 = Debug|x86 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|Any CPU.ActiveCfg = Release|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|Any CPU.Build.0 = Release|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x64.ActiveCfg = Release|x64 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x64.Build.0 = Release|x64 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.ActiveCfg = Release|x86 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.Build.0 = Release|x86 + EndGlobalSection +EndGlobal diff --git a/FacadePattern/App.config b/FacadePattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/FacadePattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/FacadePattern/FacadePattern.csproj b/FacadePattern/FacadePattern.csproj index ca3bab7..ce1697a 100644 --- a/FacadePattern/FacadePattern.csproj +++ b/FacadePattern/FacadePattern.csproj @@ -1,56 +1,8 @@ - - - + + - Debug - AnyCPU - {C5CB5821-CC3B-4440-9CB9-A571A5D7B872} Exe - FacadePattern - FacadePattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/FacadePattern/Properties/AssemblyInfo.cs b/FacadePattern/Properties/AssemblyInfo.cs deleted file mode 100644 index e778ca3..0000000 --- a/FacadePattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("FacadePattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("FacadePattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c5cb5821-cc3b-4440-9cb9-a571a5d7b872")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs b/FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs deleted file mode 100644 index 53c9430..0000000 --- a/FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; - -namespace FactoryPattern -{ - internal class ChicagoIngredientsFactory : IIngredientsFactory - { - ICheese IIngredientsFactory.CreateCheese() - { - return new Parmesan(); - } - - IClam IIngredientsFactory.CreateClam() - { - return new FreshClam(); - } - - IDough IIngredientsFactory.CreateDough() - { - return new DeepDish(); - } - - ISauce IIngredientsFactory.CreateSauce() - { - return new PlumTomato(); - } - - IEnumerable IIngredientsFactory.CreateVeggies() - { - var oni = new Onion(); - var ccm = new Cucumber(); - var ppr = new Pepper(); - IVeggies[] arr = { oni, ccm, ppr }; - return arr; - } - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/IIngredientsFactory.cs b/FactoryPattern/Abstract Factory/IIngredientsFactory.cs deleted file mode 100644 index 9010710..0000000 --- a/FactoryPattern/Abstract Factory/IIngredientsFactory.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; - -namespace FactoryPattern -{ - interface IIngredientsFactory - { - IDough CreateDough(); - IEnumerable CreateVeggies(); - ISauce CreateSauce(); - ICheese CreateCheese(); - IClam CreateClam(); - } -} diff --git a/FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs b/FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs deleted file mode 100644 index 0b5be78..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class CherryTomato : ISauce - { - public string Name => "Cherry Tomato"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs b/FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs deleted file mode 100644 index 39be3a1..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class Cucumber : IVeggies - { - public string Name => "Cucumber"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs b/FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs deleted file mode 100644 index 3d6ef79..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class DeepDish : IDough - { - public string Name => "Deep Dish"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs b/FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs deleted file mode 100644 index e2cf85a..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class FreshClam : IClam - { - public string Name => "Fresh Clam"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs b/FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs deleted file mode 100644 index 45bdcc9..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class FrozenClam : IClam - { - public string Name => "Frozen Clam"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs deleted file mode 100644 index 5c9f2f7..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - public interface ICheese - { - string Name { get; } - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs deleted file mode 100644 index 5aaa65e..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - public interface IClam - { - string Name { get; } - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs deleted file mode 100644 index 9bb5b89..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - public interface IDough - { - string Name { get; } - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs deleted file mode 100644 index 647b073..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - public interface ISauce - { - string Name { get; } - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs deleted file mode 100644 index d258bd8..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - public interface IVeggies - { - string Name { get; } - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs b/FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs deleted file mode 100644 index 30d780f..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class Mozarella : ICheese - { - public string Name => "Mozarella"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Olive.cs b/FactoryPattern/Abstract Factory/Ingredients/Olive.cs deleted file mode 100644 index f0b9d48..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Olive.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class Olive : IVeggies - { - public string Name => "Olives"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Onion.cs b/FactoryPattern/Abstract Factory/Ingredients/Onion.cs deleted file mode 100644 index c752b3c..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Onion.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FactoryPattern -{ - internal class Onion : IVeggies - { - public Onion() - { - } - - public string Name => "Onions"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs b/FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs deleted file mode 100644 index 05b95da..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class Parmesan : ICheese - { - public string Name => "Parmesan"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Pepper.cs b/FactoryPattern/Abstract Factory/Ingredients/Pepper.cs deleted file mode 100644 index 9f1a1e5..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/Pepper.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FactoryPattern -{ - internal class Pepper : IVeggies - { - - public string Name => "Bell Peppers"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs b/FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs deleted file mode 100644 index dfa40db..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class PlumTomato : ISauce - { - public string Name => "Plum Tomato"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs b/FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs deleted file mode 100644 index 5fbe3e6..0000000 --- a/FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FactoryPattern -{ - internal class ThinCrust : IDough - { - public string Name => "Thin Crust"; - } -} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/NYIngredientsFactory.cs b/FactoryPattern/Abstract Factory/NYIngredientsFactory.cs deleted file mode 100644 index dc0ea1c..0000000 --- a/FactoryPattern/Abstract Factory/NYIngredientsFactory.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; - -namespace FactoryPattern -{ - internal class NyIngredientsFactory : IIngredientsFactory - { - ICheese IIngredientsFactory.CreateCheese() - { - return new Mozarella(); - } - - IClam IIngredientsFactory.CreateClam() - { - return new FrozenClam(); - } - - IDough IIngredientsFactory.CreateDough() - { - return new ThinCrust(); - } - - ISauce IIngredientsFactory.CreateSauce() - { - return new CherryTomato(); - } - - IEnumerable IIngredientsFactory.CreateVeggies() - { - IVeggies[] arr = { new Onion(), new Pepper(), new Olive() }; - return arr; - } - } -} \ No newline at end of file diff --git a/FactoryPattern/App.config b/FactoryPattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/FactoryPattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs b/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs deleted file mode 100644 index 63df3a3..0000000 --- a/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace FactoryPattern -{ - class ChicagoPizzaFactory : PizzaFactory - { - protected override Pizza Create(string type) - { - Pizza pizza; - IIngredientsFactory ingredients = new ChicagoIngredientsFactory(); - - if (type.Equals("Cheese")) - { - pizza = new CheesePizza(ingredients); - pizza.Name = "Chicago Cheese"; - } - else if (type.Equals("Clam")) - { - pizza = new ClamPizza(ingredients); - pizza.Name = "Chicago Clam"; - } - else - { - pizza = new VeggiePizza(ingredients); - pizza.Name = "Chicago Veggie"; - } - pizza.Color = "red"; - return pizza; - } - } -} diff --git a/FactoryPattern/Factory Method/NYPizzaFactory.cs b/FactoryPattern/Factory Method/NYPizzaFactory.cs deleted file mode 100644 index d1a2776..0000000 --- a/FactoryPattern/Factory Method/NYPizzaFactory.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace FactoryPattern -{ - class NyPizzaFactory : PizzaFactory - { - protected override Pizza Create(string type) - { - Pizza pizza; - IIngredientsFactory ingredients = new NyIngredientsFactory(); - - if (type.Equals("Cheese")) - { - pizza = new CheesePizza(ingredients) {Name = "NY Style Cheese"}; - } - else if (type.Equals("Clam")) - { - pizza = new ClamPizza(ingredients) {Name = "NY Style Clam"}; - } - else - { - pizza = new VeggiePizza(ingredients) {Name = "NY Style Veggie"}; - } - pizza.Color = "blue"; - return pizza; - } - } -} diff --git a/FactoryPattern/Factory Method/PizzaFactory.cs b/FactoryPattern/Factory Method/PizzaFactory.cs deleted file mode 100644 index 31ead68..0000000 --- a/FactoryPattern/Factory Method/PizzaFactory.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FactoryPattern -{ - abstract class PizzaFactory - { - public Pizza Order(string type) - { - var pizza = Create(type); - pizza.Prepare(); - pizza.Bake(); - pizza.Cut(); - pizza.Box(); - return pizza; - } - - protected abstract Pizza Create(string type); - } -} diff --git a/FactoryPattern/FactoryPattern.csproj b/FactoryPattern/FactoryPattern.csproj deleted file mode 100644 index 7202cea..0000000 --- a/FactoryPattern/FactoryPattern.csproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - - Debug - AnyCPU - {D154B3A3-1C97-4B70-AD4F-DC4DB8F52300} - Exe - FactoryPattern - FactoryPattern - v4.5.2 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/FactoryPattern/Pizza/CheesePizza.cs b/FactoryPattern/Pizza/CheesePizza.cs deleted file mode 100644 index 60dac3c..0000000 --- a/FactoryPattern/Pizza/CheesePizza.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace FactoryPattern -{ - class CheesePizza : Pizza - { - readonly IIngredientsFactory _ingredients; - - public CheesePizza(IIngredientsFactory ing) - { - _ingredients = ing; - } - internal override void Prepare() - { - Console.WriteLine("Preparing " + Name + " Using"); - Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Cheese: " + _ingredients.CreateCheese().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Veggies: "); - Console.WriteLine(); - foreach (var val in _ingredients.CreateVeggies()) - { - Console.Write(val.Name + " "); - } - Console.WriteLine(); - } - } -} diff --git a/FactoryPattern/Pizza/ClamPizza.cs b/FactoryPattern/Pizza/ClamPizza.cs deleted file mode 100644 index 1879cf9..0000000 --- a/FactoryPattern/Pizza/ClamPizza.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace FactoryPattern -{ - class ClamPizza : Pizza - { - readonly IIngredientsFactory _ingredients; - - public ClamPizza(IIngredientsFactory ing) - { - _ingredients = ing; - } - - internal override void Prepare() - { - Console.WriteLine("Preparing " + Name + " Using"); - Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Clam: " + _ingredients.CreateClam().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Cheese: " + _ingredients.CreateCheese().Name); - Console.WriteLine(); - - } - } -} diff --git a/FactoryPattern/Pizza/Pizza.cs b/FactoryPattern/Pizza/Pizza.cs deleted file mode 100644 index e50ec8a..0000000 --- a/FactoryPattern/Pizza/Pizza.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace FactoryPattern -{ - abstract class Pizza - { - public string Color; - - internal abstract void Prepare(); - internal void Bake() - { - Console.WriteLine("Baking at 135 degree Celsius for 20 minutes"); - } - internal void Cut() - { - Console.WriteLine("Cutting into diagonal pieces"); - } - internal void Box() - { - Console.WriteLine("Putting pizza in " + Color + " coloured box"); - } - - public string Name { protected get; set; } - - } -} diff --git a/FactoryPattern/Pizza/VeggiePizza.cs b/FactoryPattern/Pizza/VeggiePizza.cs deleted file mode 100644 index e0796e0..0000000 --- a/FactoryPattern/Pizza/VeggiePizza.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace FactoryPattern -{ - class VeggiePizza : Pizza - { - readonly IIngredientsFactory _ingredients; - - public VeggiePizza(IIngredientsFactory ing) - { - _ingredients = ing; - } - internal override void Prepare() - { - Console.WriteLine("Preparing " + Name + " Using"); - Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Cheese: " + _ingredients.CreateCheese().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Veggies: "); - Console.WriteLine(); - foreach (var val in _ingredients.CreateVeggies()) - { - Console.Write(val.Name + " "); - } - Console.WriteLine(); - } - } -} diff --git a/FactoryPattern/Program.cs b/FactoryPattern/Program.cs deleted file mode 100644 index 21a9212..0000000 --- a/FactoryPattern/Program.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace FactoryPattern -{ - static class Program - { - static void Main() - { - Console.WriteLine("Yankees fan orders:"); - var yankees = new NyPizzaFactory(); - yankees.Order("Cheese"); - Console.WriteLine(); - Console.WriteLine("Cubs fan orders:"); - var cubs = new ChicagoPizzaFactory(); - cubs.Order("Clam"); - } - } -} diff --git a/FactoryPattern/Properties/AssemblyInfo.cs b/FactoryPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index bf2f310..0000000 --- a/FactoryPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("FactoryPattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("FactoryPattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("d154b3a3-1c97-4b70-ad4f-dc4db8f52300")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/IteratorPattern/App.config b/IteratorPattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/IteratorPattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/IteratorPattern/IteratorPattern.csproj b/IteratorPattern/IteratorPattern.csproj index 005791c..ce1697a 100644 --- a/IteratorPattern/IteratorPattern.csproj +++ b/IteratorPattern/IteratorPattern.csproj @@ -1,60 +1,8 @@ - - - + + - Debug - AnyCPU - {A3B8C12F-5DAC-4CEA-B039-C2CBD7A5C9AD} Exe - IteratorPattern - IteratorPattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/IteratorPattern/Properties/AssemblyInfo.cs b/IteratorPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 62fb325..0000000 --- a/IteratorPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("IteratorPattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("IteratorPattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a3b8c12f-5dac-4cea-b039-c2cbd7a5c9ad")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ObserverPattern/App.config b/ObserverPattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/ObserverPattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ObserverPattern/ObserverPattern.csproj b/ObserverPattern/ObserverPattern.csproj index 28f78db..ce1697a 100644 --- a/ObserverPattern/ObserverPattern.csproj +++ b/ObserverPattern/ObserverPattern.csproj @@ -1,56 +1,8 @@ - - - + + - Debug - AnyCPU - {678581C4-15DC-4A01-93CD-76ACBD5B7462} Exe - ObserverPattern - ObserverPattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/ObserverPattern/Properties/AssemblyInfo.cs b/ObserverPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 471caec..0000000 --- a/ObserverPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ObserverPattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ObserverPattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("678581c4-15dc-4a01-93cd-76acbd5b7462")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SingletonPattern/App.config b/SingletonPattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/SingletonPattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/SingletonPattern/Properties/AssemblyInfo.cs b/SingletonPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 4837f8d..0000000 --- a/SingletonPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SingletonPattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SingletonPattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("df749ac5-3277-45b6-b39e-61e7d842b1ba")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SingletonPattern/SingletonPattern.csproj b/SingletonPattern/SingletonPattern.csproj index 45bafb2..ce1697a 100644 --- a/SingletonPattern/SingletonPattern.csproj +++ b/SingletonPattern/SingletonPattern.csproj @@ -1,54 +1,8 @@ - - - + + - Debug - AnyCPU - {DF749AC5-3277-45B6-B39E-61E7D842B1BA} Exe - SingletonPattern - SingletonPattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/StatePattern/App.config b/StatePattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/StatePattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/StatePattern/Properties/AssemblyInfo.cs b/StatePattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 9069228..0000000 --- a/StatePattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("StatePattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("StatePattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("974fe8e8-7379-4dcc-9d4f-763d60f5e708")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/StatePattern/StatePattern.csproj b/StatePattern/StatePattern.csproj index c10b7b7..ce1697a 100644 --- a/StatePattern/StatePattern.csproj +++ b/StatePattern/StatePattern.csproj @@ -1,61 +1,8 @@ - - - + + - Debug - AnyCPU - {974FE8E8-7379-4DCC-9D4F-763D60F5E708} Exe - StatePattern - StatePattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/StrategyPattern/App.config b/StrategyPattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/StrategyPattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/StrategyPattern/Properties/AssemblyInfo.cs b/StrategyPattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 89145b8..0000000 --- a/StrategyPattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Ducks")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Ducks")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1f52949e-3569-44ec-8c1c-870d5b263694")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/StrategyPattern/StrategyPattern.csproj b/StrategyPattern/StrategyPattern.csproj index a9bd777..ce1697a 100644 --- a/StrategyPattern/StrategyPattern.csproj +++ b/StrategyPattern/StrategyPattern.csproj @@ -1,59 +1,8 @@ - - - + + - Debug - AnyCPU - {1F52949E-3569-44EC-8C1C-870D5B263694} Exe - StrategyPattern - StrategyPattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/TemplatePattern/App.config b/TemplatePattern/App.config deleted file mode 100644 index 88fa402..0000000 --- a/TemplatePattern/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/TemplatePattern/Properties/AssemblyInfo.cs b/TemplatePattern/Properties/AssemblyInfo.cs deleted file mode 100644 index 82372c0..0000000 --- a/TemplatePattern/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TemplatePattern")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TemplatePattern")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("fce8a301-ee20-42db-82dd-47ab0b569bc9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TemplatePattern/TemplatePattern.csproj b/TemplatePattern/TemplatePattern.csproj index 886b83e..ce1697a 100644 --- a/TemplatePattern/TemplatePattern.csproj +++ b/TemplatePattern/TemplatePattern.csproj @@ -1,56 +1,8 @@ - - - + + - Debug - AnyCPU - {FCE8A301-EE20-42DB-82DD-47AB0B569BC9} Exe - TemplatePattern - TemplatePattern - v4.5.2 - 512 - true + netcoreapp2.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + From f406906792dab6223e564283ddc44a66f5231faf Mon Sep 17 00:00:00 2001 From: Ricky Wu Date: Fri, 21 Sep 2018 23:38:50 +1000 Subject: [PATCH 10/28] Bridge Pattern (#10) * Bridge Pattern * Update README for Bridge Pattern --- BridgePattern/BridgePattern.csproj | 8 ++++++ BridgePattern/FlyingEnchantment.cs | 22 +++++++++++++++ BridgePattern/Hammer.cs | 36 +++++++++++++++++++++++++ BridgePattern/IEnchantment.cs | 9 +++++++ BridgePattern/IWeapon.cs | 10 +++++++ BridgePattern/Program.cs | 18 +++++++++++++ BridgePattern/SoulEatingEnchantment.cs | 22 +++++++++++++++ BridgePattern/Sword.cs | 37 ++++++++++++++++++++++++++ DesignPatternsDotNetCore.sln | 14 ++++++++++ README.md | 1 + 10 files changed, 177 insertions(+) create mode 100644 BridgePattern/BridgePattern.csproj create mode 100644 BridgePattern/FlyingEnchantment.cs create mode 100644 BridgePattern/Hammer.cs create mode 100644 BridgePattern/IEnchantment.cs create mode 100644 BridgePattern/IWeapon.cs create mode 100644 BridgePattern/Program.cs create mode 100644 BridgePattern/SoulEatingEnchantment.cs create mode 100644 BridgePattern/Sword.cs diff --git a/BridgePattern/BridgePattern.csproj b/BridgePattern/BridgePattern.csproj new file mode 100644 index 0000000..51b7f6c --- /dev/null +++ b/BridgePattern/BridgePattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/BridgePattern/FlyingEnchantment.cs b/BridgePattern/FlyingEnchantment.cs new file mode 100644 index 0000000..4678965 --- /dev/null +++ b/BridgePattern/FlyingEnchantment.cs @@ -0,0 +1,22 @@ +using System; + +namespace BridgePattern +{ + public class FlyingEnchantment:IEnchantment + { + public void OnActivate() + { + Console.WriteLine("The item begins to glow faintly."); + } + + public void Apply() + { + Console.WriteLine("The item flies and strikes the enemies finally returning to owner's hand."); + } + + public void OnDeactivate() + { + Console.WriteLine("The item's glow fades."); + } + } +} \ No newline at end of file diff --git a/BridgePattern/Hammer.cs b/BridgePattern/Hammer.cs new file mode 100644 index 0000000..99a2786 --- /dev/null +++ b/BridgePattern/Hammer.cs @@ -0,0 +1,36 @@ +using System; + +namespace BridgePattern +{ + public class Hammer:IWeapon + { + private readonly IEnchantment _enchantment; + public Hammer(IEnchantment enchantment) + { + _enchantment = enchantment; + } + + public void Wield() + { + Console.WriteLine("The hammer is wielded."); + _enchantment.OnActivate(); + } + + public void Swing() + { + Console.WriteLine("The hammer is swinged."); + _enchantment.Apply(); + } + + public void Unwield() + { + Console.WriteLine("The hammer is unwielded."); + _enchantment.OnDeactivate(); + } + + public IEnchantment GetEnchantment() + { + return _enchantment; + } + } +} \ No newline at end of file diff --git a/BridgePattern/IEnchantment.cs b/BridgePattern/IEnchantment.cs new file mode 100644 index 0000000..6f958ea --- /dev/null +++ b/BridgePattern/IEnchantment.cs @@ -0,0 +1,9 @@ +namespace BridgePattern +{ + public interface IEnchantment + { + void OnActivate(); + void Apply(); + void OnDeactivate(); + } +} \ No newline at end of file diff --git a/BridgePattern/IWeapon.cs b/BridgePattern/IWeapon.cs new file mode 100644 index 0000000..2b2383b --- /dev/null +++ b/BridgePattern/IWeapon.cs @@ -0,0 +1,10 @@ +namespace BridgePattern +{ + public interface IWeapon + { + void Wield(); + void Swing(); + void Unwield(); + IEnchantment GetEnchantment(); + } +} \ No newline at end of file diff --git a/BridgePattern/Program.cs b/BridgePattern/Program.cs new file mode 100644 index 0000000..2ee4591 --- /dev/null +++ b/BridgePattern/Program.cs @@ -0,0 +1,18 @@ +namespace BridgePattern +{ + internal static class Program + { + private static void Main() + { + IWeapon sword = new Sword(new FlyingEnchantment()); + sword.Wield(); + sword.Swing(); + sword.Unwield(); + + IWeapon hammer = new Hammer(new SoulEatingEnchantment()); + hammer.Wield(); + hammer.Swing(); + hammer.Unwield(); + } + } +} \ No newline at end of file diff --git a/BridgePattern/SoulEatingEnchantment.cs b/BridgePattern/SoulEatingEnchantment.cs new file mode 100644 index 0000000..6b8d36d --- /dev/null +++ b/BridgePattern/SoulEatingEnchantment.cs @@ -0,0 +1,22 @@ +using System; + +namespace BridgePattern +{ + public class SoulEatingEnchantment:IEnchantment + { + public void OnActivate() + { + Console.WriteLine("The item spreads bloodlust."); + } + + public void Apply() + { + Console.WriteLine("The item eats the soul of enemies."); + } + + public void OnDeactivate() + { + Console.WriteLine("Bloodlust slowly disappears."); + } + } +} \ No newline at end of file diff --git a/BridgePattern/Sword.cs b/BridgePattern/Sword.cs new file mode 100644 index 0000000..2145b4b --- /dev/null +++ b/BridgePattern/Sword.cs @@ -0,0 +1,37 @@ +using System; + +namespace BridgePattern +{ + public class Sword:IWeapon + { + private readonly IEnchantment _enchantment; + + public Sword(IEnchantment enchantment) + { + _enchantment = enchantment; + } + + public void Wield() + { + Console.WriteLine("The sword is wielded."); + _enchantment.OnActivate(); + } + + public void Swing() + { + Console.WriteLine("The sword is swinged."); + _enchantment.Apply(); + } + + public void Unwield() + { + Console.WriteLine("The sword is unwielded."); + _enchantment.OnDeactivate(); + } + + public IEnchantment GetEnchantment() + { + return _enchantment; + } + } +} \ No newline at end of file diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 561d7c2..ee7d8dc 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrategyPattern", "Strategy EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplatePattern", "TemplatePattern\TemplatePattern.csproj", "{928CD7B2-BB6E-4E07-834E-67B20CA6D698}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BridgePattern", "BridgePattern\BridgePattern.csproj", "{95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -170,5 +172,17 @@ Global {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x64.Build.0 = Release|x64 {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.ActiveCfg = Release|x86 {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.Build.0 = Release|x86 + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|x64.ActiveCfg = Debug|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|x64.Build.0 = Debug|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|x86.ActiveCfg = Debug|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|x86.Build.0 = Debug|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|Any CPU.Build.0 = Release|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|x64.ActiveCfg = Release|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|x64.Build.0 = Release|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|x86.ActiveCfg = Release|Any CPU + {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/README.md b/README.md index 226b076..d929e56 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ There are three kinds of Design Patterns ----------------------------------------- * [Adapter](/AdapterPattern) +* [Bridge](/BridgePattern) * [Command](/CommandPattern) * [Composite](/CompositePattern) * [Decorator](/DecoratorPattern) From 211c909101ac4ceefe89ffdd12c24e2b5c7becfa Mon Sep 17 00:00:00 2001 From: Ricky Wu Date: Thu, 27 Sep 2018 15:08:46 +1000 Subject: [PATCH 11/28] Visitor and Flyweight Patterns (#12) * Bridge Pattern * Update README for Bridge Pattern * Update Flyweight Pattern * Update Visitor Pattern --- DesignPatternsDotNetCore.sln | 28 ++++++++++++ FlyweightPattern/BeverageFlyweightFactory.cs | 46 ++++++++++++++++++++ FlyweightPattern/BeverageType.cs | 7 +++ FlyweightPattern/BubbleMilkTea.cs | 17 ++++++++ FlyweightPattern/BubbleTeaShop.cs | 38 ++++++++++++++++ FlyweightPattern/CoconutMilkTea.cs | 17 ++++++++ FlyweightPattern/FlyweightPattern.csproj | 8 ++++ FlyweightPattern/FoamMilkTea.cs | 18 ++++++++ FlyweightPattern/IBeverage.cs | 7 +++ FlyweightPattern/OolingMilkTea.cs | 18 ++++++++ FlyweightPattern/Program.cs | 13 ++++++ README.md | 2 + VisitorPattern/Apartment.cs | 20 +++++++++ VisitorPattern/ApartmentVisitor.cs | 24 ++++++++++ VisitorPattern/Bedroom.cs | 20 +++++++++ VisitorPattern/BedroomVisitor.cs | 24 ++++++++++ VisitorPattern/IUnitVisitor.cs | 10 +++++ VisitorPattern/LivingRoom.cs | 20 +++++++++ VisitorPattern/LivingRoomVisitor.cs | 24 ++++++++++ VisitorPattern/Program.cs | 22 ++++++++++ VisitorPattern/Studio.cs | 20 +++++++++ VisitorPattern/StudioVisitor.cs | 24 ++++++++++ VisitorPattern/Unit.cs | 22 ++++++++++ VisitorPattern/VisitorPattern.csproj | 8 ++++ 24 files changed, 457 insertions(+) create mode 100644 FlyweightPattern/BeverageFlyweightFactory.cs create mode 100644 FlyweightPattern/BeverageType.cs create mode 100644 FlyweightPattern/BubbleMilkTea.cs create mode 100644 FlyweightPattern/BubbleTeaShop.cs create mode 100644 FlyweightPattern/CoconutMilkTea.cs create mode 100644 FlyweightPattern/FlyweightPattern.csproj create mode 100644 FlyweightPattern/FoamMilkTea.cs create mode 100644 FlyweightPattern/IBeverage.cs create mode 100644 FlyweightPattern/OolingMilkTea.cs create mode 100644 FlyweightPattern/Program.cs create mode 100644 VisitorPattern/Apartment.cs create mode 100644 VisitorPattern/ApartmentVisitor.cs create mode 100644 VisitorPattern/Bedroom.cs create mode 100644 VisitorPattern/BedroomVisitor.cs create mode 100644 VisitorPattern/IUnitVisitor.cs create mode 100644 VisitorPattern/LivingRoom.cs create mode 100644 VisitorPattern/LivingRoomVisitor.cs create mode 100644 VisitorPattern/Program.cs create mode 100644 VisitorPattern/Studio.cs create mode 100644 VisitorPattern/StudioVisitor.cs create mode 100644 VisitorPattern/Unit.cs create mode 100644 VisitorPattern/VisitorPattern.csproj diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index ee7d8dc..f864d07 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -27,6 +27,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplatePattern", "Template EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BridgePattern", "BridgePattern\BridgePattern.csproj", "{95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyweightPattern", "FlyweightPattern\FlyweightPattern.csproj", "{0067EFC3-FC8D-4F1A-AA92-12323CAD0200}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisitorPattern", "VisitorPattern\VisitorPattern.csproj", "{871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -184,5 +188,29 @@ Global {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|x64.Build.0 = Release|Any CPU {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|x86.ActiveCfg = Release|Any CPU {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Release|x86.Build.0 = Release|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Debug|x64.ActiveCfg = Debug|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Debug|x64.Build.0 = Debug|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Debug|x86.ActiveCfg = Debug|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Debug|x86.Build.0 = Debug|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Release|Any CPU.Build.0 = Release|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Release|x64.ActiveCfg = Release|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Release|x64.Build.0 = Release|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Release|x86.ActiveCfg = Release|Any CPU + {0067EFC3-FC8D-4F1A-AA92-12323CAD0200}.Release|x86.Build.0 = Release|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Debug|Any CPU.Build.0 = Debug|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Debug|x64.ActiveCfg = Debug|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Debug|x64.Build.0 = Debug|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Debug|x86.ActiveCfg = Debug|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Debug|x86.Build.0 = Debug|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|Any CPU.ActiveCfg = Release|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|Any CPU.Build.0 = Release|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|x64.ActiveCfg = Release|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|x64.Build.0 = Release|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|x86.ActiveCfg = Release|Any CPU + {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/FlyweightPattern/BeverageFlyweightFactory.cs b/FlyweightPattern/BeverageFlyweightFactory.cs new file mode 100644 index 0000000..2863293 --- /dev/null +++ b/FlyweightPattern/BeverageFlyweightFactory.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; + +namespace FlyweightPattern +{ + public class BeverageFlyweightFactory + { + private readonly Dictionary _beverages; + + public BeverageFlyweightFactory() + { + _beverages = new Dictionary(); + } + + public IBeverage MakeBeverage(BeverageType type) + { + _beverages.TryGetValue(type, out var beverage); + if (beverage == null) + { + switch (type) + { + case BeverageType.BubbleMilk: + beverage = new BubbleMilkTea(); + _beverages.Add(BeverageType.BubbleMilk, beverage); + break; + case BeverageType.FoamMilk: + beverage = new FoamMilkTea(); + _beverages.Add(BeverageType.FoamMilk, beverage); + break; + case BeverageType.OolongMilk: + beverage = new OolingMilkTea(); + _beverages.Add(BeverageType.OolongMilk, beverage); + break; + case BeverageType.CoconutMilk: + beverage = new CoconutMilkTea(); + _beverages.Add(BeverageType.CoconutMilk, beverage); + break; + default: + throw new ArgumentOutOfRangeException(nameof(type), type, null); + } + } + + return beverage; + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/BeverageType.cs b/FlyweightPattern/BeverageType.cs new file mode 100644 index 0000000..4d37a0d --- /dev/null +++ b/FlyweightPattern/BeverageType.cs @@ -0,0 +1,7 @@ +namespace FlyweightPattern +{ + public enum BeverageType + { + BubbleMilk, FoamMilk, OolongMilk, CoconutMilk + } +} \ No newline at end of file diff --git a/FlyweightPattern/BubbleMilkTea.cs b/FlyweightPattern/BubbleMilkTea.cs new file mode 100644 index 0000000..476cd3e --- /dev/null +++ b/FlyweightPattern/BubbleMilkTea.cs @@ -0,0 +1,17 @@ +using System; + +namespace FlyweightPattern +{ + public class BubbleMilkTea: IBeverage + { + public BubbleMilkTea() + { + Console.WriteLine("Initializing a Bubble Milk Tea instance"); + } + + public void Drink() + { + Console.WriteLine("hmmm... this is bubble milk tea"); + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/BubbleTeaShop.cs b/FlyweightPattern/BubbleTeaShop.cs new file mode 100644 index 0000000..4b30646 --- /dev/null +++ b/FlyweightPattern/BubbleTeaShop.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Reflection.Metadata.Ecma335; + +namespace FlyweightPattern +{ + public class BubbleTeaShop + { + private List takeAwayOrders; + + public BubbleTeaShop() + { + takeAwayOrders = new List(); + TakeOrders(); + } + + private void TakeOrders() + { + var factory = new BeverageFlyweightFactory(); + + takeAwayOrders.Add(factory.MakeBeverage(BeverageType.BubbleMilk)); + takeAwayOrders.Add(factory.MakeBeverage(BeverageType.BubbleMilk)); + takeAwayOrders.Add(factory.MakeBeverage(BeverageType.CoconutMilk)); + takeAwayOrders.Add(factory.MakeBeverage(BeverageType.FoamMilk)); + takeAwayOrders.Add(factory.MakeBeverage(BeverageType.OolongMilk)); + takeAwayOrders.Add(factory.MakeBeverage(BeverageType.OolongMilk)); + } + + public void Enumerate() + { + Console.WriteLine("Enumerating take away orders\n"); + foreach (var beverage in takeAwayOrders) + { + beverage.Drink(); + } + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/CoconutMilkTea.cs b/FlyweightPattern/CoconutMilkTea.cs new file mode 100644 index 0000000..b5c89b2 --- /dev/null +++ b/FlyweightPattern/CoconutMilkTea.cs @@ -0,0 +1,17 @@ +using System; + +namespace FlyweightPattern +{ + public class CoconutMilkTea: IBeverage + { + public CoconutMilkTea() + { + Console.WriteLine("Initializing a Coconut Milk Tea instance"); + } + + public void Drink() + { + Console.WriteLine("hmmm... this is coconut milk tea"); + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/FlyweightPattern.csproj b/FlyweightPattern/FlyweightPattern.csproj new file mode 100644 index 0000000..51b7f6c --- /dev/null +++ b/FlyweightPattern/FlyweightPattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/FlyweightPattern/FoamMilkTea.cs b/FlyweightPattern/FoamMilkTea.cs new file mode 100644 index 0000000..eb5c31a --- /dev/null +++ b/FlyweightPattern/FoamMilkTea.cs @@ -0,0 +1,18 @@ +using System; + +namespace FlyweightPattern +{ + public class FoamMilkTea:IBeverage + { + + public FoamMilkTea() + { + Console.WriteLine("Initializing a Foam Milk Tea instance"); + } + + public void Drink() + { + Console.WriteLine("hmmm... this is foam milk tea"); + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/IBeverage.cs b/FlyweightPattern/IBeverage.cs new file mode 100644 index 0000000..0a271d2 --- /dev/null +++ b/FlyweightPattern/IBeverage.cs @@ -0,0 +1,7 @@ +namespace FlyweightPattern +{ + public interface IBeverage + { + void Drink(); + } +} \ No newline at end of file diff --git a/FlyweightPattern/OolingMilkTea.cs b/FlyweightPattern/OolingMilkTea.cs new file mode 100644 index 0000000..432be67 --- /dev/null +++ b/FlyweightPattern/OolingMilkTea.cs @@ -0,0 +1,18 @@ +using System; + +namespace FlyweightPattern +{ + public class OolingMilkTea: IBeverage + { + + public OolingMilkTea() + { + Console.WriteLine("Initializing an Oolong Milk Tea instance"); + } + + public void Drink() + { + Console.WriteLine("hmmm... this is oolong milk tea"); + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/Program.cs b/FlyweightPattern/Program.cs new file mode 100644 index 0000000..91d6ab2 --- /dev/null +++ b/FlyweightPattern/Program.cs @@ -0,0 +1,13 @@ +using System; + +namespace FlyweightPattern +{ + static class Program + { + private static void Main() + { + var teaShop = new BubbleTeaShop(); + teaShop.Enumerate(); + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index d929e56..5f08678 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,11 @@ There are three kinds of Design Patterns * [Decorator](/DecoratorPattern) * [Facade](/FacadePattern) * [Factory](/FactoryPattern) +* [Flyweight](/FlyweightPattern) * [Iterator](/IteratorPattern) * [Observer](/ObserverPattern) * [Singleton](/SingletonPattern) * [State](/StatePattern) * [Strategy](/StrategyPattern) * [Template](/TemplatePattern) +* [Visitor](/VisitorPattern) diff --git a/VisitorPattern/Apartment.cs b/VisitorPattern/Apartment.cs new file mode 100644 index 0000000..bbf18df --- /dev/null +++ b/VisitorPattern/Apartment.cs @@ -0,0 +1,20 @@ +namespace VisitorPattern +{ + public class Apartment: Unit + { + public Apartment(params Unit[] units) : base(units) + { + } + + public override void Accept(IUnitVisitor visitor) + { + visitor.VisitApartment(this); + base.Accept(visitor); + } + + public override string ToString() + { + return "Apartment"; + } + } +} \ No newline at end of file diff --git a/VisitorPattern/ApartmentVisitor.cs b/VisitorPattern/ApartmentVisitor.cs new file mode 100644 index 0000000..21e3d63 --- /dev/null +++ b/VisitorPattern/ApartmentVisitor.cs @@ -0,0 +1,24 @@ +using System; + +namespace VisitorPattern +{ + public class ApartmentVisitor: IUnitVisitor + { + public void VisitApartment(Apartment apartment) + { + Console.WriteLine("This is an apartment"); + } + + public void VisitStudio(Studio studio) + { + } + + public void VisitBedroom(Bedroom bedroom) + { + } + + public void VisitLivingRoom(LivingRoom livingRoom) + { + } + } +} \ No newline at end of file diff --git a/VisitorPattern/Bedroom.cs b/VisitorPattern/Bedroom.cs new file mode 100644 index 0000000..3836d32 --- /dev/null +++ b/VisitorPattern/Bedroom.cs @@ -0,0 +1,20 @@ +namespace VisitorPattern +{ + public class Bedroom: Unit + { + public Bedroom(params Unit[] units) : base(units) + { + } + + public override void Accept(IUnitVisitor visitor) + { + visitor.VisitBedroom(this); + base.Accept(visitor); + } + + public override string ToString() + { + return "Bedroom"; + } + } +} \ No newline at end of file diff --git a/VisitorPattern/BedroomVisitor.cs b/VisitorPattern/BedroomVisitor.cs new file mode 100644 index 0000000..47cfa57 --- /dev/null +++ b/VisitorPattern/BedroomVisitor.cs @@ -0,0 +1,24 @@ +using System; + +namespace VisitorPattern +{ + public class BedroomVisitor: IUnitVisitor + { + public void VisitApartment(Apartment apartment) + { + } + + public void VisitStudio(Studio studio) + { + } + + public void VisitBedroom(Bedroom bedroom) + { + Console.WriteLine("Here is a bedroom"); + } + + public void VisitLivingRoom(LivingRoom livingRoom) + { + } + } +} \ No newline at end of file diff --git a/VisitorPattern/IUnitVisitor.cs b/VisitorPattern/IUnitVisitor.cs new file mode 100644 index 0000000..cae7d6c --- /dev/null +++ b/VisitorPattern/IUnitVisitor.cs @@ -0,0 +1,10 @@ +namespace VisitorPattern +{ + public interface IUnitVisitor + { + void VisitApartment(Apartment apartment); + void VisitStudio(Studio studio); + void VisitBedroom(Bedroom bedroom); + void VisitLivingRoom(LivingRoom livingRoom); + } +} \ No newline at end of file diff --git a/VisitorPattern/LivingRoom.cs b/VisitorPattern/LivingRoom.cs new file mode 100644 index 0000000..54699d3 --- /dev/null +++ b/VisitorPattern/LivingRoom.cs @@ -0,0 +1,20 @@ +namespace VisitorPattern +{ + public class LivingRoom: Unit + { + public LivingRoom(params Unit[] units) : base(units) + { + } + + public override void Accept(IUnitVisitor visitor) + { + visitor.VisitLivingRoom(this); + base.Accept(visitor); + } + + public override string ToString() + { + return "Living Room"; + } + } +} \ No newline at end of file diff --git a/VisitorPattern/LivingRoomVisitor.cs b/VisitorPattern/LivingRoomVisitor.cs new file mode 100644 index 0000000..a45ebb4 --- /dev/null +++ b/VisitorPattern/LivingRoomVisitor.cs @@ -0,0 +1,24 @@ +using System; + +namespace VisitorPattern +{ + public class LivingRoomVisitor: IUnitVisitor + { + public void VisitApartment(Apartment apartment) + { + } + + public void VisitStudio(Studio studio) + { + } + + public void VisitBedroom(Bedroom bedroom) + { + } + + public void VisitLivingRoom(LivingRoom livingRoom) + { + Console.WriteLine("This is the living room"); + } + } +} \ No newline at end of file diff --git a/VisitorPattern/Program.cs b/VisitorPattern/Program.cs new file mode 100644 index 0000000..f328752 --- /dev/null +++ b/VisitorPattern/Program.cs @@ -0,0 +1,22 @@ +using System; + +namespace VisitorPattern +{ + class Program + { + static void Main() + { + var apartment = new Apartment(new LivingRoom(), new Bedroom(), new Bedroom()); + var studio = new Studio(new LivingRoom(), new Bedroom()); + Console.WriteLine("Visiting an Apartment"); + apartment.Accept(new ApartmentVisitor()); + apartment.Accept(new LivingRoomVisitor()); + apartment.Accept(new BedroomVisitor()); + + Console.WriteLine("Visiting a Studio"); + studio.Accept(new StudioVisitor()); + studio.Accept(new LivingRoomVisitor()); + studio.Accept(new BedroomVisitor()); + } + } +} \ No newline at end of file diff --git a/VisitorPattern/Studio.cs b/VisitorPattern/Studio.cs new file mode 100644 index 0000000..8bdc7d3 --- /dev/null +++ b/VisitorPattern/Studio.cs @@ -0,0 +1,20 @@ +namespace VisitorPattern +{ + public class Studio: Unit + { + public Studio(params Unit[] units) : base(units) + { + } + + public override void Accept(IUnitVisitor visitor) + { + visitor.VisitStudio(this); + base.Accept(visitor); + } + + public override string ToString() + { + return "Studio"; + } + } +} \ No newline at end of file diff --git a/VisitorPattern/StudioVisitor.cs b/VisitorPattern/StudioVisitor.cs new file mode 100644 index 0000000..646af15 --- /dev/null +++ b/VisitorPattern/StudioVisitor.cs @@ -0,0 +1,24 @@ +using System; + +namespace VisitorPattern +{ + public class StudioVisitor: IUnitVisitor + { + public void VisitApartment(Apartment apartment) + { + } + + public void VisitStudio(Studio studio) + { + Console.WriteLine("This is a studio"); + } + + public void VisitBedroom(Bedroom bedroom) + { + } + + public void VisitLivingRoom(LivingRoom livingRoom) + { + } + } +} \ No newline at end of file diff --git a/VisitorPattern/Unit.cs b/VisitorPattern/Unit.cs new file mode 100644 index 0000000..13f1b69 --- /dev/null +++ b/VisitorPattern/Unit.cs @@ -0,0 +1,22 @@ +namespace VisitorPattern +{ + public abstract class Unit + { + private Unit[] _units; + + public Unit(params Unit[] units) + { + _units = units; + } + + public virtual void Accept(IUnitVisitor visitor) + { + foreach (var unit in _units) + { + unit.Accept(visitor); + } + } + + public abstract string ToString(); + } +} \ No newline at end of file diff --git a/VisitorPattern/VisitorPattern.csproj b/VisitorPattern/VisitorPattern.csproj new file mode 100644 index 0000000..51b7f6c --- /dev/null +++ b/VisitorPattern/VisitorPattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + From 775eba936fc604fb82abebbd8a06b950dbf9192c Mon Sep 17 00:00:00 2001 From: Abishek Aditya Date: Sat, 20 Oct 2018 20:04:15 +0530 Subject: [PATCH 12/28] Added back factory pattern --- AdapterPattern/Program.cs | 4 +- DesignPatternsDotNetCore.sln | 228 ++++++++++-------- .../ChicagoIngredientsFactory.cs | 36 +++ .../Abstract Factory/IIngredientsFactory.cs | 13 + .../Ingredients/CherryTomato.cs | 7 + .../Abstract Factory/Ingredients/Cucumber.cs | 7 + .../Abstract Factory/Ingredients/DeepDish.cs | 7 + .../Abstract Factory/Ingredients/FreshClam.cs | 7 + .../Ingredients/FrozenClam.cs | 7 + .../Ingredients/Intefaces/ICheese.cs | 7 + .../Ingredients/Intefaces/IClam.cs | 7 + .../Ingredients/Intefaces/IDough.cs | 7 + .../Ingredients/Intefaces/ISauce.cs | 7 + .../Ingredients/Intefaces/IVeggies.cs | 7 + .../Abstract Factory/Ingredients/Mozarella.cs | 7 + .../Abstract Factory/Ingredients/Olive.cs | 7 + .../Abstract Factory/Ingredients/Onion.cs | 11 + .../Abstract Factory/Ingredients/Parmesan.cs | 7 + .../Abstract Factory/Ingredients/Pepper.cs | 8 + .../Ingredients/PlumTomato.cs | 7 + .../Abstract Factory/Ingredients/ThinCrust.cs | 7 + .../Abstract Factory/NYIngredientsFactory.cs | 33 +++ .../Factory Method/ChicagoPizzaFactory.cs | 29 +++ .../Factory Method/NYPizzaFactory.cs | 26 ++ FactoryPattern/Factory Method/PizzaFactory.cs | 17 ++ FactoryPattern/FactoryPattern.csproj | 12 + FactoryPattern/Pizza/CheesePizza.cs | 25 ++ FactoryPattern/Pizza/ClamPizza.cs | 22 ++ FactoryPattern/Pizza/Pizza.cs | 26 ++ FactoryPattern/Pizza/VeggiePizza.cs | 25 ++ FactoryPattern/Program.cs | 18 ++ 31 files changed, 531 insertions(+), 107 deletions(-) create mode 100644 FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs create mode 100644 FactoryPattern/Abstract Factory/IIngredientsFactory.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Olive.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Onion.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/Pepper.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs create mode 100644 FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs create mode 100644 FactoryPattern/Abstract Factory/NYIngredientsFactory.cs create mode 100644 FactoryPattern/Factory Method/ChicagoPizzaFactory.cs create mode 100644 FactoryPattern/Factory Method/NYPizzaFactory.cs create mode 100644 FactoryPattern/Factory Method/PizzaFactory.cs create mode 100644 FactoryPattern/FactoryPattern.csproj create mode 100644 FactoryPattern/Pizza/CheesePizza.cs create mode 100644 FactoryPattern/Pizza/ClamPizza.cs create mode 100644 FactoryPattern/Pizza/Pizza.cs create mode 100644 FactoryPattern/Pizza/VeggiePizza.cs create mode 100644 FactoryPattern/Program.cs diff --git a/AdapterPattern/Program.cs b/AdapterPattern/Program.cs index 3a159fd..e0095ad 100644 --- a/AdapterPattern/Program.cs +++ b/AdapterPattern/Program.cs @@ -1,4 +1,6 @@ -namespace AdapterPattern +using System; + +namespace AdapterPattern { internal static class Program { diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index f864d07..299d95a 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -1,35 +1,36 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26124.0 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{79553F75-E8DC-4988-B511-A79CC6A9CDF7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{79553F75-E8DC-4988-B511-A79CC6A9CDF7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandPattern", "CommandPattern\CommandPattern.csproj", "{AC6ED373-CE32-41E4-B38A-64B8700E46C9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommandPattern", "CommandPattern\CommandPattern.csproj", "{AC6ED373-CE32-41E4-B38A-64B8700E46C9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompositePattern", "CompositePattern\CompositePattern.csproj", "{21754CEF-8885-4EED-91AF-73FF2514553D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompositePattern", "CompositePattern\CompositePattern.csproj", "{21754CEF-8885-4EED-91AF-73FF2514553D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecoratorPattern", "DecoratorPattern\DecoratorPattern.csproj", "{5F9D7DA1-FA5E-477C-87D7-2A131C99D090}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DecoratorPattern", "DecoratorPattern\DecoratorPattern.csproj", "{5F9D7DA1-FA5E-477C-87D7-2A131C99D090}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FacadePattern", "FacadePattern\FacadePattern.csproj", "{CCDDFDE2-9958-476C-91DB-9F2907887ADE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FacadePattern", "FacadePattern\FacadePattern.csproj", "{CCDDFDE2-9958-476C-91DB-9F2907887ADE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IteratorPattern", "IteratorPattern\IteratorPattern.csproj", "{C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IteratorPattern", "IteratorPattern\IteratorPattern.csproj", "{C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObserverPattern", "ObserverPattern\ObserverPattern.csproj", "{DDE34459-B244-43F9-8DE2-8D1E70CB6609}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObserverPattern", "ObserverPattern\ObserverPattern.csproj", "{DDE34459-B244-43F9-8DE2-8D1E70CB6609}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingletonPattern", "SingletonPattern\SingletonPattern.csproj", "{FA82E572-FC03-4C87-86FA-660AF06AA24A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SingletonPattern", "SingletonPattern\SingletonPattern.csproj", "{FA82E572-FC03-4C87-86FA-660AF06AA24A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatePattern", "StatePattern\StatePattern.csproj", "{1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StatePattern", "StatePattern\StatePattern.csproj", "{1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrategyPattern", "StrategyPattern\StrategyPattern.csproj", "{73D240B4-428D-4BC1-BC3C-C14D1D9D806E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StrategyPattern", "StrategyPattern\StrategyPattern.csproj", "{73D240B4-428D-4BC1-BC3C-C14D1D9D806E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplatePattern", "TemplatePattern\TemplatePattern.csproj", "{928CD7B2-BB6E-4E07-834E-67B20CA6D698}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplatePattern", "TemplatePattern\TemplatePattern.csproj", "{928CD7B2-BB6E-4E07-834E-67B20CA6D698}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BridgePattern", "BridgePattern\BridgePattern.csproj", "{95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BridgePattern", "BridgePattern\BridgePattern.csproj", "{95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyweightPattern", "FlyweightPattern\FlyweightPattern.csproj", "{0067EFC3-FC8D-4F1A-AA92-12323CAD0200}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlyweightPattern", "FlyweightPattern\FlyweightPattern.csproj", "{0067EFC3-FC8D-4F1A-AA92-12323CAD0200}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisitorPattern", "VisitorPattern\VisitorPattern.csproj", "{871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisitorPattern", "VisitorPattern\VisitorPattern.csproj", "{871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{182B58DC-6787-4A09-8BCF-87A96737E5A6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -40,142 +41,139 @@ Global Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x64.ActiveCfg = Debug|x64 - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x64.Build.0 = Debug|x64 - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x86.ActiveCfg = Debug|x86 - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x86.Build.0 = Debug|x86 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x64.ActiveCfg = Debug|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x64.Build.0 = Debug|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x86.ActiveCfg = Debug|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Debug|x86.Build.0 = Debug|Any CPU {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|Any CPU.Build.0 = Release|Any CPU - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x64.ActiveCfg = Release|x64 - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x64.Build.0 = Release|x64 - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x86.ActiveCfg = Release|x86 - {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x86.Build.0 = Release|x86 + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x64.ActiveCfg = Release|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x64.Build.0 = Release|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x86.ActiveCfg = Release|Any CPU + {79553F75-E8DC-4988-B511-A79CC6A9CDF7}.Release|x86.Build.0 = Release|Any CPU {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x64.ActiveCfg = Debug|x64 - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x64.Build.0 = Debug|x64 - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x86.ActiveCfg = Debug|x86 - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x86.Build.0 = Debug|x86 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x64.ActiveCfg = Debug|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x64.Build.0 = Debug|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x86.ActiveCfg = Debug|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Debug|x86.Build.0 = Debug|Any CPU {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|Any CPU.Build.0 = Release|Any CPU - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x64.ActiveCfg = Release|x64 - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x64.Build.0 = Release|x64 - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x86.ActiveCfg = Release|x86 - {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x86.Build.0 = Release|x86 + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x64.ActiveCfg = Release|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x64.Build.0 = Release|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x86.ActiveCfg = Release|Any CPU + {AC6ED373-CE32-41E4-B38A-64B8700E46C9}.Release|x86.Build.0 = Release|Any CPU {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x64.ActiveCfg = Debug|x64 - {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x64.Build.0 = Debug|x64 - {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x86.ActiveCfg = Debug|x86 - {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x86.Build.0 = Debug|x86 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x64.ActiveCfg = Debug|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x64.Build.0 = Debug|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x86.ActiveCfg = Debug|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Debug|x86.Build.0 = Debug|Any CPU {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|Any CPU.ActiveCfg = Release|Any CPU {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|Any CPU.Build.0 = Release|Any CPU - {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x64.ActiveCfg = Release|x64 - {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x64.Build.0 = Release|x64 - {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x86.ActiveCfg = Release|x86 - {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x86.Build.0 = Release|x86 + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x64.ActiveCfg = Release|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x64.Build.0 = Release|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x86.ActiveCfg = Release|Any CPU + {21754CEF-8885-4EED-91AF-73FF2514553D}.Release|x86.Build.0 = Release|Any CPU {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x64.ActiveCfg = Debug|x64 - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x64.Build.0 = Debug|x64 - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x86.ActiveCfg = Debug|x86 - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x86.Build.0 = Debug|x86 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x64.ActiveCfg = Debug|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x64.Build.0 = Debug|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x86.ActiveCfg = Debug|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Debug|x86.Build.0 = Debug|Any CPU {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|Any CPU.Build.0 = Release|Any CPU - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x64.ActiveCfg = Release|x64 - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x64.Build.0 = Release|x64 - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x86.ActiveCfg = Release|x86 - {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x86.Build.0 = Release|x86 + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x64.ActiveCfg = Release|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x64.Build.0 = Release|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x86.ActiveCfg = Release|Any CPU + {5F9D7DA1-FA5E-477C-87D7-2A131C99D090}.Release|x86.Build.0 = Release|Any CPU {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x64.ActiveCfg = Debug|x64 - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x64.Build.0 = Debug|x64 - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x86.ActiveCfg = Debug|x86 - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x86.Build.0 = Debug|x86 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x64.ActiveCfg = Debug|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x64.Build.0 = Debug|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x86.ActiveCfg = Debug|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Debug|x86.Build.0 = Debug|Any CPU {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|Any CPU.ActiveCfg = Release|Any CPU {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|Any CPU.Build.0 = Release|Any CPU - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x64.ActiveCfg = Release|x64 - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x64.Build.0 = Release|x64 - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x86.ActiveCfg = Release|x86 - {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x86.Build.0 = Release|x86 + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x64.ActiveCfg = Release|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x64.Build.0 = Release|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x86.ActiveCfg = Release|Any CPU + {CCDDFDE2-9958-476C-91DB-9F2907887ADE}.Release|x86.Build.0 = Release|Any CPU {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x64.ActiveCfg = Debug|x64 - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x64.Build.0 = Debug|x64 - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x86.ActiveCfg = Debug|x86 - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x86.Build.0 = Debug|x86 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x64.ActiveCfg = Debug|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x64.Build.0 = Debug|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x86.ActiveCfg = Debug|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Debug|x86.Build.0 = Debug|Any CPU {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|Any CPU.Build.0 = Release|Any CPU - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x64.ActiveCfg = Release|x64 - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x64.Build.0 = Release|x64 - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x86.ActiveCfg = Release|x86 - {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x86.Build.0 = Release|x86 + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x64.ActiveCfg = Release|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x64.Build.0 = Release|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x86.ActiveCfg = Release|Any CPU + {C50111DC-B037-4A4C-ACA1-5BDE93F7D42A}.Release|x86.Build.0 = Release|Any CPU {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x64.ActiveCfg = Debug|x64 - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x64.Build.0 = Debug|x64 - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x86.ActiveCfg = Debug|x86 - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x86.Build.0 = Debug|x86 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x64.ActiveCfg = Debug|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x64.Build.0 = Debug|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x86.ActiveCfg = Debug|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Debug|x86.Build.0 = Debug|Any CPU {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|Any CPU.ActiveCfg = Release|Any CPU {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|Any CPU.Build.0 = Release|Any CPU - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x64.ActiveCfg = Release|x64 - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x64.Build.0 = Release|x64 - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x86.ActiveCfg = Release|x86 - {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x86.Build.0 = Release|x86 + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x64.ActiveCfg = Release|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x64.Build.0 = Release|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x86.ActiveCfg = Release|Any CPU + {DDE34459-B244-43F9-8DE2-8D1E70CB6609}.Release|x86.Build.0 = Release|Any CPU {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x64.ActiveCfg = Debug|x64 - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x64.Build.0 = Debug|x64 - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x86.ActiveCfg = Debug|x86 - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x86.Build.0 = Debug|x86 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x64.ActiveCfg = Debug|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x64.Build.0 = Debug|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x86.ActiveCfg = Debug|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Debug|x86.Build.0 = Debug|Any CPU {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|Any CPU.ActiveCfg = Release|Any CPU {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|Any CPU.Build.0 = Release|Any CPU - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x64.ActiveCfg = Release|x64 - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x64.Build.0 = Release|x64 - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x86.ActiveCfg = Release|x86 - {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x86.Build.0 = Release|x86 + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x64.ActiveCfg = Release|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x64.Build.0 = Release|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x86.ActiveCfg = Release|Any CPU + {FA82E572-FC03-4C87-86FA-660AF06AA24A}.Release|x86.Build.0 = Release|Any CPU {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x64.ActiveCfg = Debug|x64 - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x64.Build.0 = Debug|x64 - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x86.ActiveCfg = Debug|x86 - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x86.Build.0 = Debug|x86 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x64.ActiveCfg = Debug|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x64.Build.0 = Debug|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Debug|x86.Build.0 = Debug|Any CPU {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|Any CPU.ActiveCfg = Release|Any CPU {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|Any CPU.Build.0 = Release|Any CPU - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x64.ActiveCfg = Release|x64 - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x64.Build.0 = Release|x64 - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x86.ActiveCfg = Release|x86 - {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x86.Build.0 = Release|x86 + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x64.ActiveCfg = Release|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x64.Build.0 = Release|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x86.ActiveCfg = Release|Any CPU + {1C0A4103-B8E6-4AE1-88DA-B3EBC37B2441}.Release|x86.Build.0 = Release|Any CPU {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x64.ActiveCfg = Debug|x64 - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x64.Build.0 = Debug|x64 - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x86.ActiveCfg = Debug|x86 - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x86.Build.0 = Debug|x86 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x64.ActiveCfg = Debug|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x64.Build.0 = Debug|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x86.ActiveCfg = Debug|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Debug|x86.Build.0 = Debug|Any CPU {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|Any CPU.ActiveCfg = Release|Any CPU {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|Any CPU.Build.0 = Release|Any CPU - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x64.ActiveCfg = Release|x64 - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x64.Build.0 = Release|x64 - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x86.ActiveCfg = Release|x86 - {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x86.Build.0 = Release|x86 + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x64.ActiveCfg = Release|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x64.Build.0 = Release|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x86.ActiveCfg = Release|Any CPU + {73D240B4-428D-4BC1-BC3C-C14D1D9D806E}.Release|x86.Build.0 = Release|Any CPU {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|Any CPU.Build.0 = Debug|Any CPU - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x64.ActiveCfg = Debug|x64 - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x64.Build.0 = Debug|x64 - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x86.ActiveCfg = Debug|x86 - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x86.Build.0 = Debug|x86 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x64.ActiveCfg = Debug|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x64.Build.0 = Debug|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x86.ActiveCfg = Debug|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Debug|x86.Build.0 = Debug|Any CPU {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|Any CPU.ActiveCfg = Release|Any CPU {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|Any CPU.Build.0 = Release|Any CPU - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x64.ActiveCfg = Release|x64 - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x64.Build.0 = Release|x64 - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.ActiveCfg = Release|x86 - {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.Build.0 = Release|x86 + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x64.ActiveCfg = Release|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x64.Build.0 = Release|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.ActiveCfg = Release|Any CPU + {928CD7B2-BB6E-4E07-834E-67B20CA6D698}.Release|x86.Build.0 = Release|Any CPU {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|Any CPU.Build.0 = Debug|Any CPU {95E7F42A-74B9-4071-9A3C-86EF95A0EB1B}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -212,5 +210,23 @@ Global {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|x64.Build.0 = Release|Any CPU {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|x86.ActiveCfg = Release|Any CPU {871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}.Release|x86.Build.0 = Release|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Debug|x64.ActiveCfg = Debug|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Debug|x64.Build.0 = Debug|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Debug|x86.ActiveCfg = Debug|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Debug|x86.Build.0 = Debug|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|Any CPU.Build.0 = Release|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x64.ActiveCfg = Release|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x64.Build.0 = Release|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.ActiveCfg = Release|Any CPU + {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A3449832-9F8D-413F-8336-8EBEEB77353B} EndGlobalSection EndGlobal diff --git a/FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs b/FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs new file mode 100644 index 0000000..53c9430 --- /dev/null +++ b/FactoryPattern/Abstract Factory/ChicagoIngredientsFactory.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; + +namespace FactoryPattern +{ + internal class ChicagoIngredientsFactory : IIngredientsFactory + { + ICheese IIngredientsFactory.CreateCheese() + { + return new Parmesan(); + } + + IClam IIngredientsFactory.CreateClam() + { + return new FreshClam(); + } + + IDough IIngredientsFactory.CreateDough() + { + return new DeepDish(); + } + + ISauce IIngredientsFactory.CreateSauce() + { + return new PlumTomato(); + } + + IEnumerable IIngredientsFactory.CreateVeggies() + { + var oni = new Onion(); + var ccm = new Cucumber(); + var ppr = new Pepper(); + IVeggies[] arr = { oni, ccm, ppr }; + return arr; + } + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/IIngredientsFactory.cs b/FactoryPattern/Abstract Factory/IIngredientsFactory.cs new file mode 100644 index 0000000..9010710 --- /dev/null +++ b/FactoryPattern/Abstract Factory/IIngredientsFactory.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace FactoryPattern +{ + interface IIngredientsFactory + { + IDough CreateDough(); + IEnumerable CreateVeggies(); + ISauce CreateSauce(); + ICheese CreateCheese(); + IClam CreateClam(); + } +} diff --git a/FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs b/FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs new file mode 100644 index 0000000..0b5be78 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/CherryTomato.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class CherryTomato : ISauce + { + public string Name => "Cherry Tomato"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs b/FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs new file mode 100644 index 0000000..39be3a1 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Cucumber.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class Cucumber : IVeggies + { + public string Name => "Cucumber"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs b/FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs new file mode 100644 index 0000000..3d6ef79 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/DeepDish.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class DeepDish : IDough + { + public string Name => "Deep Dish"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs b/FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs new file mode 100644 index 0000000..e2cf85a --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/FreshClam.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class FreshClam : IClam + { + public string Name => "Fresh Clam"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs b/FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs new file mode 100644 index 0000000..45bdcc9 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/FrozenClam.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class FrozenClam : IClam + { + public string Name => "Frozen Clam"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs new file mode 100644 index 0000000..5c9f2f7 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + public interface ICheese + { + string Name { get; } + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs new file mode 100644 index 0000000..5aaa65e --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + public interface IClam + { + string Name { get; } + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs new file mode 100644 index 0000000..9bb5b89 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + public interface IDough + { + string Name { get; } + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs new file mode 100644 index 0000000..647b073 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + public interface ISauce + { + string Name { get; } + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs new file mode 100644 index 0000000..d258bd8 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + public interface IVeggies + { + string Name { get; } + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs b/FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs new file mode 100644 index 0000000..30d780f --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Mozarella.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class Mozarella : ICheese + { + public string Name => "Mozarella"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Olive.cs b/FactoryPattern/Abstract Factory/Ingredients/Olive.cs new file mode 100644 index 0000000..f0b9d48 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Olive.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class Olive : IVeggies + { + public string Name => "Olives"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Onion.cs b/FactoryPattern/Abstract Factory/Ingredients/Onion.cs new file mode 100644 index 0000000..c752b3c --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Onion.cs @@ -0,0 +1,11 @@ +namespace FactoryPattern +{ + internal class Onion : IVeggies + { + public Onion() + { + } + + public string Name => "Onions"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs b/FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs new file mode 100644 index 0000000..05b95da --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Parmesan.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class Parmesan : ICheese + { + public string Name => "Parmesan"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/Pepper.cs b/FactoryPattern/Abstract Factory/Ingredients/Pepper.cs new file mode 100644 index 0000000..9f1a1e5 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/Pepper.cs @@ -0,0 +1,8 @@ +namespace FactoryPattern +{ + internal class Pepper : IVeggies + { + + public string Name => "Bell Peppers"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs b/FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs new file mode 100644 index 0000000..dfa40db --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/PlumTomato.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class PlumTomato : ISauce + { + public string Name => "Plum Tomato"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs b/FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs new file mode 100644 index 0000000..5fbe3e6 --- /dev/null +++ b/FactoryPattern/Abstract Factory/Ingredients/ThinCrust.cs @@ -0,0 +1,7 @@ +namespace FactoryPattern +{ + internal class ThinCrust : IDough + { + public string Name => "Thin Crust"; + } +} \ No newline at end of file diff --git a/FactoryPattern/Abstract Factory/NYIngredientsFactory.cs b/FactoryPattern/Abstract Factory/NYIngredientsFactory.cs new file mode 100644 index 0000000..dc0ea1c --- /dev/null +++ b/FactoryPattern/Abstract Factory/NYIngredientsFactory.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace FactoryPattern +{ + internal class NyIngredientsFactory : IIngredientsFactory + { + ICheese IIngredientsFactory.CreateCheese() + { + return new Mozarella(); + } + + IClam IIngredientsFactory.CreateClam() + { + return new FrozenClam(); + } + + IDough IIngredientsFactory.CreateDough() + { + return new ThinCrust(); + } + + ISauce IIngredientsFactory.CreateSauce() + { + return new CherryTomato(); + } + + IEnumerable IIngredientsFactory.CreateVeggies() + { + IVeggies[] arr = { new Onion(), new Pepper(), new Olive() }; + return arr; + } + } +} \ No newline at end of file diff --git a/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs b/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs new file mode 100644 index 0000000..63df3a3 --- /dev/null +++ b/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs @@ -0,0 +1,29 @@ +namespace FactoryPattern +{ + class ChicagoPizzaFactory : PizzaFactory + { + protected override Pizza Create(string type) + { + Pizza pizza; + IIngredientsFactory ingredients = new ChicagoIngredientsFactory(); + + if (type.Equals("Cheese")) + { + pizza = new CheesePizza(ingredients); + pizza.Name = "Chicago Cheese"; + } + else if (type.Equals("Clam")) + { + pizza = new ClamPizza(ingredients); + pizza.Name = "Chicago Clam"; + } + else + { + pizza = new VeggiePizza(ingredients); + pizza.Name = "Chicago Veggie"; + } + pizza.Color = "red"; + return pizza; + } + } +} diff --git a/FactoryPattern/Factory Method/NYPizzaFactory.cs b/FactoryPattern/Factory Method/NYPizzaFactory.cs new file mode 100644 index 0000000..d1a2776 --- /dev/null +++ b/FactoryPattern/Factory Method/NYPizzaFactory.cs @@ -0,0 +1,26 @@ +namespace FactoryPattern +{ + class NyPizzaFactory : PizzaFactory + { + protected override Pizza Create(string type) + { + Pizza pizza; + IIngredientsFactory ingredients = new NyIngredientsFactory(); + + if (type.Equals("Cheese")) + { + pizza = new CheesePizza(ingredients) {Name = "NY Style Cheese"}; + } + else if (type.Equals("Clam")) + { + pizza = new ClamPizza(ingredients) {Name = "NY Style Clam"}; + } + else + { + pizza = new VeggiePizza(ingredients) {Name = "NY Style Veggie"}; + } + pizza.Color = "blue"; + return pizza; + } + } +} diff --git a/FactoryPattern/Factory Method/PizzaFactory.cs b/FactoryPattern/Factory Method/PizzaFactory.cs new file mode 100644 index 0000000..31ead68 --- /dev/null +++ b/FactoryPattern/Factory Method/PizzaFactory.cs @@ -0,0 +1,17 @@ +namespace FactoryPattern +{ + abstract class PizzaFactory + { + public Pizza Order(string type) + { + var pizza = Create(type); + pizza.Prepare(); + pizza.Bake(); + pizza.Cut(); + pizza.Box(); + return pizza; + } + + protected abstract Pizza Create(string type); + } +} diff --git a/FactoryPattern/FactoryPattern.csproj b/FactoryPattern/FactoryPattern.csproj new file mode 100644 index 0000000..8ffe015 --- /dev/null +++ b/FactoryPattern/FactoryPattern.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.1 + + + + + + + diff --git a/FactoryPattern/Pizza/CheesePizza.cs b/FactoryPattern/Pizza/CheesePizza.cs new file mode 100644 index 0000000..60dac3c --- /dev/null +++ b/FactoryPattern/Pizza/CheesePizza.cs @@ -0,0 +1,25 @@ +using System; + +namespace FactoryPattern +{ + class CheesePizza : Pizza + { + readonly IIngredientsFactory _ingredients; + + public CheesePizza(IIngredientsFactory ing) + { + _ingredients = ing; + } + internal override void Prepare() + { + Console.WriteLine("Preparing " + Name + " Using"); + Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Cheese: " + _ingredients.CreateCheese().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Veggies: "); + Console.WriteLine(); + foreach (var val in _ingredients.CreateVeggies()) + { + Console.Write(val.Name + " "); + } + Console.WriteLine(); + } + } +} diff --git a/FactoryPattern/Pizza/ClamPizza.cs b/FactoryPattern/Pizza/ClamPizza.cs new file mode 100644 index 0000000..1879cf9 --- /dev/null +++ b/FactoryPattern/Pizza/ClamPizza.cs @@ -0,0 +1,22 @@ +using System; + +namespace FactoryPattern +{ + class ClamPizza : Pizza + { + readonly IIngredientsFactory _ingredients; + + public ClamPizza(IIngredientsFactory ing) + { + _ingredients = ing; + } + + internal override void Prepare() + { + Console.WriteLine("Preparing " + Name + " Using"); + Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Clam: " + _ingredients.CreateClam().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Cheese: " + _ingredients.CreateCheese().Name); + Console.WriteLine(); + + } + } +} diff --git a/FactoryPattern/Pizza/Pizza.cs b/FactoryPattern/Pizza/Pizza.cs new file mode 100644 index 0000000..e50ec8a --- /dev/null +++ b/FactoryPattern/Pizza/Pizza.cs @@ -0,0 +1,26 @@ +using System; + +namespace FactoryPattern +{ + abstract class Pizza + { + public string Color; + + internal abstract void Prepare(); + internal void Bake() + { + Console.WriteLine("Baking at 135 degree Celsius for 20 minutes"); + } + internal void Cut() + { + Console.WriteLine("Cutting into diagonal pieces"); + } + internal void Box() + { + Console.WriteLine("Putting pizza in " + Color + " coloured box"); + } + + public string Name { protected get; set; } + + } +} diff --git a/FactoryPattern/Pizza/VeggiePizza.cs b/FactoryPattern/Pizza/VeggiePizza.cs new file mode 100644 index 0000000..e0796e0 --- /dev/null +++ b/FactoryPattern/Pizza/VeggiePizza.cs @@ -0,0 +1,25 @@ +using System; + +namespace FactoryPattern +{ + class VeggiePizza : Pizza + { + readonly IIngredientsFactory _ingredients; + + public VeggiePizza(IIngredientsFactory ing) + { + _ingredients = ing; + } + internal override void Prepare() + { + Console.WriteLine("Preparing " + Name + " Using"); + Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Cheese: " + _ingredients.CreateCheese().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Veggies: "); + Console.WriteLine(); + foreach (var val in _ingredients.CreateVeggies()) + { + Console.Write(val.Name + " "); + } + Console.WriteLine(); + } + } +} diff --git a/FactoryPattern/Program.cs b/FactoryPattern/Program.cs new file mode 100644 index 0000000..d16bc6f --- /dev/null +++ b/FactoryPattern/Program.cs @@ -0,0 +1,18 @@ +using System; + +namespace FactoryPattern +{ + static class Program + { + static void Main() + { + Console.WriteLine("Yankees fan orders:"); + var yankees = new NyPizzaFactory(); + yankees.Order("Cheese"); + Console.WriteLine(); + Console.WriteLine("Cubs fan orders:"); + var cubs = new ChicagoPizzaFactory(); + cubs.Order("Clam"); + } + } +} \ No newline at end of file From 7cc61454452d7386b52d3dd75dfc03d36cf5c76b Mon Sep 17 00:00:00 2001 From: dim_ok00 Date: Sat, 4 May 2019 23:48:12 +0300 Subject: [PATCH 13/28] Add PrototypePattern --- DesignPatternsDotNetCore.sln | 16 +++++++++++++++- PrototypePattern/Circle.cs | 22 ++++++++++++++++++++++ PrototypePattern/IFigure.cs | 9 +++++++++ PrototypePattern/Program.cs | 22 ++++++++++++++++++++++ PrototypePattern/PrototypePattern.csproj | 8 ++++++++ PrototypePattern/Rectangle.cs | 24 ++++++++++++++++++++++++ 6 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 PrototypePattern/Circle.cs create mode 100644 PrototypePattern/IFigure.cs create mode 100644 PrototypePattern/Program.cs create mode 100644 PrototypePattern/PrototypePattern.csproj create mode 100644 PrototypePattern/Rectangle.cs diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 299d95a..5fa0760 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -30,7 +30,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlyweightPattern", "Flyweig EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisitorPattern", "VisitorPattern\VisitorPattern.csproj", "{871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{182B58DC-6787-4A09-8BCF-87A96737E5A6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{182B58DC-6787-4A09-8BCF-87A96737E5A6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrototypePattern", "PrototypePattern\PrototypePattern.csproj", "{2DC00E3D-2099-4C58-B98F-B6B3F285739F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -222,6 +224,18 @@ Global {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x64.Build.0 = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.ActiveCfg = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.Build.0 = Release|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|x64.ActiveCfg = Debug|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|x64.Build.0 = Debug|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|x86.ActiveCfg = Debug|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|x86.Build.0 = Debug|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|Any CPU.Build.0 = Release|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|x64.ActiveCfg = Release|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|x64.Build.0 = Release|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|x86.ActiveCfg = Release|Any CPU + {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrototypePattern/Circle.cs b/PrototypePattern/Circle.cs new file mode 100644 index 0000000..6289f77 --- /dev/null +++ b/PrototypePattern/Circle.cs @@ -0,0 +1,22 @@ +using System; + +namespace PrototypePattern +{ + class Circle : IFigure + { + readonly int _radius; + public Circle(int r) + { + _radius = r; + } + + public object Clone() + { + return new Circle(_radius); + } + public void GetInfo() + { + Console.WriteLine($"Circle with radius {_radius}"); + } + } +} \ No newline at end of file diff --git a/PrototypePattern/IFigure.cs b/PrototypePattern/IFigure.cs new file mode 100644 index 0000000..85879a4 --- /dev/null +++ b/PrototypePattern/IFigure.cs @@ -0,0 +1,9 @@ +using System; + +namespace PrototypePattern +{ + interface IFigure : ICloneable + { + void GetInfo(); + } +} \ No newline at end of file diff --git a/PrototypePattern/Program.cs b/PrototypePattern/Program.cs new file mode 100644 index 0000000..ebdecdb --- /dev/null +++ b/PrototypePattern/Program.cs @@ -0,0 +1,22 @@ +using System; + +namespace PrototypePattern +{ + class Program + { + static void Main(string[] args) + { + IFigure figure = new Rectangle(30, 40); + IFigure clonedFigure = (IFigure)figure.Clone(); + figure.GetInfo(); + clonedFigure.GetInfo(); + + figure = new Circle(30); + clonedFigure = (IFigure)figure.Clone(); + figure.GetInfo(); + clonedFigure.GetInfo(); + + Console.Read(); + } + } +} diff --git a/PrototypePattern/PrototypePattern.csproj b/PrototypePattern/PrototypePattern.csproj new file mode 100644 index 0000000..23df604 --- /dev/null +++ b/PrototypePattern/PrototypePattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/PrototypePattern/Rectangle.cs b/PrototypePattern/Rectangle.cs new file mode 100644 index 0000000..9856cf2 --- /dev/null +++ b/PrototypePattern/Rectangle.cs @@ -0,0 +1,24 @@ +using System; + +namespace PrototypePattern +{ + class Rectangle : IFigure + { + readonly int _width; + readonly int _height; + public Rectangle(int w, int h) + { + _width = w; + _height = h; + } + + public object Clone() + { + return new Rectangle(_width, _height); + } + public void GetInfo() + { + Console.WriteLine($"Rectangle height {_height} and width {_width}"); + } + } +} \ No newline at end of file From abd12be1387418660e1bda9e45bf7de446ba346b Mon Sep 17 00:00:00 2001 From: basbros Date: Mon, 20 May 2019 14:38:49 +0200 Subject: [PATCH 14/28] Add builder pattern (#14) * Add builder pattern * Revert VS2019 info from .sln file * Downgrade target framework to core 2.0 * Fix GUID of BuildPattern project type --- .../BuilderPattern/BuilderPattern.csproj | 8 +++ BuilderPattern/BuilderPattern/Hamburger.cs | 32 ++++++++++++ .../BuilderPattern/HamburgerBuilder.cs | 52 +++++++++++++++++++ BuilderPattern/BuilderPattern/Program.cs | 26 ++++++++++ DesignPatternsDotNetCore.sln | 16 +++++- 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 BuilderPattern/BuilderPattern/BuilderPattern.csproj create mode 100644 BuilderPattern/BuilderPattern/Hamburger.cs create mode 100644 BuilderPattern/BuilderPattern/HamburgerBuilder.cs create mode 100644 BuilderPattern/BuilderPattern/Program.cs diff --git a/BuilderPattern/BuilderPattern/BuilderPattern.csproj b/BuilderPattern/BuilderPattern/BuilderPattern.csproj new file mode 100644 index 0000000..ce1697a --- /dev/null +++ b/BuilderPattern/BuilderPattern/BuilderPattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.0 + + + diff --git a/BuilderPattern/BuilderPattern/Hamburger.cs b/BuilderPattern/BuilderPattern/Hamburger.cs new file mode 100644 index 0000000..7d3bcc1 --- /dev/null +++ b/BuilderPattern/BuilderPattern/Hamburger.cs @@ -0,0 +1,32 @@ +namespace BuilderPattern +{ + public class Hamburger + { + public bool HasBread { get; } + public bool HasMeal { get; } + public bool HasCheese { get; } + public bool HasTomato { get; } + public bool HasSalad { get; } + public bool HasMayonnaise { get; } + + internal Hamburger(bool hasBread, bool hasMeal, bool hasCheese, bool hasTomato, bool hasSalad, bool hasMayonnaise) + { + HasBread = hasBread; + HasMeal = hasMeal; + HasCheese = hasCheese; + HasTomato = hasTomato; + HasSalad = hasSalad; + HasMayonnaise = hasMayonnaise; + } + + public override string ToString() + { + return (HasBread ? "Bread " : string.Empty) + + (HasMeal ? "Meal " : string.Empty) + + (HasCheese ? "Cheese " : string.Empty) + + (HasTomato ? "Tomato " : string.Empty) + + (HasSalad ? "Salad " : string.Empty) + + (HasMayonnaise ? "Mayonnaise " : string.Empty); + } + } +} diff --git a/BuilderPattern/BuilderPattern/HamburgerBuilder.cs b/BuilderPattern/BuilderPattern/HamburgerBuilder.cs new file mode 100644 index 0000000..c144bc3 --- /dev/null +++ b/BuilderPattern/BuilderPattern/HamburgerBuilder.cs @@ -0,0 +1,52 @@ +namespace BuilderPattern +{ + public class HamburgerBuilder + { + private bool _hasBread; + private bool _hasMeal; + private bool _hasCheese; + private bool _hasTomato; + private bool _hasSalad; + private bool _hasMayonnaise; + + public HamburgerBuilder Builder => new HamburgerBuilder(); + + public HamburgerBuilder AddBread() + { + _hasBread = true; + return this; + } + + public HamburgerBuilder AddMeal() + { + _hasMeal = true; + return this; + } + + public HamburgerBuilder AddCheese() + { + _hasCheese = true; + return this; + } + + public HamburgerBuilder AddTomato() + { + _hasTomato = true; + return this; + } + + public HamburgerBuilder AddSalad() + { + _hasSalad = true; + return this; + } + + public HamburgerBuilder AddMayonnaise() + { + _hasMayonnaise = true; + return this; + } + + public Hamburger Build() => new Hamburger(_hasBread, _hasMeal, _hasCheese, _hasTomato, _hasSalad, _hasMayonnaise); + } +} diff --git a/BuilderPattern/BuilderPattern/Program.cs b/BuilderPattern/BuilderPattern/Program.cs new file mode 100644 index 0000000..c05ba81 --- /dev/null +++ b/BuilderPattern/BuilderPattern/Program.cs @@ -0,0 +1,26 @@ +using System; + +namespace BuilderPattern +{ + class Program + { + static void Main() + { + var myHamburger = new HamburgerBuilder() + .AddBread() + .AddMeal() + .AddCheese() + .AddTomato() + .AddSalad() + .AddMayonnaise() + .Build(); + Console.WriteLine($"My hamburger: {myHamburger}"); + + var myWifeHamburger = new HamburgerBuilder() + .AddBread() + .AddSalad() + .Build(); + Console.WriteLine($"My wife's hamburger: {myWifeHamburger}"); + } + } +} diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 299d95a..1816eb0 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -30,7 +30,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlyweightPattern", "Flyweig EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisitorPattern", "VisitorPattern\VisitorPattern.csproj", "{871F7BE0-B75F-4F9E-9C4D-CE9C4ECE7A88}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{182B58DC-6787-4A09-8BCF-87A96737E5A6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{182B58DC-6787-4A09-8BCF-87A96737E5A6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern\BuilderPattern.csproj", "{D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -222,6 +224,18 @@ Global {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x64.Build.0 = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.ActiveCfg = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.Build.0 = Release|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x64.ActiveCfg = Debug|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x64.Build.0 = Debug|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x86.ActiveCfg = Debug|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x86.Build.0 = Debug|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|Any CPU.Build.0 = Release|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x64.ActiveCfg = Release|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x64.Build.0 = Release|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x86.ActiveCfg = Release|Any CPU + {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 5914dbf0cc61afbac81fc3a911cdcd72b9b63b47 Mon Sep 17 00:00:00 2001 From: Ndubuisi Jr Chukuigwe <44238346+NdubuisiJr@users.noreply.github.com> Date: Thu, 17 Oct 2019 12:53:27 +0100 Subject: [PATCH 15/28] Implemented Builder Pattern with regards to issue #8 (#16) * Implemented Builder Pattern with regards to issure #8 * Changed folder structure for BuilderPattern * Added new folder structure to solution * Added Chain of Responsibility design pattern --- .../BuilderPattern.csproj | 0 BuilderPattern/BuilderPattern/Hamburger.cs | 32 ------------ .../BuilderPattern/HamburgerBuilder.cs | 52 ------------------- BuilderPattern/BuilderPattern/Program.cs | 26 ---------- BuilderPattern/Cook.cs | 26 ++++++++++ BuilderPattern/Hamburger.cs | 19 +++++++ BuilderPattern/IBuilder.cs | 9 ++++ BuilderPattern/MyHamburgerBuilder.cs | 25 +++++++++ BuilderPattern/Program.cs | 20 +++++++ BuilderPattern/WifesHamburgerBuilder.cs | 26 ++++++++++ .../AdditionHandler.cs | 20 +++++++ ChainOfResponsibilityPattern/BaseHandler.cs | 11 ++++ .../ChainOfResponsibilityPattern.csproj | 8 +++ ChainOfResponsibilityPattern/IHandler.cs | 6 +++ .../MultiplicationHandler.cs | 16 ++++++ ChainOfResponsibilityPattern/Program.cs | 26 ++++++++++ .../SubtractionHandler.cs | 16 ++++++ DesignPatternsDotNetCore.sln | 44 ++++++++++------ 18 files changed, 257 insertions(+), 125 deletions(-) rename BuilderPattern/{BuilderPattern => }/BuilderPattern.csproj (100%) delete mode 100644 BuilderPattern/BuilderPattern/Hamburger.cs delete mode 100644 BuilderPattern/BuilderPattern/HamburgerBuilder.cs delete mode 100644 BuilderPattern/BuilderPattern/Program.cs create mode 100644 BuilderPattern/Cook.cs create mode 100644 BuilderPattern/Hamburger.cs create mode 100644 BuilderPattern/IBuilder.cs create mode 100644 BuilderPattern/MyHamburgerBuilder.cs create mode 100644 BuilderPattern/Program.cs create mode 100644 BuilderPattern/WifesHamburgerBuilder.cs create mode 100644 ChainOfResponsibilityPattern/AdditionHandler.cs create mode 100644 ChainOfResponsibilityPattern/BaseHandler.cs create mode 100644 ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj create mode 100644 ChainOfResponsibilityPattern/IHandler.cs create mode 100644 ChainOfResponsibilityPattern/MultiplicationHandler.cs create mode 100644 ChainOfResponsibilityPattern/Program.cs create mode 100644 ChainOfResponsibilityPattern/SubtractionHandler.cs diff --git a/BuilderPattern/BuilderPattern/BuilderPattern.csproj b/BuilderPattern/BuilderPattern.csproj similarity index 100% rename from BuilderPattern/BuilderPattern/BuilderPattern.csproj rename to BuilderPattern/BuilderPattern.csproj diff --git a/BuilderPattern/BuilderPattern/Hamburger.cs b/BuilderPattern/BuilderPattern/Hamburger.cs deleted file mode 100644 index 7d3bcc1..0000000 --- a/BuilderPattern/BuilderPattern/Hamburger.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace BuilderPattern -{ - public class Hamburger - { - public bool HasBread { get; } - public bool HasMeal { get; } - public bool HasCheese { get; } - public bool HasTomato { get; } - public bool HasSalad { get; } - public bool HasMayonnaise { get; } - - internal Hamburger(bool hasBread, bool hasMeal, bool hasCheese, bool hasTomato, bool hasSalad, bool hasMayonnaise) - { - HasBread = hasBread; - HasMeal = hasMeal; - HasCheese = hasCheese; - HasTomato = hasTomato; - HasSalad = hasSalad; - HasMayonnaise = hasMayonnaise; - } - - public override string ToString() - { - return (HasBread ? "Bread " : string.Empty) - + (HasMeal ? "Meal " : string.Empty) - + (HasCheese ? "Cheese " : string.Empty) - + (HasTomato ? "Tomato " : string.Empty) - + (HasSalad ? "Salad " : string.Empty) - + (HasMayonnaise ? "Mayonnaise " : string.Empty); - } - } -} diff --git a/BuilderPattern/BuilderPattern/HamburgerBuilder.cs b/BuilderPattern/BuilderPattern/HamburgerBuilder.cs deleted file mode 100644 index c144bc3..0000000 --- a/BuilderPattern/BuilderPattern/HamburgerBuilder.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace BuilderPattern -{ - public class HamburgerBuilder - { - private bool _hasBread; - private bool _hasMeal; - private bool _hasCheese; - private bool _hasTomato; - private bool _hasSalad; - private bool _hasMayonnaise; - - public HamburgerBuilder Builder => new HamburgerBuilder(); - - public HamburgerBuilder AddBread() - { - _hasBread = true; - return this; - } - - public HamburgerBuilder AddMeal() - { - _hasMeal = true; - return this; - } - - public HamburgerBuilder AddCheese() - { - _hasCheese = true; - return this; - } - - public HamburgerBuilder AddTomato() - { - _hasTomato = true; - return this; - } - - public HamburgerBuilder AddSalad() - { - _hasSalad = true; - return this; - } - - public HamburgerBuilder AddMayonnaise() - { - _hasMayonnaise = true; - return this; - } - - public Hamburger Build() => new Hamburger(_hasBread, _hasMeal, _hasCheese, _hasTomato, _hasSalad, _hasMayonnaise); - } -} diff --git a/BuilderPattern/BuilderPattern/Program.cs b/BuilderPattern/BuilderPattern/Program.cs deleted file mode 100644 index c05ba81..0000000 --- a/BuilderPattern/BuilderPattern/Program.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace BuilderPattern -{ - class Program - { - static void Main() - { - var myHamburger = new HamburgerBuilder() - .AddBread() - .AddMeal() - .AddCheese() - .AddTomato() - .AddSalad() - .AddMayonnaise() - .Build(); - Console.WriteLine($"My hamburger: {myHamburger}"); - - var myWifeHamburger = new HamburgerBuilder() - .AddBread() - .AddSalad() - .Build(); - Console.WriteLine($"My wife's hamburger: {myWifeHamburger}"); - } - } -} diff --git a/BuilderPattern/Cook.cs b/BuilderPattern/Cook.cs new file mode 100644 index 0000000..dd40620 --- /dev/null +++ b/BuilderPattern/Cook.cs @@ -0,0 +1,26 @@ +namespace BuilderPattern { + + // This class can also be called the Director + public class Cook { + private IBuilder _builder; + public Cook(IBuilder builder) { + AcceptBuilder(builder); + } + + public void ChangeBuilder(IBuilder builder) { + AcceptBuilder(builder); + } + + public Hamburger Build() { + _builder.AddIngredients(); + _builder.AddShape(); + _builder.AddSize(); + return _builder.Build(); + } + + private void AcceptBuilder(IBuilder builder) { + _builder = builder; + _builder.Reset(); + } + } +} diff --git a/BuilderPattern/Hamburger.cs b/BuilderPattern/Hamburger.cs new file mode 100644 index 0000000..604f138 --- /dev/null +++ b/BuilderPattern/Hamburger.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace BuilderPattern +{ + public class Hamburger + { + public int Size { get; set; } + public string Shape { get; set; } + public string[] Ingredients { get; set; } + public override string ToString() + { + var hamburger=""; + foreach (var ingredient in Ingredients) { + hamburger += $"{ingredient} "; + } + return $"Ingredients: {hamburger}, Size: {Size}, Shape: {Shape}"; + } + } +} diff --git a/BuilderPattern/IBuilder.cs b/BuilderPattern/IBuilder.cs new file mode 100644 index 0000000..34d96a2 --- /dev/null +++ b/BuilderPattern/IBuilder.cs @@ -0,0 +1,9 @@ +namespace BuilderPattern { + public interface IBuilder { + void AddIngredients(); + void AddShape(); + void AddSize(); + void Reset(); + Hamburger Build(); + } +} diff --git a/BuilderPattern/MyHamburgerBuilder.cs b/BuilderPattern/MyHamburgerBuilder.cs new file mode 100644 index 0000000..61782f7 --- /dev/null +++ b/BuilderPattern/MyHamburgerBuilder.cs @@ -0,0 +1,25 @@ +namespace BuilderPattern +{ + public class MyHamburgerBuilder : IBuilder { + private Hamburger _hamburger; + public void AddIngredients() { + _hamburger.Ingredients = new string[] { "Bread", "Meat", "Tomato", "Salad", "Mayonnaise" }; + } + + public void AddShape() { + _hamburger.Shape = "Kite"; + } + + public void AddSize() { + _hamburger.Size = 10; //inches + } + public void Reset() { + _hamburger = new Hamburger(); + } + + public Hamburger Build() { + return _hamburger; + } + + } +} diff --git a/BuilderPattern/Program.cs b/BuilderPattern/Program.cs new file mode 100644 index 0000000..dc14219 --- /dev/null +++ b/BuilderPattern/Program.cs @@ -0,0 +1,20 @@ +using System; + +namespace BuilderPattern +{ + class Program + { + static void Main() + { + var builder = new MyHamburgerBuilder(); + var cook = new Cook(builder); + var myHamburger = cook.Build(); + + cook.ChangeBuilder(new WifesHamburgerBuilder()); + var wifesHamburger = cook.Build(); + + Console.WriteLine($"My Hamburger: {myHamburger}"); + Console.WriteLine($"My Wife's Hamburger: {wifesHamburger}"); + } + } +} diff --git a/BuilderPattern/WifesHamburgerBuilder.cs b/BuilderPattern/WifesHamburgerBuilder.cs new file mode 100644 index 0000000..9724fc6 --- /dev/null +++ b/BuilderPattern/WifesHamburgerBuilder.cs @@ -0,0 +1,26 @@ +using System; + +namespace BuilderPattern { + + public class WifesHamburgerBuilder : IBuilder { + private Hamburger _hamburger; + public void AddIngredients() { + _hamburger.Ingredients = new string[] { "Bread", "Salad" }; + } + + public void AddShape() { + _hamburger.Shape = "Cuboid"; + } + + public void AddSize() { + _hamburger.Size = 6; //inches + } + + public void Reset() { + _hamburger = new Hamburger(); + } + public Hamburger Build() { + return _hamburger; + } + } +} diff --git a/ChainOfResponsibilityPattern/AdditionHandler.cs b/ChainOfResponsibilityPattern/AdditionHandler.cs new file mode 100644 index 0000000..27f7bbe --- /dev/null +++ b/ChainOfResponsibilityPattern/AdditionHandler.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ChainOfResponsibilityPattern { + public class AdditionHandler : BaseHandler { + public override double? Handle(double[] values, string action) { + if (action.ToLower() == "add") { + double result=0.0; + foreach (var value in values) { + result += value; + } + return result; + } + else { + return _nextInLine?.Handle(values,action); + } + } + } +} diff --git a/ChainOfResponsibilityPattern/BaseHandler.cs b/ChainOfResponsibilityPattern/BaseHandler.cs new file mode 100644 index 0000000..b24a593 --- /dev/null +++ b/ChainOfResponsibilityPattern/BaseHandler.cs @@ -0,0 +1,11 @@ +namespace ChainOfResponsibilityPattern { + public abstract class BaseHandler : IHandler { + public void AddChain(IHandler handler) { + _nextInLine = handler; + } + + public abstract double? Handle(double[] values, string action); + + protected IHandler _nextInLine; + } +} diff --git a/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj b/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj new file mode 100644 index 0000000..23df604 --- /dev/null +++ b/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/ChainOfResponsibilityPattern/IHandler.cs b/ChainOfResponsibilityPattern/IHandler.cs new file mode 100644 index 0000000..f263adb --- /dev/null +++ b/ChainOfResponsibilityPattern/IHandler.cs @@ -0,0 +1,6 @@ +namespace ChainOfResponsibilityPattern { + public interface IHandler { + void AddChain(IHandler handler); + double? Handle(double[] values, string action); + } +} diff --git a/ChainOfResponsibilityPattern/MultiplicationHandler.cs b/ChainOfResponsibilityPattern/MultiplicationHandler.cs new file mode 100644 index 0000000..cf99553 --- /dev/null +++ b/ChainOfResponsibilityPattern/MultiplicationHandler.cs @@ -0,0 +1,16 @@ +namespace ChainOfResponsibilityPattern { + public class MultiplicationHandler : BaseHandler { + public override double? Handle(double[] values, string action) { + if (action.ToLower() == "multiply") { + var result = 1.0; + foreach (var value in values) { + result *= value; + } + return result; + } + else { + return _nextInLine?.Handle(values, action); + } + } + } +} diff --git a/ChainOfResponsibilityPattern/Program.cs b/ChainOfResponsibilityPattern/Program.cs new file mode 100644 index 0000000..2ea5d2d --- /dev/null +++ b/ChainOfResponsibilityPattern/Program.cs @@ -0,0 +1,26 @@ +using System; + +namespace ChainOfResponsibilityPattern { + class Program { + static void Main(string[] args) { + //create handlers + var additionHandler = new AdditionHandler(); + var subtractionHandler = new SubtractionHandler(); + var multiplicationHander = new MultiplicationHandler(); + //create chain + subtractionHandler.AddChain(multiplicationHander); + additionHandler.AddChain(subtractionHandler); + //Execution + double[] numbers = new double[] { 2, 3, 4, 5 }; + var additionResult = additionHandler.Handle(numbers, "Add"); + var subtractionResult = additionHandler.Handle(numbers, "Minus"); + var multResult = additionHandler.Handle(numbers, "Multiply"); + var divisionResult = additionHandler.Handle(numbers, "divide"); // Divide is not in the chain!!! + + Console.WriteLine("Addition = {0}",additionResult); + Console.WriteLine("Subtraction = {0}", subtractionResult); + Console.WriteLine("Multiplication = {0}", multResult); + Console.WriteLine("Division = {0}", divisionResult); + } + } +} diff --git a/ChainOfResponsibilityPattern/SubtractionHandler.cs b/ChainOfResponsibilityPattern/SubtractionHandler.cs new file mode 100644 index 0000000..7a5e5dd --- /dev/null +++ b/ChainOfResponsibilityPattern/SubtractionHandler.cs @@ -0,0 +1,16 @@ +namespace ChainOfResponsibilityPattern { + public class SubtractionHandler : BaseHandler { + public override double? Handle(double[] values, string action) { + if (action.ToLower() == "minus") { + var result = values[0]; + for (int i = 1; i < values.Length; i++) { + result -= values[i]; + } + return result; + } + else { + return _nextInLine?.Handle(values, action); + } + } + } +} diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 1816eb0..3188dab 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29025.244 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{79553F75-E8DC-4988-B511-A79CC6A9CDF7}" EndProject @@ -32,7 +32,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisitorPattern", "VisitorPa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{182B58DC-6787-4A09-8BCF-87A96737E5A6}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern\BuilderPattern.csproj", "{D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern.csproj", "{9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainOfResponsibilityPattern", "ChainOfResponsibilityPattern\ChainOfResponsibilityPattern.csproj", "{B703B66A-310A-45BC-94C9-EEEB57570E16}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -224,18 +226,30 @@ Global {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x64.Build.0 = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.ActiveCfg = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.Build.0 = Release|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x64.ActiveCfg = Debug|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x64.Build.0 = Debug|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x86.ActiveCfg = Debug|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Debug|x86.Build.0 = Debug|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|Any CPU.Build.0 = Release|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x64.ActiveCfg = Release|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x64.Build.0 = Release|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x86.ActiveCfg = Release|Any CPU - {D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}.Release|x86.Build.0 = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x64.ActiveCfg = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x64.Build.0 = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x86.ActiveCfg = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x86.Build.0 = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|Any CPU.Build.0 = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x64.ActiveCfg = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x64.Build.0 = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x86.ActiveCfg = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x86.Build.0 = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x64.ActiveCfg = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x64.Build.0 = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x86.ActiveCfg = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x86.Build.0 = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|Any CPU.Build.0 = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x64.ActiveCfg = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x64.Build.0 = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x86.ActiveCfg = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From b022771886d1d838501549e1e0a1a180d5e01763 Mon Sep 17 00:00:00 2001 From: Oleg Date: Sat, 2 May 2020 21:05:54 +0300 Subject: [PATCH 16/28] mediatorPatternAdded (#17) Co-authored-by: o.musin Co-authored-by: Abishek Aditya --- DesignPatternsDotNetCore.sln | 38 ++++++++++++++++++++++++++ MediatorPattern/Colleague.cs | 14 ++++++++++ MediatorPattern/Customer.cs | 14 ++++++++++ MediatorPattern/ManagerMediator.cs | 22 +++++++++++++++ MediatorPattern/Mediator.cs | 7 +++++ MediatorPattern/MediatorPattern.csproj | 8 ++++++ MediatorPattern/Program.cs | 21 ++++++++++++++ MediatorPattern/Programmer.cs | 14 ++++++++++ MediatorPattern/Tester.cs | 14 ++++++++++ README.md | 1 + 10 files changed, 153 insertions(+) create mode 100644 MediatorPattern/Colleague.cs create mode 100644 MediatorPattern/Customer.cs create mode 100644 MediatorPattern/ManagerMediator.cs create mode 100644 MediatorPattern/Mediator.cs create mode 100644 MediatorPattern/MediatorPattern.csproj create mode 100644 MediatorPattern/Program.cs create mode 100644 MediatorPattern/Programmer.cs create mode 100644 MediatorPattern/Tester.cs diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 4cef771..76cc66d 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -36,6 +36,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrototypePattern", "Prototy EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern\BuilderPattern.csproj", "{D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediatorPattern", "MediatorPattern\MediatorPattern.csproj", "{82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -226,6 +228,42 @@ Global {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x64.Build.0 = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.ActiveCfg = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.Build.0 = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x64.ActiveCfg = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x64.Build.0 = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x86.ActiveCfg = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x86.Build.0 = Debug|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|Any CPU.Build.0 = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x64.ActiveCfg = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x64.Build.0 = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x86.ActiveCfg = Release|Any CPU + {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x86.Build.0 = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x64.ActiveCfg = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x64.Build.0 = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x86.ActiveCfg = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x86.Build.0 = Debug|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|Any CPU.Build.0 = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x64.ActiveCfg = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x64.Build.0 = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x86.ActiveCfg = Release|Any CPU + {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x86.Build.0 = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x64.ActiveCfg = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x64.Build.0 = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x86.ActiveCfg = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x86.Build.0 = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|Any CPU.Build.0 = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x64.ActiveCfg = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x64.Build.0 = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x86.ActiveCfg = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x86.Build.0 = Release|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/MediatorPattern/Colleague.cs b/MediatorPattern/Colleague.cs new file mode 100644 index 0000000..78c694a --- /dev/null +++ b/MediatorPattern/Colleague.cs @@ -0,0 +1,14 @@ +namespace MediatorPattern +{ + abstract class Colleague + { + protected Mediator mediator; + + public Colleague(Mediator mediator) => this.mediator = mediator; + + public virtual void Send(string message) => this.mediator.Send(message, this); + + public abstract void Notify(string message); + + } +} \ No newline at end of file diff --git a/MediatorPattern/Customer.cs b/MediatorPattern/Customer.cs new file mode 100644 index 0000000..774863c --- /dev/null +++ b/MediatorPattern/Customer.cs @@ -0,0 +1,14 @@ +using System; + +namespace MediatorPattern +{ + class Customer : Colleague + { + public Customer(Mediator mediator) : base(mediator) {} + + public override void Notify(string message) + { + Console.WriteLine($"Message to customer: {message}"); + } + } +} \ No newline at end of file diff --git a/MediatorPattern/ManagerMediator.cs b/MediatorPattern/ManagerMediator.cs new file mode 100644 index 0000000..ceda018 --- /dev/null +++ b/MediatorPattern/ManagerMediator.cs @@ -0,0 +1,22 @@ +namespace MediatorPattern +{ + class ManagerMediator : Mediator + { + public Colleague Customer { get; set; } + public Colleague Programmer { get; set; } + public Colleague Tester { get; set; } + + public override void Send(string message, Colleague colleague) + { + if (colleague == Customer) + { + Programmer.Notify(message); + } + else if (colleague == Programmer) + { + Tester.Notify(message); + } + else Customer.Notify(message); + } + } +} \ No newline at end of file diff --git a/MediatorPattern/Mediator.cs b/MediatorPattern/Mediator.cs new file mode 100644 index 0000000..2646a13 --- /dev/null +++ b/MediatorPattern/Mediator.cs @@ -0,0 +1,7 @@ +namespace MediatorPattern +{ + abstract class Mediator + { + public abstract void Send(string message, Colleague colleague); + } +} \ No newline at end of file diff --git a/MediatorPattern/MediatorPattern.csproj b/MediatorPattern/MediatorPattern.csproj new file mode 100644 index 0000000..51b7f6c --- /dev/null +++ b/MediatorPattern/MediatorPattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/MediatorPattern/Program.cs b/MediatorPattern/Program.cs new file mode 100644 index 0000000..9276771 --- /dev/null +++ b/MediatorPattern/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace MediatorPattern +{ + class Program + { + static void Main(string[] args) + { + var mediator = new ManagerMediator(); + var customer = new Customer(mediator); + var programmer = new Programmer(mediator); + var tester = new Tester(mediator); + mediator.Customer = customer; + mediator.Programmer = programmer; + mediator.Tester = tester; + customer.Send("We have an order, need to make a program"); + programmer.Send("I have done program, need to test it"); + tester.Send("I have done testing, here is ready program for you"); + } + } +} \ No newline at end of file diff --git a/MediatorPattern/Programmer.cs b/MediatorPattern/Programmer.cs new file mode 100644 index 0000000..275214e --- /dev/null +++ b/MediatorPattern/Programmer.cs @@ -0,0 +1,14 @@ +using System; + +namespace MediatorPattern +{ + class Programmer : Colleague + { + public Programmer(Mediator mediator) : base(mediator) {} + + public override void Notify(string message) + { + Console.WriteLine($"Message to programmer: {message}"); + } + } +} \ No newline at end of file diff --git a/MediatorPattern/Tester.cs b/MediatorPattern/Tester.cs new file mode 100644 index 0000000..e218496 --- /dev/null +++ b/MediatorPattern/Tester.cs @@ -0,0 +1,14 @@ +using System; + +namespace MediatorPattern +{ + class Tester : Colleague + { + public Tester(Mediator mediator) : base(mediator) {} + + public override void Notify(string message) + { + Console.WriteLine($"Message to tester: {message}"); + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index 5f08678..8cdcb6f 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,4 @@ There are three kinds of Design Patterns * [Strategy](/StrategyPattern) * [Template](/TemplatePattern) * [Visitor](/VisitorPattern) +* [Mediator](/MediatorPattern) From fce4a2a310874aeb18de86f0149faca550087d51 Mon Sep 17 00:00:00 2001 From: Abishek Aditya Date: Sat, 2 May 2020 23:46:47 +0530 Subject: [PATCH 17/28] Fix builder pattern folder path --- DesignPatternsDotNetCore.sln | 70 +++++++++++++++--------------------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 76cc66d..68fbfab 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29920.165 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{79553F75-E8DC-4988-B511-A79CC6A9CDF7}" EndProject @@ -32,11 +32,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisitorPattern", "VisitorPa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{182B58DC-6787-4A09-8BCF-87A96737E5A6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrototypePattern", "PrototypePattern\PrototypePattern.csproj", "{2DC00E3D-2099-4C58-B98F-B6B3F285739F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrototypePattern", "PrototypePattern\PrototypePattern.csproj", "{2DC00E3D-2099-4C58-B98F-B6B3F285739F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern\BuilderPattern.csproj", "{D8B3C6D1-4AAD-4ED4-BFAE-582A1B43389C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatorPattern", "MediatorPattern\MediatorPattern.csproj", "{82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediatorPattern", "MediatorPattern\MediatorPattern.csproj", "{82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern.csproj", "{274786D8-2E30-40D7-81B5-DFA3872CF9B6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -228,42 +228,6 @@ Global {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x64.Build.0 = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.ActiveCfg = Release|Any CPU {182B58DC-6787-4A09-8BCF-87A96737E5A6}.Release|x86.Build.0 = Release|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x64.ActiveCfg = Debug|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x64.Build.0 = Debug|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x86.ActiveCfg = Debug|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Debug|x86.Build.0 = Debug|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|Any CPU.Build.0 = Release|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x64.ActiveCfg = Release|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x64.Build.0 = Release|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x86.ActiveCfg = Release|Any CPU - {9C400147-84CB-40B2-8E82-6C9A4A1DF4E9}.Release|x86.Build.0 = Release|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x64.ActiveCfg = Debug|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x64.Build.0 = Debug|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x86.ActiveCfg = Debug|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Debug|x86.Build.0 = Debug|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|Any CPU.Build.0 = Release|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x64.ActiveCfg = Release|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x64.Build.0 = Release|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x86.ActiveCfg = Release|Any CPU - {B703B66A-310A-45BC-94C9-EEEB57570E16}.Release|x86.Build.0 = Release|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x64.ActiveCfg = Debug|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x64.Build.0 = Debug|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x86.ActiveCfg = Debug|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x86.Build.0 = Debug|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|Any CPU.Build.0 = Release|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x64.ActiveCfg = Release|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x64.Build.0 = Release|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x86.ActiveCfg = Release|Any CPU - {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x86.Build.0 = Release|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -276,6 +240,30 @@ Global {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|x64.Build.0 = Release|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|x86.ActiveCfg = Release|Any CPU {2DC00E3D-2099-4C58-B98F-B6B3F285739F}.Release|x86.Build.0 = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x64.ActiveCfg = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x64.Build.0 = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x86.ActiveCfg = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Debug|x86.Build.0 = Debug|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|Any CPU.Build.0 = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x64.ActiveCfg = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x64.Build.0 = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x86.ActiveCfg = Release|Any CPU + {82A66FF6-5D66-4E39-8FF8-C8EBA0EB3A2D}.Release|x86.Build.0 = Release|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Debug|x64.ActiveCfg = Debug|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Debug|x64.Build.0 = Debug|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Debug|x86.ActiveCfg = Debug|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Debug|x86.Build.0 = Debug|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|Any CPU.Build.0 = Release|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|x64.ActiveCfg = Release|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|x64.Build.0 = Release|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|x86.ActiveCfg = Release|Any CPU + {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 64075c9041f19bb32ce5d0a5aee83d443face21d Mon Sep 17 00:00:00 2001 From: YaraYasser Date: Sat, 9 Jan 2021 15:37:26 +0200 Subject: [PATCH 18/28] adding Proxy Pattern which is structural design pattern (#19) --- DesignPatternsDotNetCore.sln | 14 ++++++++ FlyweightPattern/ProxyPattern/Dimmer.cs | 18 ++++++++++ FlyweightPattern/ProxyPattern/Dvd.cs | 11 ++++++ FlyweightPattern/ProxyPattern/DvdPlayer.cs | 30 ++++++++++++++++ .../ProxyPattern/HometheaterFacade.cs | 36 +++++++++++++++++++ FlyweightPattern/ProxyPattern/Program.cs | 23 ++++++++++++ .../ProxyPattern/ProxyPattern.csproj | 8 +++++ ProxyPattern/Image.cs | 8 +++++ ProxyPattern/Program.cs | 19 ++++++++++ ProxyPattern/ProxyImage.cs | 23 ++++++++++++ ProxyPattern/ProxyPattern.csproj | 8 +++++ ProxyPattern/RealImage.cs | 27 ++++++++++++++ README.md | 1 + 13 files changed, 226 insertions(+) create mode 100644 FlyweightPattern/ProxyPattern/Dimmer.cs create mode 100644 FlyweightPattern/ProxyPattern/Dvd.cs create mode 100644 FlyweightPattern/ProxyPattern/DvdPlayer.cs create mode 100644 FlyweightPattern/ProxyPattern/HometheaterFacade.cs create mode 100644 FlyweightPattern/ProxyPattern/Program.cs create mode 100644 FlyweightPattern/ProxyPattern/ProxyPattern.csproj create mode 100644 ProxyPattern/Image.cs create mode 100644 ProxyPattern/Program.cs create mode 100644 ProxyPattern/ProxyImage.cs create mode 100644 ProxyPattern/ProxyPattern.csproj create mode 100644 ProxyPattern/RealImage.cs diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 68fbfab..5f9a763 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -38,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatorPattern", "Mediator EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern.csproj", "{274786D8-2E30-40D7-81B5-DFA3872CF9B6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyPattern", "ProxyPattern\ProxyPattern.csproj", "{0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -264,6 +266,18 @@ Global {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|x64.Build.0 = Release|Any CPU {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|x86.ActiveCfg = Release|Any CPU {274786D8-2E30-40D7-81B5-DFA3872CF9B6}.Release|x86.Build.0 = Release|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Debug|x64.ActiveCfg = Debug|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Debug|x64.Build.0 = Debug|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Debug|x86.ActiveCfg = Debug|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Debug|x86.Build.0 = Debug|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|Any CPU.Build.0 = Release|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|x64.ActiveCfg = Release|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|x64.Build.0 = Release|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|x86.ActiveCfg = Release|Any CPU + {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FlyweightPattern/ProxyPattern/Dimmer.cs b/FlyweightPattern/ProxyPattern/Dimmer.cs new file mode 100644 index 0000000..d9cfef3 --- /dev/null +++ b/FlyweightPattern/ProxyPattern/Dimmer.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FacadePattern +{ + public class Dimmer + { + internal void Dim(int val) + { + Console.WriteLine(val == 10 ? "Turning Lights On" : $"Dimming lights to {val}"); + } + + internal void Off() => Console.WriteLine("Switching off lights"); + } +} diff --git a/FlyweightPattern/ProxyPattern/Dvd.cs b/FlyweightPattern/ProxyPattern/Dvd.cs new file mode 100644 index 0000000..b247c62 --- /dev/null +++ b/FlyweightPattern/ProxyPattern/Dvd.cs @@ -0,0 +1,11 @@ +namespace FacadePattern +{ + public class Dvd + { + public Dvd(string name) + { + Movie = name; + } + public string Movie { get; set; } + } +} \ No newline at end of file diff --git a/FlyweightPattern/ProxyPattern/DvdPlayer.cs b/FlyweightPattern/ProxyPattern/DvdPlayer.cs new file mode 100644 index 0000000..ffaa58c --- /dev/null +++ b/FlyweightPattern/ProxyPattern/DvdPlayer.cs @@ -0,0 +1,30 @@ +using System; + +namespace FacadePattern +{ + public class DvdPlayer + { + private Dvd _dvd; + private int _time = 0; + public void On() => Console.WriteLine("DVD Player powered on"); + + public void Insert(Dvd dvd) + { + _dvd = dvd; + Console.WriteLine($"Inserting {dvd.Movie}"); + + } + + public void Play() => Console.WriteLine($"Playing {_dvd.Movie}"); + + public void Pause() + { + Console.WriteLine($"Pausing at {_time = (new Random()).Next(_time,_time + 120)}"); + } + + public void Resume() + { + Console.WriteLine($"Resuming from {_time}"); + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/ProxyPattern/HometheaterFacade.cs b/FlyweightPattern/ProxyPattern/HometheaterFacade.cs new file mode 100644 index 0000000..2d09049 --- /dev/null +++ b/FlyweightPattern/ProxyPattern/HometheaterFacade.cs @@ -0,0 +1,36 @@ +namespace FacadePattern +{ + public class HomeTheatreFacade + { + private Dimmer _dimmer; + private Dvd _dvd; + private DvdPlayer _dvdPlayer; + + public HomeTheatreFacade(Dimmer dimmer,Dvd dvd, DvdPlayer dvdPlayer) + { + _dvd = dvd; + _dimmer = dimmer; + _dvdPlayer = dvdPlayer; + } + + public void WatchMovie() + { + _dimmer.Dim(5); + _dvdPlayer.On(); + _dvdPlayer.Insert(_dvd); + _dvdPlayer.Play(); + } + + public void Pause() + { + _dimmer.Dim(10); + _dvdPlayer.Pause(); + } + + public void Resume() + { + _dimmer.Dim(5); + _dvdPlayer.Resume(); + } + } +} \ No newline at end of file diff --git a/FlyweightPattern/ProxyPattern/Program.cs b/FlyweightPattern/ProxyPattern/Program.cs new file mode 100644 index 0000000..a695029 --- /dev/null +++ b/FlyweightPattern/ProxyPattern/Program.cs @@ -0,0 +1,23 @@ +using System; + +namespace FacadePattern +{ + internal static class Program + { + private static void Main() + { + var dimmer = new Dimmer(); + var dvdPlayer = new DvdPlayer(); + var dvd = new Dvd("Gone with the Wind 2 : Electric Bugaloo"); + var homeTheater = new HomeTheatreFacade(dimmer,dvd,dvdPlayer); + + homeTheater.WatchMovie(); + Console.WriteLine(); + homeTheater.Pause(); + Console.WriteLine(); + homeTheater.Resume(); + Console.WriteLine(); + homeTheater.Pause(); + } + } +} diff --git a/FlyweightPattern/ProxyPattern/ProxyPattern.csproj b/FlyweightPattern/ProxyPattern/ProxyPattern.csproj new file mode 100644 index 0000000..ce1697a --- /dev/null +++ b/FlyweightPattern/ProxyPattern/ProxyPattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.0 + + + diff --git a/ProxyPattern/Image.cs b/ProxyPattern/Image.cs new file mode 100644 index 0000000..9c1d7b0 --- /dev/null +++ b/ProxyPattern/Image.cs @@ -0,0 +1,8 @@ +namespace ProxyPattern +{ + public interface Image + { + void display(); + + } +} diff --git a/ProxyPattern/Program.cs b/ProxyPattern/Program.cs new file mode 100644 index 0000000..b0cedf6 --- /dev/null +++ b/ProxyPattern/Program.cs @@ -0,0 +1,19 @@ +using System; + +namespace ProxyPattern +{ + class Program + { + static void Main(string[] args) + { + Image image = new ProxyImage("testImage.jpg"); + + //image will be loaded from disk + image.display(); + Console.WriteLine(""); + + //image will not be loaded from disk + image.display(); + } + } +} diff --git a/ProxyPattern/ProxyImage.cs b/ProxyPattern/ProxyImage.cs new file mode 100644 index 0000000..bdab6de --- /dev/null +++ b/ProxyPattern/ProxyImage.cs @@ -0,0 +1,23 @@ +namespace ProxyPattern +{ + public class ProxyImage : Image + { + private RealImage _realImage; + private string _fileName; + + public ProxyImage(string fileName) + { + _fileName = fileName; + } + + + public void display() + { + if (_realImage == null) + { + _realImage = new RealImage(_fileName); + } + _realImage.display(); + } + } +} \ No newline at end of file diff --git a/ProxyPattern/ProxyPattern.csproj b/ProxyPattern/ProxyPattern.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/ProxyPattern/ProxyPattern.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/ProxyPattern/RealImage.cs b/ProxyPattern/RealImage.cs new file mode 100644 index 0000000..0405fad --- /dev/null +++ b/ProxyPattern/RealImage.cs @@ -0,0 +1,27 @@ +using System; + +namespace ProxyPattern +{ + + public class RealImage : Image + { + + private string _fileName; + + public RealImage(string fileName) + { + _fileName = fileName; + loadFromDisk(_fileName); + } + + public void display() + { + Console.WriteLine("Displaying " + _fileName); + } + + private void loadFromDisk(string fileName) + { + Console.WriteLine("Loading " + fileName); + } +} +} \ No newline at end of file diff --git a/README.md b/README.md index 8cdcb6f..238a5db 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,4 @@ There are three kinds of Design Patterns * [Template](/TemplatePattern) * [Visitor](/VisitorPattern) * [Mediator](/MediatorPattern) +* [Proxy] (/ProxyPattern) \ No newline at end of file From 174ab9f4e82657205d4b3add3232316355097ade Mon Sep 17 00:00:00 2001 From: Hamed Moghadasi Date: Sat, 6 Mar 2021 07:22:32 +0330 Subject: [PATCH 19/28] Code Cleanup ! (#21) --- AdapterPattern/MallardDuck.cs | 4 --- AdapterPattern/Program.cs | 3 +-- AdapterPattern/TurkeyAdapter.cs | 2 -- AdapterPattern/WildTurkey.cs | 4 --- BridgePattern/FlyingEnchantment.cs | 2 +- BridgePattern/Hammer.cs | 2 +- BridgePattern/Program.cs | 2 +- BridgePattern/SoulEatingEnchantment.cs | 2 +- BridgePattern/Sword.cs | 2 +- BuilderPattern/Cook.cs | 18 ++++++++----- BuilderPattern/Hamburger.cs | 8 +++--- BuilderPattern/IBuilder.cs | 6 +++-- BuilderPattern/MyHamburgerBuilder.cs | 18 ++++++++----- BuilderPattern/WifesHamburgerBuilder.cs | 23 +++++++++------- CommandPattern/Program.cs | 6 ++--- CompositePattern/Menu.cs | 2 +- CompositePattern/MenuComponent.cs | 2 +- CompositePattern/MenuItem.cs | 2 +- CompositePattern/Program.cs | 8 +++--- DecoratorPattern/MochaCondiment.cs | 5 ++-- DecoratorPattern/WhipCondiment.cs | 2 +- FacadePattern/Dimmer.cs | 4 --- FacadePattern/DvdPlayer.cs | 4 +-- FacadePattern/HometheaterFacade.cs | 4 +-- FacadePattern/Program.cs | 2 +- .../Factory Method/ChicagoPizzaFactory.cs | 2 +- .../Factory Method/NYPizzaFactory.cs | 6 ++--- FactoryPattern/Pizza/CheesePizza.cs | 2 +- FlyweightPattern/BubbleMilkTea.cs | 2 +- FlyweightPattern/BubbleTeaShop.cs | 3 +-- FlyweightPattern/CoconutMilkTea.cs | 4 +-- FlyweightPattern/FoamMilkTea.cs | 6 ++--- FlyweightPattern/OolingMilkTea.cs | 2 +- FlyweightPattern/Program.cs | 4 +-- FlyweightPattern/ProxyPattern/Dimmer.cs | 4 --- FlyweightPattern/ProxyPattern/DvdPlayer.cs | 4 +-- .../ProxyPattern/HometheaterFacade.cs | 4 +-- FlyweightPattern/ProxyPattern/Program.cs | 2 +- IteratorPattern/BreakfastMenu.cs | 8 +++--- IteratorPattern/BreakfastMenuEnum.cs | 2 +- IteratorPattern/BreakfastMenuIterator.cs | 4 +-- IteratorPattern/Client.cs | 2 +- IteratorPattern/DinnerMenu.cs | 2 +- IteratorPattern/DinnerMenuEnum.cs | 1 - IteratorPattern/DinnerMenuIterator.cs | 1 - IteratorPattern/Menu.cs | 2 +- IteratorPattern/Program.cs | 4 +-- MediatorPattern/Customer.cs | 2 +- MediatorPattern/Program.cs | 4 +-- MediatorPattern/Programmer.cs | 2 +- MediatorPattern/Tester.cs | 2 +- ObserverPattern/WeatherMonitor.cs | 6 ++--- ProxyPattern/Image.cs | 2 +- ProxyPattern/RealImage.cs | 26 +++++++++---------- SingletonPattern/ChocolateBoiler.cs | 4 +-- SingletonPattern/Program.cs | 2 +- StatePattern/HasQuarterState.cs | 2 +- StatePattern/NoQuarterState.cs | 2 +- StatePattern/SoldState.cs | 2 +- StrategyPattern/Program.cs | 5 ++-- StrategyPattern/QuackNormal.cs | 2 +- TemplatePattern/Program.cs | 2 +- VisitorPattern/Apartment.cs | 2 +- VisitorPattern/ApartmentVisitor.cs | 2 +- VisitorPattern/Bedroom.cs | 2 +- VisitorPattern/BedroomVisitor.cs | 2 +- VisitorPattern/LivingRoom.cs | 2 +- VisitorPattern/LivingRoomVisitor.cs | 2 +- VisitorPattern/Program.cs | 2 +- VisitorPattern/Studio.cs | 2 +- VisitorPattern/StudioVisitor.cs | 2 +- 71 files changed, 142 insertions(+), 149 deletions(-) diff --git a/AdapterPattern/MallardDuck.cs b/AdapterPattern/MallardDuck.cs index 24c1ede..b0602cf 100644 --- a/AdapterPattern/MallardDuck.cs +++ b/AdapterPattern/MallardDuck.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace AdapterPattern { diff --git a/AdapterPattern/Program.cs b/AdapterPattern/Program.cs index e0095ad..cb46974 100644 --- a/AdapterPattern/Program.cs +++ b/AdapterPattern/Program.cs @@ -1,5 +1,4 @@ -using System; - + namespace AdapterPattern { internal static class Program diff --git a/AdapterPattern/TurkeyAdapter.cs b/AdapterPattern/TurkeyAdapter.cs index 708eae1..adf13e0 100644 --- a/AdapterPattern/TurkeyAdapter.cs +++ b/AdapterPattern/TurkeyAdapter.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; namespace AdapterPattern { diff --git a/AdapterPattern/WildTurkey.cs b/AdapterPattern/WildTurkey.cs index 2e79fa7..b6e04ac 100644 --- a/AdapterPattern/WildTurkey.cs +++ b/AdapterPattern/WildTurkey.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace AdapterPattern { diff --git a/BridgePattern/FlyingEnchantment.cs b/BridgePattern/FlyingEnchantment.cs index 4678965..4aa5b38 100644 --- a/BridgePattern/FlyingEnchantment.cs +++ b/BridgePattern/FlyingEnchantment.cs @@ -2,7 +2,7 @@ namespace BridgePattern { - public class FlyingEnchantment:IEnchantment + public class FlyingEnchantment : IEnchantment { public void OnActivate() { diff --git a/BridgePattern/Hammer.cs b/BridgePattern/Hammer.cs index 99a2786..55e6782 100644 --- a/BridgePattern/Hammer.cs +++ b/BridgePattern/Hammer.cs @@ -2,7 +2,7 @@ namespace BridgePattern { - public class Hammer:IWeapon + public class Hammer : IWeapon { private readonly IEnchantment _enchantment; public Hammer(IEnchantment enchantment) diff --git a/BridgePattern/Program.cs b/BridgePattern/Program.cs index 2ee4591..c07d035 100644 --- a/BridgePattern/Program.cs +++ b/BridgePattern/Program.cs @@ -8,7 +8,7 @@ private static void Main() sword.Wield(); sword.Swing(); sword.Unwield(); - + IWeapon hammer = new Hammer(new SoulEatingEnchantment()); hammer.Wield(); hammer.Swing(); diff --git a/BridgePattern/SoulEatingEnchantment.cs b/BridgePattern/SoulEatingEnchantment.cs index 6b8d36d..dfb9b8a 100644 --- a/BridgePattern/SoulEatingEnchantment.cs +++ b/BridgePattern/SoulEatingEnchantment.cs @@ -2,7 +2,7 @@ namespace BridgePattern { - public class SoulEatingEnchantment:IEnchantment + public class SoulEatingEnchantment : IEnchantment { public void OnActivate() { diff --git a/BridgePattern/Sword.cs b/BridgePattern/Sword.cs index 2145b4b..23198d5 100644 --- a/BridgePattern/Sword.cs +++ b/BridgePattern/Sword.cs @@ -2,7 +2,7 @@ namespace BridgePattern { - public class Sword:IWeapon + public class Sword : IWeapon { private readonly IEnchantment _enchantment; diff --git a/BuilderPattern/Cook.cs b/BuilderPattern/Cook.cs index dd40620..980bb3d 100644 --- a/BuilderPattern/Cook.cs +++ b/BuilderPattern/Cook.cs @@ -1,24 +1,30 @@ -namespace BuilderPattern { +namespace BuilderPattern +{ // This class can also be called the Director - public class Cook { + public class Cook + { private IBuilder _builder; - public Cook(IBuilder builder) { + public Cook(IBuilder builder) + { AcceptBuilder(builder); } - public void ChangeBuilder(IBuilder builder) { + public void ChangeBuilder(IBuilder builder) + { AcceptBuilder(builder); } - public Hamburger Build() { + public Hamburger Build() + { _builder.AddIngredients(); _builder.AddShape(); _builder.AddSize(); return _builder.Build(); } - private void AcceptBuilder(IBuilder builder) { + private void AcceptBuilder(IBuilder builder) + { _builder = builder; _builder.Reset(); } diff --git a/BuilderPattern/Hamburger.cs b/BuilderPattern/Hamburger.cs index 604f138..68ec0f6 100644 --- a/BuilderPattern/Hamburger.cs +++ b/BuilderPattern/Hamburger.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; - + namespace BuilderPattern { public class Hamburger @@ -9,8 +8,9 @@ public class Hamburger public string[] Ingredients { get; set; } public override string ToString() { - var hamburger=""; - foreach (var ingredient in Ingredients) { + var hamburger = ""; + foreach (var ingredient in Ingredients) + { hamburger += $"{ingredient} "; } return $"Ingredients: {hamburger}, Size: {Size}, Shape: {Shape}"; diff --git a/BuilderPattern/IBuilder.cs b/BuilderPattern/IBuilder.cs index 34d96a2..2730841 100644 --- a/BuilderPattern/IBuilder.cs +++ b/BuilderPattern/IBuilder.cs @@ -1,5 +1,7 @@ -namespace BuilderPattern { - public interface IBuilder { +namespace BuilderPattern +{ + public interface IBuilder + { void AddIngredients(); void AddShape(); void AddSize(); diff --git a/BuilderPattern/MyHamburgerBuilder.cs b/BuilderPattern/MyHamburgerBuilder.cs index 61782f7..4ce1cbf 100644 --- a/BuilderPattern/MyHamburgerBuilder.cs +++ b/BuilderPattern/MyHamburgerBuilder.cs @@ -1,23 +1,29 @@ namespace BuilderPattern { - public class MyHamburgerBuilder : IBuilder { + public class MyHamburgerBuilder : IBuilder + { private Hamburger _hamburger; - public void AddIngredients() { + public void AddIngredients() + { _hamburger.Ingredients = new string[] { "Bread", "Meat", "Tomato", "Salad", "Mayonnaise" }; } - public void AddShape() { + public void AddShape() + { _hamburger.Shape = "Kite"; } - public void AddSize() { + public void AddSize() + { _hamburger.Size = 10; //inches } - public void Reset() { + public void Reset() + { _hamburger = new Hamburger(); } - public Hamburger Build() { + public Hamburger Build() + { return _hamburger; } diff --git a/BuilderPattern/WifesHamburgerBuilder.cs b/BuilderPattern/WifesHamburgerBuilder.cs index 9724fc6..887dcc1 100644 --- a/BuilderPattern/WifesHamburgerBuilder.cs +++ b/BuilderPattern/WifesHamburgerBuilder.cs @@ -1,25 +1,30 @@ -using System; +namespace BuilderPattern +{ -namespace BuilderPattern { - - public class WifesHamburgerBuilder : IBuilder { + public class WifesHamburgerBuilder : IBuilder + { private Hamburger _hamburger; - public void AddIngredients() { + public void AddIngredients() + { _hamburger.Ingredients = new string[] { "Bread", "Salad" }; } - public void AddShape() { + public void AddShape() + { _hamburger.Shape = "Cuboid"; } - public void AddSize() { + public void AddSize() + { _hamburger.Size = 6; //inches } - public void Reset() { + public void Reset() + { _hamburger = new Hamburger(); } - public Hamburger Build() { + public Hamburger Build() + { return _hamburger; } } diff --git a/CommandPattern/Program.cs b/CommandPattern/Program.cs index d12a569..d719ca9 100644 --- a/CommandPattern/Program.cs +++ b/CommandPattern/Program.cs @@ -33,11 +33,11 @@ private static void Main() Console.WriteLine(); var light = new Light("Hall"); - ICommand[] partyOn = {new LightOffCommand(light), bikeDoorOpen, carDoorOpen}; - ICommand[] partyOff = {new LightOnCommand(light), bikeDoorClose, carDoorClose}; + ICommand[] partyOn = { new LightOffCommand(light), bikeDoorOpen, carDoorOpen }; + ICommand[] partyOff = { new LightOnCommand(light), bikeDoorClose, carDoorClose }; - remote[2] = new OnOffStruct {On = new MacroCommand(partyOn), Off = new MacroCommand(partyOff)}; + remote[2] = new OnOffStruct { On = new MacroCommand(partyOn), Off = new MacroCommand(partyOff) }; try { diff --git a/CompositePattern/Menu.cs b/CompositePattern/Menu.cs index 5049303..6be36c6 100644 --- a/CompositePattern/Menu.cs +++ b/CompositePattern/Menu.cs @@ -26,7 +26,7 @@ public override void Remove(MenuComponent component) public override MenuComponent GetChild(int i) { - return _components[i]; + return _components[i]; } public override string Name { get; } diff --git a/CompositePattern/MenuComponent.cs b/CompositePattern/MenuComponent.cs index 07c8c03..38928e4 100644 --- a/CompositePattern/MenuComponent.cs +++ b/CompositePattern/MenuComponent.cs @@ -6,7 +6,7 @@ public class MenuComponent { public virtual void Add(MenuComponent component) { - throw new NotImplementedException(); + throw new NotImplementedException(); } public virtual void Remove(MenuComponent component) diff --git a/CompositePattern/MenuItem.cs b/CompositePattern/MenuItem.cs index 50222e8..ab7c2f1 100644 --- a/CompositePattern/MenuItem.cs +++ b/CompositePattern/MenuItem.cs @@ -18,7 +18,7 @@ public MenuItem(string name, string description, double price, bool isveg) public override double Price { get; } - public override bool Vegetarian { get; } + public override bool Vegetarian { get; } public override void Print() { diff --git a/CompositePattern/Program.cs b/CompositePattern/Program.cs index ea24810..1c24613 100644 --- a/CompositePattern/Program.cs +++ b/CompositePattern/Program.cs @@ -7,14 +7,14 @@ public static void Main() var breakfast = new Menu("Breakfast", "Pancake House"); var lunch = new Menu("Lunch", "Deli Diner"); - var dinner = new Menu("Dinner","Dinneroni"); + var dinner = new Menu("Dinner", "Dinneroni"); var dessert = new Menu("Dessert", "Ice Cream"); var menu = new Menu("All", "McDonalds"); - breakfast.Add(new MenuItem("Waffles","Butterscotch waffles",140,false)); - breakfast.Add(new MenuItem("Corn Flakes","Kellogs",80,true)); + breakfast.Add(new MenuItem("Waffles", "Butterscotch waffles", 140, false)); + breakfast.Add(new MenuItem("Corn Flakes", "Kellogs", 80, true)); lunch.Add(new MenuItem("Burger", "Cheese and Onion Burger", 250, true)); lunch.Add(new MenuItem("Sandwich", "Chicken Sandwich", 280, false)); @@ -23,7 +23,7 @@ public static void Main() dinner.Add(new MenuItem("Pasta", "Chicken Pasta", 280, false)); dessert.Add(new MenuItem("Ice Cream", "Vanilla and Chocolate", 120, true)); - dessert.Add(new MenuItem("Cake", "Choclate Cake Slice",180, false)); + dessert.Add(new MenuItem("Cake", "Choclate Cake Slice", 180, false)); dinner.Add(dessert); menu.Add(breakfast); diff --git a/DecoratorPattern/MochaCondiment.cs b/DecoratorPattern/MochaCondiment.cs index ae2b45d..b0e76a5 100644 --- a/DecoratorPattern/MochaCondiment.cs +++ b/DecoratorPattern/MochaCondiment.cs @@ -9,8 +9,9 @@ public MochaCondiment(Beverage beverage) this._beverage = beverage; } - public override string Description { - get + public override string Description + { + get { if (_beverage.Description.StartsWith("Mocha")) { diff --git a/DecoratorPattern/WhipCondiment.cs b/DecoratorPattern/WhipCondiment.cs index 8863b67..550b929 100644 --- a/DecoratorPattern/WhipCondiment.cs +++ b/DecoratorPattern/WhipCondiment.cs @@ -12,7 +12,7 @@ public WhipCondiment(Beverage beverage) public override string Description { get - { + { if (_beverage.Description.StartsWith("Whip")) { return "Double " + _beverage.Description; diff --git a/FacadePattern/Dimmer.cs b/FacadePattern/Dimmer.cs index d9cfef3..11c35df 100644 --- a/FacadePattern/Dimmer.cs +++ b/FacadePattern/Dimmer.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FacadePattern { diff --git a/FacadePattern/DvdPlayer.cs b/FacadePattern/DvdPlayer.cs index ffaa58c..f442655 100644 --- a/FacadePattern/DvdPlayer.cs +++ b/FacadePattern/DvdPlayer.cs @@ -12,14 +12,14 @@ public void Insert(Dvd dvd) { _dvd = dvd; Console.WriteLine($"Inserting {dvd.Movie}"); - + } public void Play() => Console.WriteLine($"Playing {_dvd.Movie}"); public void Pause() { - Console.WriteLine($"Pausing at {_time = (new Random()).Next(_time,_time + 120)}"); + Console.WriteLine($"Pausing at {_time = (new Random()).Next(_time, _time + 120)}"); } public void Resume() diff --git a/FacadePattern/HometheaterFacade.cs b/FacadePattern/HometheaterFacade.cs index 2d09049..703828e 100644 --- a/FacadePattern/HometheaterFacade.cs +++ b/FacadePattern/HometheaterFacade.cs @@ -5,8 +5,8 @@ public class HomeTheatreFacade private Dimmer _dimmer; private Dvd _dvd; private DvdPlayer _dvdPlayer; - - public HomeTheatreFacade(Dimmer dimmer,Dvd dvd, DvdPlayer dvdPlayer) + + public HomeTheatreFacade(Dimmer dimmer, Dvd dvd, DvdPlayer dvdPlayer) { _dvd = dvd; _dimmer = dimmer; diff --git a/FacadePattern/Program.cs b/FacadePattern/Program.cs index a695029..074539c 100644 --- a/FacadePattern/Program.cs +++ b/FacadePattern/Program.cs @@ -9,7 +9,7 @@ private static void Main() var dimmer = new Dimmer(); var dvdPlayer = new DvdPlayer(); var dvd = new Dvd("Gone with the Wind 2 : Electric Bugaloo"); - var homeTheater = new HomeTheatreFacade(dimmer,dvd,dvdPlayer); + var homeTheater = new HomeTheatreFacade(dimmer, dvd, dvdPlayer); homeTheater.WatchMovie(); Console.WriteLine(); diff --git a/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs b/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs index 63df3a3..2075587 100644 --- a/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs +++ b/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs @@ -6,7 +6,7 @@ protected override Pizza Create(string type) { Pizza pizza; IIngredientsFactory ingredients = new ChicagoIngredientsFactory(); - + if (type.Equals("Cheese")) { pizza = new CheesePizza(ingredients); diff --git a/FactoryPattern/Factory Method/NYPizzaFactory.cs b/FactoryPattern/Factory Method/NYPizzaFactory.cs index d1a2776..2c24bff 100644 --- a/FactoryPattern/Factory Method/NYPizzaFactory.cs +++ b/FactoryPattern/Factory Method/NYPizzaFactory.cs @@ -9,15 +9,15 @@ protected override Pizza Create(string type) if (type.Equals("Cheese")) { - pizza = new CheesePizza(ingredients) {Name = "NY Style Cheese"}; + pizza = new CheesePizza(ingredients) { Name = "NY Style Cheese" }; } else if (type.Equals("Clam")) { - pizza = new ClamPizza(ingredients) {Name = "NY Style Clam"}; + pizza = new ClamPizza(ingredients) { Name = "NY Style Clam" }; } else { - pizza = new VeggiePizza(ingredients) {Name = "NY Style Veggie"}; + pizza = new VeggiePizza(ingredients) { Name = "NY Style Veggie" }; } pizza.Color = "blue"; return pizza; diff --git a/FactoryPattern/Pizza/CheesePizza.cs b/FactoryPattern/Pizza/CheesePizza.cs index 60dac3c..c7e26b5 100644 --- a/FactoryPattern/Pizza/CheesePizza.cs +++ b/FactoryPattern/Pizza/CheesePizza.cs @@ -12,7 +12,7 @@ public CheesePizza(IIngredientsFactory ing) } internal override void Prepare() { - Console.WriteLine("Preparing " + Name + " Using"); + Console.WriteLine("Preparing " + Name + " Using"); Console.Write("Dough: " + _ingredients.CreateDough().Name + ", Cheese: " + _ingredients.CreateCheese().Name + ", Sauce: " + _ingredients.CreateSauce().Name + ", Veggies: "); Console.WriteLine(); foreach (var val in _ingredients.CreateVeggies()) diff --git a/FlyweightPattern/BubbleMilkTea.cs b/FlyweightPattern/BubbleMilkTea.cs index 476cd3e..c58ab9b 100644 --- a/FlyweightPattern/BubbleMilkTea.cs +++ b/FlyweightPattern/BubbleMilkTea.cs @@ -2,7 +2,7 @@ namespace FlyweightPattern { - public class BubbleMilkTea: IBeverage + public class BubbleMilkTea : IBeverage { public BubbleMilkTea() { diff --git a/FlyweightPattern/BubbleTeaShop.cs b/FlyweightPattern/BubbleTeaShop.cs index 4b30646..e6bcbae 100644 --- a/FlyweightPattern/BubbleTeaShop.cs +++ b/FlyweightPattern/BubbleTeaShop.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Reflection.Metadata.Ecma335; namespace FlyweightPattern { @@ -17,7 +16,7 @@ public BubbleTeaShop() private void TakeOrders() { var factory = new BeverageFlyweightFactory(); - + takeAwayOrders.Add(factory.MakeBeverage(BeverageType.BubbleMilk)); takeAwayOrders.Add(factory.MakeBeverage(BeverageType.BubbleMilk)); takeAwayOrders.Add(factory.MakeBeverage(BeverageType.CoconutMilk)); diff --git a/FlyweightPattern/CoconutMilkTea.cs b/FlyweightPattern/CoconutMilkTea.cs index b5c89b2..f96035b 100644 --- a/FlyweightPattern/CoconutMilkTea.cs +++ b/FlyweightPattern/CoconutMilkTea.cs @@ -2,13 +2,13 @@ namespace FlyweightPattern { - public class CoconutMilkTea: IBeverage + public class CoconutMilkTea : IBeverage { public CoconutMilkTea() { Console.WriteLine("Initializing a Coconut Milk Tea instance"); } - + public void Drink() { Console.WriteLine("hmmm... this is coconut milk tea"); diff --git a/FlyweightPattern/FoamMilkTea.cs b/FlyweightPattern/FoamMilkTea.cs index eb5c31a..958b9d7 100644 --- a/FlyweightPattern/FoamMilkTea.cs +++ b/FlyweightPattern/FoamMilkTea.cs @@ -2,14 +2,14 @@ namespace FlyweightPattern { - public class FoamMilkTea:IBeverage + public class FoamMilkTea : IBeverage { - + public FoamMilkTea() { Console.WriteLine("Initializing a Foam Milk Tea instance"); } - + public void Drink() { Console.WriteLine("hmmm... this is foam milk tea"); diff --git a/FlyweightPattern/OolingMilkTea.cs b/FlyweightPattern/OolingMilkTea.cs index 432be67..40a3715 100644 --- a/FlyweightPattern/OolingMilkTea.cs +++ b/FlyweightPattern/OolingMilkTea.cs @@ -2,7 +2,7 @@ namespace FlyweightPattern { - public class OolingMilkTea: IBeverage + public class OolingMilkTea : IBeverage { public OolingMilkTea() diff --git a/FlyweightPattern/Program.cs b/FlyweightPattern/Program.cs index 91d6ab2..462bab7 100644 --- a/FlyweightPattern/Program.cs +++ b/FlyweightPattern/Program.cs @@ -1,6 +1,4 @@ -using System; - -namespace FlyweightPattern +namespace FlyweightPattern { static class Program { diff --git a/FlyweightPattern/ProxyPattern/Dimmer.cs b/FlyweightPattern/ProxyPattern/Dimmer.cs index d9cfef3..11c35df 100644 --- a/FlyweightPattern/ProxyPattern/Dimmer.cs +++ b/FlyweightPattern/ProxyPattern/Dimmer.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FacadePattern { diff --git a/FlyweightPattern/ProxyPattern/DvdPlayer.cs b/FlyweightPattern/ProxyPattern/DvdPlayer.cs index ffaa58c..f442655 100644 --- a/FlyweightPattern/ProxyPattern/DvdPlayer.cs +++ b/FlyweightPattern/ProxyPattern/DvdPlayer.cs @@ -12,14 +12,14 @@ public void Insert(Dvd dvd) { _dvd = dvd; Console.WriteLine($"Inserting {dvd.Movie}"); - + } public void Play() => Console.WriteLine($"Playing {_dvd.Movie}"); public void Pause() { - Console.WriteLine($"Pausing at {_time = (new Random()).Next(_time,_time + 120)}"); + Console.WriteLine($"Pausing at {_time = (new Random()).Next(_time, _time + 120)}"); } public void Resume() diff --git a/FlyweightPattern/ProxyPattern/HometheaterFacade.cs b/FlyweightPattern/ProxyPattern/HometheaterFacade.cs index 2d09049..703828e 100644 --- a/FlyweightPattern/ProxyPattern/HometheaterFacade.cs +++ b/FlyweightPattern/ProxyPattern/HometheaterFacade.cs @@ -5,8 +5,8 @@ public class HomeTheatreFacade private Dimmer _dimmer; private Dvd _dvd; private DvdPlayer _dvdPlayer; - - public HomeTheatreFacade(Dimmer dimmer,Dvd dvd, DvdPlayer dvdPlayer) + + public HomeTheatreFacade(Dimmer dimmer, Dvd dvd, DvdPlayer dvdPlayer) { _dvd = dvd; _dimmer = dimmer; diff --git a/FlyweightPattern/ProxyPattern/Program.cs b/FlyweightPattern/ProxyPattern/Program.cs index a695029..074539c 100644 --- a/FlyweightPattern/ProxyPattern/Program.cs +++ b/FlyweightPattern/ProxyPattern/Program.cs @@ -9,7 +9,7 @@ private static void Main() var dimmer = new Dimmer(); var dvdPlayer = new DvdPlayer(); var dvd = new Dvd("Gone with the Wind 2 : Electric Bugaloo"); - var homeTheater = new HomeTheatreFacade(dimmer,dvd,dvdPlayer); + var homeTheater = new HomeTheatreFacade(dimmer, dvd, dvdPlayer); homeTheater.WatchMovie(); Console.WriteLine(); diff --git a/IteratorPattern/BreakfastMenu.cs b/IteratorPattern/BreakfastMenu.cs index c9ad3d8..f4b5073 100644 --- a/IteratorPattern/BreakfastMenu.cs +++ b/IteratorPattern/BreakfastMenu.cs @@ -20,16 +20,16 @@ public BreakfastMenu() AddItem("Waffle", "Blueberry Sauce topped breakfast Waffles", 125, false); AddItem("Sandwich", "Veggie Sandwich with tomato and cucumber", 75, true); - AddItem("Pankcakes", "Maple syrup Pancakes",110,false); - AddItem("Corn Flakes", "Cornflakes with fruits and nuts",60,true); + AddItem("Pankcakes", "Maple syrup Pancakes", 110, false); + AddItem("Corn Flakes", "Cornflakes with fruits and nuts", 60, true); } private void AddItem(string name, string description, int price, bool veg) { - var item = new Menu(name,description,price,veg); + var item = new Menu(name, description, price, veg); _items.Add(item); } - + } } \ No newline at end of file diff --git a/IteratorPattern/BreakfastMenuEnum.cs b/IteratorPattern/BreakfastMenuEnum.cs index d661b02..683cd3c 100644 --- a/IteratorPattern/BreakfastMenuEnum.cs +++ b/IteratorPattern/BreakfastMenuEnum.cs @@ -37,7 +37,7 @@ public Menu Current { try { - return (Menu) _items[_position]; + return (Menu)_items[_position]; } catch (IndexOutOfRangeException) { diff --git a/IteratorPattern/BreakfastMenuIterator.cs b/IteratorPattern/BreakfastMenuIterator.cs index 9c25928..68bd86e 100644 --- a/IteratorPattern/BreakfastMenuIterator.cs +++ b/IteratorPattern/BreakfastMenuIterator.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections; namespace IteratorPattern { diff --git a/IteratorPattern/Client.cs b/IteratorPattern/Client.cs index 21f2db8..27a1a5b 100644 --- a/IteratorPattern/Client.cs +++ b/IteratorPattern/Client.cs @@ -26,7 +26,7 @@ private void PrintMenu(IEnumerable iter) { foreach (var item in iter) { - var i = (Menu) item; + var i = (Menu)item; Console.WriteLine($"{i.Name} Rs. {i.Price} { (i.Vegetarian ? "*" : "x") } \n {i.Description} "); } diff --git a/IteratorPattern/DinnerMenu.cs b/IteratorPattern/DinnerMenu.cs index cd0c7a6..877fcc7 100644 --- a/IteratorPattern/DinnerMenu.cs +++ b/IteratorPattern/DinnerMenu.cs @@ -28,7 +28,7 @@ public DinnerMenu() private void AddItems(string name, string description, int price, bool veg) { - var item = new Menu(name,description,price,veg); + var item = new Menu(name, description, price, veg); if (_count <= Max) { diff --git a/IteratorPattern/DinnerMenuEnum.cs b/IteratorPattern/DinnerMenuEnum.cs index a567833..68929eb 100644 --- a/IteratorPattern/DinnerMenuEnum.cs +++ b/IteratorPattern/DinnerMenuEnum.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; namespace IteratorPattern { diff --git a/IteratorPattern/DinnerMenuIterator.cs b/IteratorPattern/DinnerMenuIterator.cs index a5fd659..c4dca48 100644 --- a/IteratorPattern/DinnerMenuIterator.cs +++ b/IteratorPattern/DinnerMenuIterator.cs @@ -1,5 +1,4 @@ using System.Collections; -using System.Collections.Generic; namespace IteratorPattern { diff --git a/IteratorPattern/Menu.cs b/IteratorPattern/Menu.cs index 355ed4d..984f85f 100644 --- a/IteratorPattern/Menu.cs +++ b/IteratorPattern/Menu.cs @@ -14,6 +14,6 @@ public Menu(string name, string description, double price, bool vegetarian) Price = price; Vegetarian = vegetarian; } - + } } \ No newline at end of file diff --git a/IteratorPattern/Program.cs b/IteratorPattern/Program.cs index 6f5712d..dae6a70 100644 --- a/IteratorPattern/Program.cs +++ b/IteratorPattern/Program.cs @@ -6,8 +6,8 @@ private static void Main() { var breakfast = new BreakfastMenu(); var dinner = new DinnerMenu(); - var waiter = new Client(breakfast,dinner); + var waiter = new Client(breakfast, dinner); waiter.PrintMenu(); } - } + } } diff --git a/MediatorPattern/Customer.cs b/MediatorPattern/Customer.cs index 774863c..b3bf289 100644 --- a/MediatorPattern/Customer.cs +++ b/MediatorPattern/Customer.cs @@ -4,7 +4,7 @@ namespace MediatorPattern { class Customer : Colleague { - public Customer(Mediator mediator) : base(mediator) {} + public Customer(Mediator mediator) : base(mediator) { } public override void Notify(string message) { diff --git a/MediatorPattern/Program.cs b/MediatorPattern/Program.cs index 9276771..bbdddc5 100644 --- a/MediatorPattern/Program.cs +++ b/MediatorPattern/Program.cs @@ -1,6 +1,4 @@ -using System; - -namespace MediatorPattern +namespace MediatorPattern { class Program { diff --git a/MediatorPattern/Programmer.cs b/MediatorPattern/Programmer.cs index 275214e..cef0b16 100644 --- a/MediatorPattern/Programmer.cs +++ b/MediatorPattern/Programmer.cs @@ -4,7 +4,7 @@ namespace MediatorPattern { class Programmer : Colleague { - public Programmer(Mediator mediator) : base(mediator) {} + public Programmer(Mediator mediator) : base(mediator) { } public override void Notify(string message) { diff --git a/MediatorPattern/Tester.cs b/MediatorPattern/Tester.cs index e218496..0fe71d7 100644 --- a/MediatorPattern/Tester.cs +++ b/MediatorPattern/Tester.cs @@ -4,7 +4,7 @@ namespace MediatorPattern { class Tester : Colleague { - public Tester(Mediator mediator) : base(mediator) {} + public Tester(Mediator mediator) : base(mediator) { } public override void Notify(string message) { diff --git a/ObserverPattern/WeatherMonitor.cs b/ObserverPattern/WeatherMonitor.cs index 5cf8942..6d65f37 100644 --- a/ObserverPattern/WeatherMonitor.cs +++ b/ObserverPattern/WeatherMonitor.cs @@ -21,7 +21,7 @@ public WeatherMonitor(string name) { _name = name; } - + public void OnCompleted() { throw new NotImplementedException(); @@ -39,7 +39,7 @@ public void OnNext(Weather value) { string op = $"| Temperature : {value.Temperature} Celsius |"; Console.Write(op); - + } if (_name.Contains("P")) { @@ -48,7 +48,7 @@ public void OnNext(Weather value) } if (_name.Contains("H")) { - string op = $"| Humidity : {value.Humidity*100} % |"; + string op = $"| Humidity : {value.Humidity * 100} % |"; Console.Write(op); } if (!(_name.Contains("T") || _name.Contains("P") || _name.Contains("H"))) diff --git a/ProxyPattern/Image.cs b/ProxyPattern/Image.cs index 9c1d7b0..5041b84 100644 --- a/ProxyPattern/Image.cs +++ b/ProxyPattern/Image.cs @@ -3,6 +3,6 @@ public interface Image { void display(); - + } } diff --git a/ProxyPattern/RealImage.cs b/ProxyPattern/RealImage.cs index 0405fad..d0826fd 100644 --- a/ProxyPattern/RealImage.cs +++ b/ProxyPattern/RealImage.cs @@ -6,22 +6,22 @@ namespace ProxyPattern public class RealImage : Image { - private string _fileName; + private string _fileName; - public RealImage(string fileName) - { - _fileName = fileName; - loadFromDisk(_fileName); - } + public RealImage(string fileName) + { + _fileName = fileName; + loadFromDisk(_fileName); + } - public void display() - { - Console.WriteLine("Displaying " + _fileName); - } + public void display() + { + Console.WriteLine("Displaying " + _fileName); + } - private void loadFromDisk(string fileName) - { + private void loadFromDisk(string fileName) + { Console.WriteLine("Loading " + fileName); + } } -} } \ No newline at end of file diff --git a/SingletonPattern/ChocolateBoiler.cs b/SingletonPattern/ChocolateBoiler.cs index 35d3e15..bdc6a2d 100644 --- a/SingletonPattern/ChocolateBoiler.cs +++ b/SingletonPattern/ChocolateBoiler.cs @@ -5,9 +5,9 @@ namespace SingletonPattern internal partial class ChocolateBoiler { private static readonly Lazy _singleton = new Lazy(() => new ChocolateBoiler()); - + public static ChocolateBoiler GetInstance() => _singleton.Value; - + private Status _boiler; private ChocolateBoiler() diff --git a/SingletonPattern/Program.cs b/SingletonPattern/Program.cs index 0609ca0..7d81245 100644 --- a/SingletonPattern/Program.cs +++ b/SingletonPattern/Program.cs @@ -11,7 +11,7 @@ static void Main() var chocoEggs = ChocolateBoiler.GetInstance(); chocoEggs.Fill(); chocoEggs.Boil(); - chocoEggs.Drain(); + chocoEggs.Drain(); } catch (Exception) { diff --git a/StatePattern/HasQuarterState.cs b/StatePattern/HasQuarterState.cs index f5e4d98..2dc106d 100644 --- a/StatePattern/HasQuarterState.cs +++ b/StatePattern/HasQuarterState.cs @@ -33,7 +33,7 @@ public void TurnCrank() { Machine.State = Machine.SoldState; } - } + } public void Dispense() { diff --git a/StatePattern/NoQuarterState.cs b/StatePattern/NoQuarterState.cs index 5f2d670..978114d 100644 --- a/StatePattern/NoQuarterState.cs +++ b/StatePattern/NoQuarterState.cs @@ -23,7 +23,7 @@ public void EjectQuarter() public void TurnCrank() { - Console.WriteLine("Can't turn crank without a quarter"); + Console.WriteLine("Can't turn crank without a quarter"); } public void Dispense() diff --git a/StatePattern/SoldState.cs b/StatePattern/SoldState.cs index 0c2d4f4..e8ecb33 100644 --- a/StatePattern/SoldState.cs +++ b/StatePattern/SoldState.cs @@ -18,7 +18,7 @@ public void InsertQuarter() public void EjectQuarter() { - Console.WriteLine("Can't eject, already turned the crank"); + Console.WriteLine("Can't eject, already turned the crank"); } public void TurnCrank() diff --git a/StrategyPattern/Program.cs b/StrategyPattern/Program.cs index 85f9495..934724b 100644 --- a/StrategyPattern/Program.cs +++ b/StrategyPattern/Program.cs @@ -6,7 +6,8 @@ internal class Duck private IFlyBehaviour _flyer; - public IQuackBehaviour Quacker { + public IQuackBehaviour Quacker + { set { _quacker = value; @@ -52,7 +53,7 @@ internal static class Program { private static void Main() { - var mallard = new MallardDuck {Quacker = new QuackNormal()}; + var mallard = new MallardDuck { Quacker = new QuackNormal() }; mallard.Display(); mallard.Flyer = new FlyWings(); mallard.Display(); diff --git a/StrategyPattern/QuackNormal.cs b/StrategyPattern/QuackNormal.cs index aaa0b1f..0dc0053 100644 --- a/StrategyPattern/QuackNormal.cs +++ b/StrategyPattern/QuackNormal.cs @@ -7,6 +7,6 @@ class QuackNormal : IQuackBehaviour public void Quack() { Console.WriteLine("Quack Quack"); - } + } } } diff --git a/TemplatePattern/Program.cs b/TemplatePattern/Program.cs index cc0c9b3..eb0abae 100644 --- a/TemplatePattern/Program.cs +++ b/TemplatePattern/Program.cs @@ -13,7 +13,7 @@ static void Main() tea.WantsCondiments = true; tea.AddSugar = 5; tea.Prepare(); - + Console.WriteLine(); coffee.WantsCondiments = true; coffee.Prepare(); diff --git a/VisitorPattern/Apartment.cs b/VisitorPattern/Apartment.cs index bbf18df..63469c7 100644 --- a/VisitorPattern/Apartment.cs +++ b/VisitorPattern/Apartment.cs @@ -1,6 +1,6 @@ namespace VisitorPattern { - public class Apartment: Unit + public class Apartment : Unit { public Apartment(params Unit[] units) : base(units) { diff --git a/VisitorPattern/ApartmentVisitor.cs b/VisitorPattern/ApartmentVisitor.cs index 21e3d63..bdc6b81 100644 --- a/VisitorPattern/ApartmentVisitor.cs +++ b/VisitorPattern/ApartmentVisitor.cs @@ -2,7 +2,7 @@ namespace VisitorPattern { - public class ApartmentVisitor: IUnitVisitor + public class ApartmentVisitor : IUnitVisitor { public void VisitApartment(Apartment apartment) { diff --git a/VisitorPattern/Bedroom.cs b/VisitorPattern/Bedroom.cs index 3836d32..ee0d08e 100644 --- a/VisitorPattern/Bedroom.cs +++ b/VisitorPattern/Bedroom.cs @@ -1,6 +1,6 @@ namespace VisitorPattern { - public class Bedroom: Unit + public class Bedroom : Unit { public Bedroom(params Unit[] units) : base(units) { diff --git a/VisitorPattern/BedroomVisitor.cs b/VisitorPattern/BedroomVisitor.cs index 47cfa57..f4792ea 100644 --- a/VisitorPattern/BedroomVisitor.cs +++ b/VisitorPattern/BedroomVisitor.cs @@ -2,7 +2,7 @@ namespace VisitorPattern { - public class BedroomVisitor: IUnitVisitor + public class BedroomVisitor : IUnitVisitor { public void VisitApartment(Apartment apartment) { diff --git a/VisitorPattern/LivingRoom.cs b/VisitorPattern/LivingRoom.cs index 54699d3..31e7421 100644 --- a/VisitorPattern/LivingRoom.cs +++ b/VisitorPattern/LivingRoom.cs @@ -1,6 +1,6 @@ namespace VisitorPattern { - public class LivingRoom: Unit + public class LivingRoom : Unit { public LivingRoom(params Unit[] units) : base(units) { diff --git a/VisitorPattern/LivingRoomVisitor.cs b/VisitorPattern/LivingRoomVisitor.cs index a45ebb4..f6cf11a 100644 --- a/VisitorPattern/LivingRoomVisitor.cs +++ b/VisitorPattern/LivingRoomVisitor.cs @@ -2,7 +2,7 @@ namespace VisitorPattern { - public class LivingRoomVisitor: IUnitVisitor + public class LivingRoomVisitor : IUnitVisitor { public void VisitApartment(Apartment apartment) { diff --git a/VisitorPattern/Program.cs b/VisitorPattern/Program.cs index f328752..3d17f4d 100644 --- a/VisitorPattern/Program.cs +++ b/VisitorPattern/Program.cs @@ -12,7 +12,7 @@ static void Main() apartment.Accept(new ApartmentVisitor()); apartment.Accept(new LivingRoomVisitor()); apartment.Accept(new BedroomVisitor()); - + Console.WriteLine("Visiting a Studio"); studio.Accept(new StudioVisitor()); studio.Accept(new LivingRoomVisitor()); diff --git a/VisitorPattern/Studio.cs b/VisitorPattern/Studio.cs index 8bdc7d3..aa48f4e 100644 --- a/VisitorPattern/Studio.cs +++ b/VisitorPattern/Studio.cs @@ -1,6 +1,6 @@ namespace VisitorPattern { - public class Studio: Unit + public class Studio : Unit { public Studio(params Unit[] units) : base(units) { diff --git a/VisitorPattern/StudioVisitor.cs b/VisitorPattern/StudioVisitor.cs index 646af15..82c2521 100644 --- a/VisitorPattern/StudioVisitor.cs +++ b/VisitorPattern/StudioVisitor.cs @@ -2,7 +2,7 @@ namespace VisitorPattern { - public class StudioVisitor: IUnitVisitor + public class StudioVisitor : IUnitVisitor { public void VisitApartment(Apartment apartment) { From 871bea0de8cc4e339671a8fca7f715ddf7d6ff06 Mon Sep 17 00:00:00 2001 From: u8989332 Date: Sat, 6 Mar 2021 11:52:57 +0800 Subject: [PATCH 20/28] Fix the link of Proxy Pattern in README.md (#20) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 238a5db..0d2dbdd 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ There are three kinds of Design Patterns * [Template](/TemplatePattern) * [Visitor](/VisitorPattern) * [Mediator](/MediatorPattern) -* [Proxy] (/ProxyPattern) \ No newline at end of file +* [Proxy](/ProxyPattern) From 6f9a5c906267e267156e99055a75dd28cd96ea61 Mon Sep 17 00:00:00 2001 From: Kyle <59298462+Kfollen93@users.noreply.github.com> Date: Tue, 27 Jul 2021 10:16:05 -0700 Subject: [PATCH 21/28] Fix typos in README (#23) --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0d2dbdd..d16ff9f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# DesignPatterns -Design patterns are solutions to recurring problems; guidelines on how to tackle certain problems +# Design Patterns +Design patterns are solutions to recurring problems; guidelines on how to tackle certain problems. I have included implementations of some design patterns in C# to help beginners like me get their feet wet. -There are better alternatives available for some of them in the .NET Framework, so this is by no means a comprehensive tutorial +There are better alternatives available for some of them in the .NET Framework, so this is by no means a comprehensive tutorial. -Any comments and suggestions are welcome. If you want to add a new design pattern implementation, just follow the naming conversation, fork my repo and submit a pull request. Same goes for any improvements and modifications. +Any comments and suggestions are welcome. If you want to add a new design pattern implementation, just follow the naming convention, fork my repo and submit a pull request. Same goes for any improvements and modifications. ## Types of Design Patterns --------------------------- -There are three kinds of Design Patterns +There are three kinds of Design Patterns: * Creational * Structural From 04526887f577f21e212e963fa383b51971e8d197 Mon Sep 17 00:00:00 2001 From: Can Karaboran Date: Wed, 22 Sep 2021 12:01:03 +0300 Subject: [PATCH 22/28] Fix interface directory (#25) Co-authored-by: Can Karaboran --- .../Ingredients/{Intefaces => Interfaces}/ICheese.cs | 0 .../Ingredients/{Intefaces => Interfaces}/IClam.cs | 0 .../Ingredients/{Intefaces => Interfaces}/IDough.cs | 0 .../Ingredients/{Intefaces => Interfaces}/ISauce.cs | 0 .../Ingredients/{Intefaces => Interfaces}/IVeggies.cs | 0 FactoryPattern/FactoryPattern.csproj | 4 ---- 6 files changed, 4 deletions(-) rename FactoryPattern/Abstract Factory/Ingredients/{Intefaces => Interfaces}/ICheese.cs (100%) rename FactoryPattern/Abstract Factory/Ingredients/{Intefaces => Interfaces}/IClam.cs (100%) rename FactoryPattern/Abstract Factory/Ingredients/{Intefaces => Interfaces}/IDough.cs (100%) rename FactoryPattern/Abstract Factory/Ingredients/{Intefaces => Interfaces}/ISauce.cs (100%) rename FactoryPattern/Abstract Factory/Ingredients/{Intefaces => Interfaces}/IVeggies.cs (100%) diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs b/FactoryPattern/Abstract Factory/Ingredients/Interfaces/ICheese.cs similarity index 100% rename from FactoryPattern/Abstract Factory/Ingredients/Intefaces/ICheese.cs rename to FactoryPattern/Abstract Factory/Ingredients/Interfaces/ICheese.cs diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs b/FactoryPattern/Abstract Factory/Ingredients/Interfaces/IClam.cs similarity index 100% rename from FactoryPattern/Abstract Factory/Ingredients/Intefaces/IClam.cs rename to FactoryPattern/Abstract Factory/Ingredients/Interfaces/IClam.cs diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs b/FactoryPattern/Abstract Factory/Ingredients/Interfaces/IDough.cs similarity index 100% rename from FactoryPattern/Abstract Factory/Ingredients/Intefaces/IDough.cs rename to FactoryPattern/Abstract Factory/Ingredients/Interfaces/IDough.cs diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs b/FactoryPattern/Abstract Factory/Ingredients/Interfaces/ISauce.cs similarity index 100% rename from FactoryPattern/Abstract Factory/Ingredients/Intefaces/ISauce.cs rename to FactoryPattern/Abstract Factory/Ingredients/Interfaces/ISauce.cs diff --git a/FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs b/FactoryPattern/Abstract Factory/Ingredients/Interfaces/IVeggies.cs similarity index 100% rename from FactoryPattern/Abstract Factory/Ingredients/Intefaces/IVeggies.cs rename to FactoryPattern/Abstract Factory/Ingredients/Interfaces/IVeggies.cs diff --git a/FactoryPattern/FactoryPattern.csproj b/FactoryPattern/FactoryPattern.csproj index 8ffe015..23df604 100644 --- a/FactoryPattern/FactoryPattern.csproj +++ b/FactoryPattern/FactoryPattern.csproj @@ -5,8 +5,4 @@ netcoreapp2.1 - - - - From dcd0bebfbaa69973d41a34943f32d657a3f28b8a Mon Sep 17 00:00:00 2001 From: Ashwin Chakravarthy K Date: Fri, 26 Aug 2022 16:04:04 +0530 Subject: [PATCH 23/28] net core to net 6 upgrade (#28) --- AdapterPattern/AdapterPattern.csproj | 4 +++- BridgePattern/BridgePattern.csproj | 10 ++++++---- BuilderPattern/BuilderPattern.csproj | 4 +++- .../ChainOfResponsibilityPattern.csproj | 4 +++- CommandPattern/CommandPattern.csproj | 4 +++- CompositePattern/CompositePattern.csproj | 4 +++- DecoratorPattern/DecoratorPattern.csproj | 4 +++- FacadePattern/FacadePattern.csproj | 4 +++- FactoryPattern/FactoryPattern.csproj | 4 +++- FlyweightPattern/FlyweightPattern.csproj | 10 ++++++---- IteratorPattern/IteratorPattern.csproj | 4 +++- MediatorPattern/MediatorPattern.csproj | 10 ++++++---- ObserverPattern/ObserverPattern.csproj | 4 +++- PrototypePattern/PrototypePattern.csproj | 4 +++- ProxyPattern/ProxyPattern.csproj | 4 +++- SingletonPattern/SingletonPattern.csproj | 4 +++- StatePattern/StatePattern.csproj | 4 +++- StrategyPattern/StrategyPattern.csproj | 4 +++- TemplatePattern/TemplatePattern.csproj | 4 +++- VisitorPattern/VisitorPattern.csproj | 10 ++++++---- 20 files changed, 72 insertions(+), 32 deletions(-) diff --git a/AdapterPattern/AdapterPattern.csproj b/AdapterPattern/AdapterPattern.csproj index ce1697a..74abf5c 100644 --- a/AdapterPattern/AdapterPattern.csproj +++ b/AdapterPattern/AdapterPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/BridgePattern/BridgePattern.csproj b/BridgePattern/BridgePattern.csproj index 51b7f6c..74abf5c 100644 --- a/BridgePattern/BridgePattern.csproj +++ b/BridgePattern/BridgePattern.csproj @@ -1,8 +1,10 @@ - - Exe - netcoreapp2.1 - + + Exe + net6.0 + enable + enable + diff --git a/BuilderPattern/BuilderPattern.csproj b/BuilderPattern/BuilderPattern.csproj index ce1697a..74abf5c 100644 --- a/BuilderPattern/BuilderPattern.csproj +++ b/BuilderPattern/BuilderPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj b/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj index 23df604..74abf5c 100644 --- a/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj +++ b/ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.1 + net6.0 + enable + enable diff --git a/CommandPattern/CommandPattern.csproj b/CommandPattern/CommandPattern.csproj index ce1697a..74abf5c 100644 --- a/CommandPattern/CommandPattern.csproj +++ b/CommandPattern/CommandPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/CompositePattern/CompositePattern.csproj b/CompositePattern/CompositePattern.csproj index ce1697a..74abf5c 100644 --- a/CompositePattern/CompositePattern.csproj +++ b/CompositePattern/CompositePattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/DecoratorPattern/DecoratorPattern.csproj b/DecoratorPattern/DecoratorPattern.csproj index ce1697a..74abf5c 100644 --- a/DecoratorPattern/DecoratorPattern.csproj +++ b/DecoratorPattern/DecoratorPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/FacadePattern/FacadePattern.csproj b/FacadePattern/FacadePattern.csproj index ce1697a..74abf5c 100644 --- a/FacadePattern/FacadePattern.csproj +++ b/FacadePattern/FacadePattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/FactoryPattern/FactoryPattern.csproj b/FactoryPattern/FactoryPattern.csproj index 23df604..74abf5c 100644 --- a/FactoryPattern/FactoryPattern.csproj +++ b/FactoryPattern/FactoryPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.1 + net6.0 + enable + enable diff --git a/FlyweightPattern/FlyweightPattern.csproj b/FlyweightPattern/FlyweightPattern.csproj index 51b7f6c..74abf5c 100644 --- a/FlyweightPattern/FlyweightPattern.csproj +++ b/FlyweightPattern/FlyweightPattern.csproj @@ -1,8 +1,10 @@ - - Exe - netcoreapp2.1 - + + Exe + net6.0 + enable + enable + diff --git a/IteratorPattern/IteratorPattern.csproj b/IteratorPattern/IteratorPattern.csproj index ce1697a..74abf5c 100644 --- a/IteratorPattern/IteratorPattern.csproj +++ b/IteratorPattern/IteratorPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/MediatorPattern/MediatorPattern.csproj b/MediatorPattern/MediatorPattern.csproj index 51b7f6c..74abf5c 100644 --- a/MediatorPattern/MediatorPattern.csproj +++ b/MediatorPattern/MediatorPattern.csproj @@ -1,8 +1,10 @@ - - Exe - netcoreapp2.1 - + + Exe + net6.0 + enable + enable + diff --git a/ObserverPattern/ObserverPattern.csproj b/ObserverPattern/ObserverPattern.csproj index ce1697a..74abf5c 100644 --- a/ObserverPattern/ObserverPattern.csproj +++ b/ObserverPattern/ObserverPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/PrototypePattern/PrototypePattern.csproj b/PrototypePattern/PrototypePattern.csproj index 23df604..74abf5c 100644 --- a/PrototypePattern/PrototypePattern.csproj +++ b/PrototypePattern/PrototypePattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.1 + net6.0 + enable + enable diff --git a/ProxyPattern/ProxyPattern.csproj b/ProxyPattern/ProxyPattern.csproj index c73e0d1..74abf5c 100644 --- a/ProxyPattern/ProxyPattern.csproj +++ b/ProxyPattern/ProxyPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp3.1 + net6.0 + enable + enable diff --git a/SingletonPattern/SingletonPattern.csproj b/SingletonPattern/SingletonPattern.csproj index ce1697a..74abf5c 100644 --- a/SingletonPattern/SingletonPattern.csproj +++ b/SingletonPattern/SingletonPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/StatePattern/StatePattern.csproj b/StatePattern/StatePattern.csproj index ce1697a..74abf5c 100644 --- a/StatePattern/StatePattern.csproj +++ b/StatePattern/StatePattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/StrategyPattern/StrategyPattern.csproj b/StrategyPattern/StrategyPattern.csproj index ce1697a..74abf5c 100644 --- a/StrategyPattern/StrategyPattern.csproj +++ b/StrategyPattern/StrategyPattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/TemplatePattern/TemplatePattern.csproj b/TemplatePattern/TemplatePattern.csproj index ce1697a..74abf5c 100644 --- a/TemplatePattern/TemplatePattern.csproj +++ b/TemplatePattern/TemplatePattern.csproj @@ -2,7 +2,9 @@ Exe - netcoreapp2.0 + net6.0 + enable + enable diff --git a/VisitorPattern/VisitorPattern.csproj b/VisitorPattern/VisitorPattern.csproj index 51b7f6c..74abf5c 100644 --- a/VisitorPattern/VisitorPattern.csproj +++ b/VisitorPattern/VisitorPattern.csproj @@ -1,8 +1,10 @@ - - Exe - netcoreapp2.1 - + + Exe + net6.0 + enable + enable + From 463ef4ecb9f21d77c04d56693db6c938108d9b1d Mon Sep 17 00:00:00 2001 From: Volodymyr Tkachenko Date: Wed, 2 Nov 2022 19:40:39 +0200 Subject: [PATCH 24/28] Build fix: Improper Proxy pattern is removed from Flyghtweight pattern's project (#32) --- FlyweightPattern/ProxyPattern/Dimmer.cs | 14 -------- FlyweightPattern/ProxyPattern/Dvd.cs | 11 ------ FlyweightPattern/ProxyPattern/DvdPlayer.cs | 30 ---------------- .../ProxyPattern/HometheaterFacade.cs | 36 ------------------- FlyweightPattern/ProxyPattern/Program.cs | 23 ------------ .../ProxyPattern/ProxyPattern.csproj | 8 ----- 6 files changed, 122 deletions(-) delete mode 100644 FlyweightPattern/ProxyPattern/Dimmer.cs delete mode 100644 FlyweightPattern/ProxyPattern/Dvd.cs delete mode 100644 FlyweightPattern/ProxyPattern/DvdPlayer.cs delete mode 100644 FlyweightPattern/ProxyPattern/HometheaterFacade.cs delete mode 100644 FlyweightPattern/ProxyPattern/Program.cs delete mode 100644 FlyweightPattern/ProxyPattern/ProxyPattern.csproj diff --git a/FlyweightPattern/ProxyPattern/Dimmer.cs b/FlyweightPattern/ProxyPattern/Dimmer.cs deleted file mode 100644 index 11c35df..0000000 --- a/FlyweightPattern/ProxyPattern/Dimmer.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace FacadePattern -{ - public class Dimmer - { - internal void Dim(int val) - { - Console.WriteLine(val == 10 ? "Turning Lights On" : $"Dimming lights to {val}"); - } - - internal void Off() => Console.WriteLine("Switching off lights"); - } -} diff --git a/FlyweightPattern/ProxyPattern/Dvd.cs b/FlyweightPattern/ProxyPattern/Dvd.cs deleted file mode 100644 index b247c62..0000000 --- a/FlyweightPattern/ProxyPattern/Dvd.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace FacadePattern -{ - public class Dvd - { - public Dvd(string name) - { - Movie = name; - } - public string Movie { get; set; } - } -} \ No newline at end of file diff --git a/FlyweightPattern/ProxyPattern/DvdPlayer.cs b/FlyweightPattern/ProxyPattern/DvdPlayer.cs deleted file mode 100644 index f442655..0000000 --- a/FlyweightPattern/ProxyPattern/DvdPlayer.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace FacadePattern -{ - public class DvdPlayer - { - private Dvd _dvd; - private int _time = 0; - public void On() => Console.WriteLine("DVD Player powered on"); - - public void Insert(Dvd dvd) - { - _dvd = dvd; - Console.WriteLine($"Inserting {dvd.Movie}"); - - } - - public void Play() => Console.WriteLine($"Playing {_dvd.Movie}"); - - public void Pause() - { - Console.WriteLine($"Pausing at {_time = (new Random()).Next(_time, _time + 120)}"); - } - - public void Resume() - { - Console.WriteLine($"Resuming from {_time}"); - } - } -} \ No newline at end of file diff --git a/FlyweightPattern/ProxyPattern/HometheaterFacade.cs b/FlyweightPattern/ProxyPattern/HometheaterFacade.cs deleted file mode 100644 index 703828e..0000000 --- a/FlyweightPattern/ProxyPattern/HometheaterFacade.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace FacadePattern -{ - public class HomeTheatreFacade - { - private Dimmer _dimmer; - private Dvd _dvd; - private DvdPlayer _dvdPlayer; - - public HomeTheatreFacade(Dimmer dimmer, Dvd dvd, DvdPlayer dvdPlayer) - { - _dvd = dvd; - _dimmer = dimmer; - _dvdPlayer = dvdPlayer; - } - - public void WatchMovie() - { - _dimmer.Dim(5); - _dvdPlayer.On(); - _dvdPlayer.Insert(_dvd); - _dvdPlayer.Play(); - } - - public void Pause() - { - _dimmer.Dim(10); - _dvdPlayer.Pause(); - } - - public void Resume() - { - _dimmer.Dim(5); - _dvdPlayer.Resume(); - } - } -} \ No newline at end of file diff --git a/FlyweightPattern/ProxyPattern/Program.cs b/FlyweightPattern/ProxyPattern/Program.cs deleted file mode 100644 index 074539c..0000000 --- a/FlyweightPattern/ProxyPattern/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace FacadePattern -{ - internal static class Program - { - private static void Main() - { - var dimmer = new Dimmer(); - var dvdPlayer = new DvdPlayer(); - var dvd = new Dvd("Gone with the Wind 2 : Electric Bugaloo"); - var homeTheater = new HomeTheatreFacade(dimmer, dvd, dvdPlayer); - - homeTheater.WatchMovie(); - Console.WriteLine(); - homeTheater.Pause(); - Console.WriteLine(); - homeTheater.Resume(); - Console.WriteLine(); - homeTheater.Pause(); - } - } -} diff --git a/FlyweightPattern/ProxyPattern/ProxyPattern.csproj b/FlyweightPattern/ProxyPattern/ProxyPattern.csproj deleted file mode 100644 index ce1697a..0000000 --- a/FlyweightPattern/ProxyPattern/ProxyPattern.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp2.0 - - - From ce571e3627ed26ed936aba88ab45c8bc590f3a59 Mon Sep 17 00:00:00 2001 From: Abishek Aditya Date: Wed, 2 Nov 2022 23:12:50 +0530 Subject: [PATCH 25/28] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d16ff9f..6039801 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ There are better alternatives available for some of them in the .NET Framework, Any comments and suggestions are welcome. If you want to add a new design pattern implementation, just follow the naming convention, fork my repo and submit a pull request. Same goes for any improvements and modifications. +This was created as a C# alternative to Java while reading https://www.oreilly.com/library/view/head-first-design/0596007124/ <- take a look at it if anything confuses you. + ## Types of Design Patterns --------------------------- There are three kinds of Design Patterns: From 3574c8a52c6d1236710a08c6bdd9bfaf84e8e732 Mon Sep 17 00:00:00 2001 From: Ale-na98 <86318402+Ale-na98@users.noreply.github.com> Date: Wed, 2 Nov 2022 18:43:27 +0100 Subject: [PATCH 26/28] Add unit test for Singleton pattern (#29) --- DesignPatternsDotNetCore.sln | 20 +++++++++++++--- .../SingletonPattern.Tests.csproj | 23 +++++++++++++++++++ .../SingletonPatternTests.cs | 17 ++++++++++++++ SingletonPattern.Tests/Usings.cs | 1 + SingletonPattern/Properties/AssemblyInfo.cs | 3 +++ 5 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 SingletonPattern.Tests/SingletonPattern.Tests.csproj create mode 100644 SingletonPattern.Tests/SingletonPatternTests.cs create mode 100644 SingletonPattern.Tests/Usings.cs create mode 100644 SingletonPattern/Properties/AssemblyInfo.cs diff --git a/DesignPatternsDotNetCore.sln b/DesignPatternsDotNetCore.sln index 5f9a763..3a7677a 100644 --- a/DesignPatternsDotNetCore.sln +++ b/DesignPatternsDotNetCore.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29920.165 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{79553F75-E8DC-4988-B511-A79CC6A9CDF7}" EndProject @@ -38,7 +38,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatorPattern", "Mediator EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuilderPattern", "BuilderPattern\BuilderPattern.csproj", "{274786D8-2E30-40D7-81B5-DFA3872CF9B6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyPattern", "ProxyPattern\ProxyPattern.csproj", "{0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProxyPattern", "ProxyPattern\ProxyPattern.csproj", "{0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingletonPattern.Tests", "SingletonPattern.Tests\SingletonPattern.Tests.csproj", "{7A21A074-AEBB-4B33-80BA-D7DFBE87A449}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -278,6 +280,18 @@ Global {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|x64.Build.0 = Release|Any CPU {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|x86.ActiveCfg = Release|Any CPU {0F8297F6-FA4F-44B6-BF99-0FF71ECCF87A}.Release|x86.Build.0 = Release|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Debug|x64.ActiveCfg = Debug|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Debug|x64.Build.0 = Debug|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Debug|x86.ActiveCfg = Debug|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Debug|x86.Build.0 = Debug|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Release|Any CPU.Build.0 = Release|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Release|x64.ActiveCfg = Release|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Release|x64.Build.0 = Release|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Release|x86.ActiveCfg = Release|Any CPU + {7A21A074-AEBB-4B33-80BA-D7DFBE87A449}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SingletonPattern.Tests/SingletonPattern.Tests.csproj b/SingletonPattern.Tests/SingletonPattern.Tests.csproj new file mode 100644 index 0000000..ec8a874 --- /dev/null +++ b/SingletonPattern.Tests/SingletonPattern.Tests.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + diff --git a/SingletonPattern.Tests/SingletonPatternTests.cs b/SingletonPattern.Tests/SingletonPatternTests.cs new file mode 100644 index 0000000..f015dfc --- /dev/null +++ b/SingletonPattern.Tests/SingletonPatternTests.cs @@ -0,0 +1,17 @@ +namespace SingletonPattern.Tests +{ + [TestFixture] + public class SingletonPatternTests + { + [Test] + public void GetInstance_CreateInstanceTwice_AreEqual() + { + // Arrange, Act + var firstAttemptInstance = ChocolateBoiler.GetInstance(); + var secondAttemptInstance = ChocolateBoiler.GetInstance(); + + // Assert + Assert.That(firstAttemptInstance, Is.EqualTo(secondAttemptInstance)); + } + } +} diff --git a/SingletonPattern.Tests/Usings.cs b/SingletonPattern.Tests/Usings.cs new file mode 100644 index 0000000..3244567 --- /dev/null +++ b/SingletonPattern.Tests/Usings.cs @@ -0,0 +1 @@ +global using NUnit.Framework; diff --git a/SingletonPattern/Properties/AssemblyInfo.cs b/SingletonPattern/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f6a8309 --- /dev/null +++ b/SingletonPattern/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly:InternalsVisibleTo("SingletonPattern.Tests")] From 34b417f9b52336378416e32b32e7243d41348416 Mon Sep 17 00:00:00 2001 From: FunkyMonk8111 <100250024+FunkyMonk8111@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:09:32 -0500 Subject: [PATCH 27/28] Adding missing design pattern links (#34) Added the typo or missing design pattern links per issue #22 --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6039801..f82eb91 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ There are three kinds of Design Patterns: * [Adapter](/AdapterPattern) * [Bridge](/BridgePattern) +* [Builder](/BuilderPattern) +* [ChainOfResponsibility](/ChainOfResponsibilityPattern) * [Command](/CommandPattern) * [Composite](/CompositePattern) * [Decorator](/DecoratorPattern) @@ -27,11 +29,13 @@ There are three kinds of Design Patterns: * [Factory](/FactoryPattern) * [Flyweight](/FlyweightPattern) * [Iterator](/IteratorPattern) +* [Mediator](/MediatorPattern) * [Observer](/ObserverPattern) +* [Prototype](/PrototypePattern) +* [Proxy](/ProxyPattern) * [Singleton](/SingletonPattern) +* [SingletonPattern.Tests](/SingletonPattern.Tests) * [State](/StatePattern) * [Strategy](/StrategyPattern) * [Template](/TemplatePattern) * [Visitor](/VisitorPattern) -* [Mediator](/MediatorPattern) -* [Proxy](/ProxyPattern) From 3975eae85bf104af87e94efa592548a325624f83 Mon Sep 17 00:00:00 2001 From: vikramvee Date: Thu, 11 Jan 2024 03:40:17 +0530 Subject: [PATCH 28/28] Cleaned the code by removing the string literals (#33) * Removed the use of String Literals * Removed the use of String Literals for clean code --- .../Factory Method/ChicagoPizzaFactory.cs | 16 ++++++++++------ .../Factory Method/NYPizzaFactory.cs | 16 ++++++++++------ FactoryPattern/Factory Method/PizzaFactory.cs | 4 ++-- FactoryPattern/Helper.cs | 18 ++++++++++++++++++ FactoryPattern/Program.cs | 4 ++-- 5 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 FactoryPattern/Helper.cs diff --git a/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs b/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs index 2075587..234bdb0 100644 --- a/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs +++ b/FactoryPattern/Factory Method/ChicagoPizzaFactory.cs @@ -2,25 +2,29 @@ { class ChicagoPizzaFactory : PizzaFactory { - protected override Pizza Create(string type) + private readonly string chicagoCheese = "Chicago Cheese"; + private readonly string chicagoClam = "Chicago Clam"; + private readonly string chicagoVeggie = "Chicago Veggie"; + + protected override Pizza Create(PizzaType type) { Pizza pizza; IIngredientsFactory ingredients = new ChicagoIngredientsFactory(); - if (type.Equals("Cheese")) + if (type == PizzaType.Cheese) { pizza = new CheesePizza(ingredients); - pizza.Name = "Chicago Cheese"; + pizza.Name = chicagoCheese; } - else if (type.Equals("Clam")) + else if (type == PizzaType.Clam) { pizza = new ClamPizza(ingredients); - pizza.Name = "Chicago Clam"; + pizza.Name = chicagoClam; } else { pizza = new VeggiePizza(ingredients); - pizza.Name = "Chicago Veggie"; + pizza.Name = chicagoVeggie; } pizza.Color = "red"; return pizza; diff --git a/FactoryPattern/Factory Method/NYPizzaFactory.cs b/FactoryPattern/Factory Method/NYPizzaFactory.cs index 2c24bff..de2d0b7 100644 --- a/FactoryPattern/Factory Method/NYPizzaFactory.cs +++ b/FactoryPattern/Factory Method/NYPizzaFactory.cs @@ -2,22 +2,26 @@ { class NyPizzaFactory : PizzaFactory { - protected override Pizza Create(string type) + private readonly string nyStyleCheese = "NY Style Cheese"; + private readonly string nyStyleClam = "NY Style Clam"; + private readonly string nyStyleVeggie = "NY Style Veggie"; + + protected override Pizza Create(PizzaType type) { Pizza pizza; IIngredientsFactory ingredients = new NyIngredientsFactory(); - if (type.Equals("Cheese")) + if (type == PizzaType.Cheese) { - pizza = new CheesePizza(ingredients) { Name = "NY Style Cheese" }; + pizza = new CheesePizza(ingredients) { Name = nyStyleCheese }; } - else if (type.Equals("Clam")) + else if (type == PizzaType.Clam) { - pizza = new ClamPizza(ingredients) { Name = "NY Style Clam" }; + pizza = new ClamPizza(ingredients) { Name = nyStyleClam }; } else { - pizza = new VeggiePizza(ingredients) { Name = "NY Style Veggie" }; + pizza = new VeggiePizza(ingredients) { Name = nyStyleVeggie }; } pizza.Color = "blue"; return pizza; diff --git a/FactoryPattern/Factory Method/PizzaFactory.cs b/FactoryPattern/Factory Method/PizzaFactory.cs index 31ead68..f0b7a38 100644 --- a/FactoryPattern/Factory Method/PizzaFactory.cs +++ b/FactoryPattern/Factory Method/PizzaFactory.cs @@ -2,7 +2,7 @@ { abstract class PizzaFactory { - public Pizza Order(string type) + public Pizza Order(PizzaType type) { var pizza = Create(type); pizza.Prepare(); @@ -12,6 +12,6 @@ public Pizza Order(string type) return pizza; } - protected abstract Pizza Create(string type); + protected abstract Pizza Create(PizzaType type); } } diff --git a/FactoryPattern/Helper.cs b/FactoryPattern/Helper.cs new file mode 100644 index 0000000..4a897e8 --- /dev/null +++ b/FactoryPattern/Helper.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FactoryPattern +{ + internal class Helper + { + } + + internal enum PizzaType + { + Cheese, + Clam + } +} diff --git a/FactoryPattern/Program.cs b/FactoryPattern/Program.cs index d16bc6f..0612463 100644 --- a/FactoryPattern/Program.cs +++ b/FactoryPattern/Program.cs @@ -8,11 +8,11 @@ static void Main() { Console.WriteLine("Yankees fan orders:"); var yankees = new NyPizzaFactory(); - yankees.Order("Cheese"); + yankees.Order(PizzaType.Cheese); Console.WriteLine(); Console.WriteLine("Cubs fan orders:"); var cubs = new ChicagoPizzaFactory(); - cubs.Order("Clam"); + cubs.Order(PizzaType.Clam); } } } \ No newline at end of file