DesignPatternsDemo 1.0.0

dotnet add package DesignPatternsDemo --version 1.0.0                
NuGet\Install-Package DesignPatternsDemo -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DesignPatternsDemo" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DesignPatternsDemo --version 1.0.0                
#r "nuget: DesignPatternsDemo, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DesignPatternsDemo as a Cake Addin
#addin nuget:?package=DesignPatternsDemo&version=1.0.0

// Install DesignPatternsDemo as a Cake Tool
#tool nuget:?package=DesignPatternsDemo&version=1.0.0                

DesignPatternsDemo

DesignPatternsDemo is a C# library that demonstrates various design patterns, including Singleton, Factory Method, Strategy, and Observer patterns. This library serves as a practical reference for developers who want to understand and implement these design patterns in their applications.

Installation

You can install the library via NuGet Package Manager or by using the .NET CLI.

Using NuGet Package Manager

Install-Package DesignPatternsDemo
Using .NET CLI

dotnet add package DesignPatternsDemo
Usage
Singleton Pattern
The Singleton pattern ensures that a class has only one instance and provides a global point of access to it.

csharp

var singletonInstance = Singleton.Instance;
Console.WriteLine(singletonInstance.GetMessage());
Factory Method Pattern
The Factory Method pattern defines an interface for creating an object but allows subclasses to alter the type of objects that will be created.

csharp

Creator creator = new ConcreteCreatorA();
IProduct product = creator.FactoryMethod();
Console.WriteLine(product.Operation());
Strategy Pattern
The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable.

var context = new Context();
context.SetStrategy(new ConcreteStrategyAdd());
Console.WriteLine(context.ExecuteStrategy(5, 3));  // Output: 8

context.SetStrategy(new ConcreteStrategySubtract());
Console.WriteLine(context.ExecuteStrategy(5, 3));  // Output: 2
Observer Pattern
The Observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified.

csharp

var subject = new ConcreteSubject();
var observerA = new ConcreteObserver("Observer A");
var observerB = new ConcreteObserver("Observer B");

subject.Attach(observerA);
subject.Attach(observerB);

subject.State = "New State";  // Both observers will receive this update
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.

License
This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments
This library is inspired by common software design principles and patterns.
Special thanks to the open-source community for their contributions and resources.


### Notes on the `README.md` File

- **Title and Description**: Clearly state the name and purpose of the library.
- **Installation Instructions**: Provide clear instructions on how to install the library using NuGet.
- **Usage Examples**: Include code snippets demonstrating how to use each design pattern implemented in the library.
- **Contributing Section**: Encourage contributions and provide a way for users to engage with the project.
- **License Information**: Include licensing details to clarify how others can use your library.
- **Acknowledgments**: Optionally, you can acknowledge any resources or individuals that helped you in your project.

Feel free to modify this `README.md` file according to your preferences a
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 91 11/15/2024