diff --git a/.gitignore b/.gitignore
index 3f105cd..d855cbd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,376 @@
-.vscode/
-bin/
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Oo]ut/
+[Ll]og/
+[Ll]ogs/
+WTH/
obj/
-.env
\ No newline at end of file
+<<<<<<< HEAD
+.env
+/.vs/ConsoleApp1/FileContentIndex
+/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681
+/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/CodeChunks.db-shm
+/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/CodeChunks.db-wal
+/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/SemanticSymbols.db-shm
+/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/SemanticSymbols.db-wal
+=======
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+/MyAPI/README.md
+>>>>>>> 0cd14716d2d2d0a2df4550cd4e8f767725efbe8d
diff --git a/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/CodeChunks.db b/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/CodeChunks.db
new file mode 100644
index 0000000..e0f5faf
Binary files /dev/null and b/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/CodeChunks.db differ
diff --git a/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/SemanticSymbols.db b/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/SemanticSymbols.db
new file mode 100644
index 0000000..ce60245
Binary files /dev/null and b/.vs/ConsoleApp1/CopilotIndices/17.14.1584.41681/SemanticSymbols.db differ
diff --git a/.vs/ConsoleApp1/DesignTimeBuild/.dtbcache.v2 b/.vs/ConsoleApp1/DesignTimeBuild/.dtbcache.v2
new file mode 100644
index 0000000..2629e79
Binary files /dev/null and b/.vs/ConsoleApp1/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/.vs/ConsoleApp1/FileContentIndex/84c97080-cdb3-4163-89a8-e254b7a1d178.vsidx b/.vs/ConsoleApp1/FileContentIndex/84c97080-cdb3-4163-89a8-e254b7a1d178.vsidx
new file mode 100644
index 0000000..ce4825d
Binary files /dev/null and b/.vs/ConsoleApp1/FileContentIndex/84c97080-cdb3-4163-89a8-e254b7a1d178.vsidx differ
diff --git a/.vs/ConsoleApp1/FileContentIndex/a0072a93-9218-4dee-8161-934393ad3884.vsidx b/.vs/ConsoleApp1/FileContentIndex/a0072a93-9218-4dee-8161-934393ad3884.vsidx
new file mode 100644
index 0000000..d2c7022
Binary files /dev/null and b/.vs/ConsoleApp1/FileContentIndex/a0072a93-9218-4dee-8161-934393ad3884.vsidx differ
diff --git a/.vs/ConsoleApp1/FileContentIndex/a987a522-a77a-434a-96dc-049618b147ee.vsidx b/.vs/ConsoleApp1/FileContentIndex/a987a522-a77a-434a-96dc-049618b147ee.vsidx
new file mode 100644
index 0000000..7f9d620
Binary files /dev/null and b/.vs/ConsoleApp1/FileContentIndex/a987a522-a77a-434a-96dc-049618b147ee.vsidx differ
diff --git a/.vs/ConsoleApp1/FileContentIndex/b7bedf4e-384b-433f-9359-3c90d083f92a.vsidx b/.vs/ConsoleApp1/FileContentIndex/b7bedf4e-384b-433f-9359-3c90d083f92a.vsidx
new file mode 100644
index 0000000..7c7074a
Binary files /dev/null and b/.vs/ConsoleApp1/FileContentIndex/b7bedf4e-384b-433f-9359-3c90d083f92a.vsidx differ
diff --git a/.vs/ConsoleApp1/FileContentIndex/d7ce8612-b261-4e56-b18f-72daccc6124d.vsidx b/.vs/ConsoleApp1/FileContentIndex/d7ce8612-b261-4e56-b18f-72daccc6124d.vsidx
new file mode 100644
index 0000000..3b5af02
Binary files /dev/null and b/.vs/ConsoleApp1/FileContentIndex/d7ce8612-b261-4e56-b18f-72daccc6124d.vsidx differ
diff --git a/.vs/ConsoleApp1/v17/.futdcache.v2 b/.vs/ConsoleApp1/v17/.futdcache.v2
new file mode 100644
index 0000000..be04370
Binary files /dev/null and b/.vs/ConsoleApp1/v17/.futdcache.v2 differ
diff --git a/.vs/ConsoleApp1/v17/.suo b/.vs/ConsoleApp1/v17/.suo
new file mode 100644
index 0000000..7e9eb52
Binary files /dev/null and b/.vs/ConsoleApp1/v17/.suo differ
diff --git a/.vs/ConsoleApp1/v17/DocumentLayout.backup.json b/.vs/ConsoleApp1/v17/DocumentLayout.backup.json
new file mode 100644
index 0000000..1f3f025
--- /dev/null
+++ b/.vs/ConsoleApp1/v17/DocumentLayout.backup.json
@@ -0,0 +1,100 @@
+{
+ "Version": 1,
+ "WorkspaceRootPath": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\",
+ "Documents": [
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\history.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\history.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editorstate.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editorstate.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editor.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editor.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ }
+ ],
+ "DocumentGroupContainers": [
+ {
+ "Orientation": 0,
+ "VerticalTabListWidth": 256,
+ "DocumentGroups": [
+ {
+ "DockedWidth": 231,
+ "SelectedChildIndex": 6,
+ "Children": [
+ {
+ "$type": "Bookmark",
+ "Name": "ST:129:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:128:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:129:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 1,
+ "Title": "History.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "ViewState": "AgIAAA4AAAAAAAAAAAApwBIAAAAaAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-28T16:05:45.381Z",
+ "EditorCaption": ""
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 2,
+ "Title": "EditorState.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "ViewState": "AgIAAAoAAAAAAAAAAAA7wC4AAAAAAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-28T16:05:41.957Z",
+ "EditorCaption": ""
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 3,
+ "Title": "Editor.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAAAUAAABCAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-28T16:05:32.007Z",
+ "EditorCaption": ""
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 0,
+ "Title": "Program.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\Program.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\Program.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\Program.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\Program.cs",
+ "ViewState": "AgIAAJIAAAAAAAAAAAAwwJ8AAAAVAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-24T20:52:59.773Z",
+ "EditorCaption": ""
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vs/ConsoleApp1/v17/DocumentLayout.json b/.vs/ConsoleApp1/v17/DocumentLayout.json
new file mode 100644
index 0000000..c60c228
--- /dev/null
+++ b/.vs/ConsoleApp1/v17/DocumentLayout.json
@@ -0,0 +1,100 @@
+{
+ "Version": 1,
+ "WorkspaceRootPath": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\",
+ "Documents": [
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\history.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\history.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editorstate.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editorstate.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|e:\\visual studio\\code\\visual studio 2022\\master design patterns\\consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editor.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{92CF5E55-C53C-4837-87A9-B37322E4052B}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\src\\designpatterns\\behavioral\\memento\\mytest\\editor.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ }
+ ],
+ "DocumentGroupContainers": [
+ {
+ "Orientation": 0,
+ "VerticalTabListWidth": 256,
+ "DocumentGroups": [
+ {
+ "DockedWidth": 231,
+ "SelectedChildIndex": 6,
+ "Children": [
+ {
+ "$type": "Bookmark",
+ "Name": "ST:129:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:128:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:129:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 1,
+ "Title": "History.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\History.cs",
+ "ViewState": "AgIAAA4AAAAAAAAAAAApwBQAAAAMAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-28T16:05:45.381Z",
+ "EditorCaption": ""
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 2,
+ "Title": "EditorState.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\EditorState.cs",
+ "ViewState": "AgIAAAoAAAAAAAAAAAA7wC4AAAAAAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-28T16:05:41.957Z",
+ "EditorCaption": ""
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 3,
+ "Title": "Editor.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\DesignPatterns\\Behavioral\\Memento\\MyTest\\Editor.cs",
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAAAUAAABCAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-28T16:05:32.007Z",
+ "EditorCaption": ""
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 0,
+ "Title": "Program.cs",
+ "DocumentMoniker": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\Program.cs",
+ "RelativeDocumentMoniker": "ConsoleApp1\\src\\Program.cs",
+ "ToolTip": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\ConsoleApp1\\src\\Program.cs",
+ "RelativeToolTip": "ConsoleApp1\\src\\Program.cs",
+ "ViewState": "AgIAAJIAAAAAAAAAAAAwwKwAAAARAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2026-02-24T20:52:59.773Z",
+ "EditorCaption": ""
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vs/Master Design Patterns/v17/.wsuo b/.vs/Master Design Patterns/v17/.wsuo
new file mode 100644
index 0000000..5b7a129
Binary files /dev/null and b/.vs/Master Design Patterns/v17/.wsuo differ
diff --git a/.vs/Master Design Patterns/v17/DocumentLayout.json b/.vs/Master Design Patterns/v17/DocumentLayout.json
new file mode 100644
index 0000000..a1ce7c9
--- /dev/null
+++ b/.vs/Master Design Patterns/v17/DocumentLayout.json
@@ -0,0 +1,31 @@
+{
+ "Version": 1,
+ "WorkspaceRootPath": "E:\\Visual Studio\\Code\\Visual Studio 2022\\Master Design Patterns\\",
+ "Documents": [],
+ "DocumentGroupContainers": [
+ {
+ "Orientation": 0,
+ "VerticalTabListWidth": 256,
+ "DocumentGroups": [
+ {
+ "DockedWidth": 326,
+ "SelectedChildIndex": -1,
+ "Children": [
+ {
+ "$type": "Bookmark",
+ "Name": "ST:129:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:128:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:129:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vs/ProjectEvaluation/consoleapp1.metadata.v9.bin b/.vs/ProjectEvaluation/consoleapp1.metadata.v9.bin
new file mode 100644
index 0000000..c74c328
Binary files /dev/null and b/.vs/ProjectEvaluation/consoleapp1.metadata.v9.bin differ
diff --git a/.vs/ProjectEvaluation/consoleapp1.projects.v9.bin b/.vs/ProjectEvaluation/consoleapp1.projects.v9.bin
new file mode 100644
index 0000000..6124386
Binary files /dev/null and b/.vs/ProjectEvaluation/consoleapp1.projects.v9.bin differ
diff --git a/.vs/ProjectEvaluation/consoleapp1.strings.v9.bin b/.vs/ProjectEvaluation/consoleapp1.strings.v9.bin
new file mode 100644
index 0000000..906743f
Binary files /dev/null and b/.vs/ProjectEvaluation/consoleapp1.strings.v9.bin differ
diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json
new file mode 100644
index 0000000..0d1fac6
--- /dev/null
+++ b/.vs/VSWorkspaceState.json
@@ -0,0 +1,7 @@
+{
+ "ExpandedNodes": [
+ ""
+ ],
+ "SelectedNode": "\\ConsoleApp1.sln",
+ "PreviewInSolutionExplorer": false
+}
\ No newline at end of file
diff --git a/ConsoleApp1/ConsoleApp1.csproj b/ConsoleApp1/ConsoleApp1.csproj
index 206b89a..eba0976 100644
--- a/ConsoleApp1/ConsoleApp1.csproj
+++ b/ConsoleApp1/ConsoleApp1.csproj
@@ -7,4 +7,10 @@
enable
+
+
+
+
+
+
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Authenticator.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Authenticator.cs
new file mode 100644
index 0000000..881d826
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Authenticator.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.ChainOfResponsibility.MyTest
+{
+ public class Authenticator : Handler
+ {
+ public override bool DoHandle(HTTPRequest request)
+ {
+ Console.WriteLine("Authentication");
+ var username = request.ValidatedUsername;
+ var password = request.ValidatedPassword;
+
+ //True if the user is not authenticated, false if the user is authenticated
+ return !(username == "Leif" && password == "123");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/HTTPRequest.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/HTTPRequest.cs
new file mode 100644
index 0000000..a779b36
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/HTTPRequest.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.ChainOfResponsibility.MyTest
+{
+ public class HTTPRequest
+ {
+ private string _username;
+ private string _password;
+ public string ValidatedUsername { get; set; } = "";
+ public string ValidatedPassword { get; set; } = "";
+
+
+ public HTTPRequest(string username, string password)
+ {
+ _username = username;
+ _password = password;
+ }
+
+ public string GetUsername()
+ {
+ return _username;
+ }
+
+ public string GetPassword()
+ {
+ return _password;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Handler.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Handler.cs
new file mode 100644
index 0000000..e7e370b
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Handler.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.ChainOfResponsibility.MyTest
+{
+ public abstract class Handler
+ {
+ private Handler? _nextHandler;
+
+ public Handler SetNext(Handler handler)
+ {
+ _nextHandler = handler;
+
+ return handler; // Return the next handler to allow chaining
+ }
+
+ public void Handle(HTTPRequest request)
+ {
+ if (DoHandle(request))
+ {
+ return;
+ }
+ if (_nextHandler != null)
+ {
+ _nextHandler.Handle(request);
+ }
+ }
+
+ public abstract bool DoHandle(HTTPRequest request);
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Logger.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Logger.cs
new file mode 100644
index 0000000..e6462e2
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Logger.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.ChainOfResponsibility.MyTest
+{
+ public class Logger : Handler
+ {
+ public override bool DoHandle(HTTPRequest request)
+ {
+ Console.WriteLine("Logging");
+ return false;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Validator.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Validator.cs
new file mode 100644
index 0000000..7bacf70
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/Validator.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.ChainOfResponsibility.MyTest
+{
+ public class Validator : Handler
+ {
+ public override bool DoHandle(HTTPRequest request)
+ {
+ Console.WriteLine("Validating");
+ var username = request.GetUsername();
+ var password = request.GetPassword();
+
+ request.ValidatedUsername = username.Trim();
+ request.ValidatedPassword = password.Trim();
+
+ return request.ValidatedUsername == "" || request.ValidatedPassword == "";
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/WebServer.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/WebServer.cs
new file mode 100644
index 0000000..5985371
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/ChainOfResponsibility/MyTest/WebServer.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.ChainOfResponsibility.MyTest
+{
+ public class WebServer
+ {
+ private Handler _handler;
+ public WebServer(Handler handler)
+ {
+ _handler = handler;
+ }
+
+ public void Handle(HTTPRequest request)
+ {
+ _handler.Handle(request);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/IIterator.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/IIterator.cs
new file mode 100644
index 0000000..3be0d82
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/IIterator.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Iterator.MyTest;
+
+public interface IIterator
+{
+ void Next();
+ bool HasNext();
+ void Reset();
+ T Current(); // Use generic type T for the current element
+
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/ListIterator.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/ListIterator.cs
new file mode 100644
index 0000000..a52adcc
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/ListIterator.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Iterator.MyTest
+{
+ public class ListIterator : IIterator
+ {
+ private ShoppingList _shoppingList;
+ private int _index;
+
+ public ListIterator(ShoppingList shoppingList)
+ {
+ _shoppingList = shoppingList;
+ }
+
+ public string Current()
+ {
+ return _shoppingList.GetList()[_index];
+ }
+
+ public bool HasNext()
+ {
+ return _index < _shoppingList.GetList().Count;
+ }
+
+ public void Next()
+ {
+ _index++;
+ }
+
+ public void Reset()
+ {
+ _index = 0;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/ShoppingList.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/ShoppingList.cs
new file mode 100644
index 0000000..df45fce
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Iterator/MyTest/ShoppingList.cs
@@ -0,0 +1,31 @@
+using ConsoleApp1.src.DesignPatterns.Behavioral.Iterator.GoodExample;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Iterator.MyTest
+{
+ public class ShoppingList
+ {
+ private List _list = new List();
+ public void Push(string itemName)
+ {
+ _list.Add(itemName);
+ }
+
+ public List GetList() => _list;
+ public string Pop()
+ {
+ var last = _list.Last();
+ _list.Remove(last);
+ return last;
+ }
+
+ public IIterator CreateIterator()
+ {
+ return new ListIterator(this);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/PostDialogBox.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/PostDialogBox.cs
new file mode 100644
index 0000000..be0f6a4
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/PostDialogBox.cs
@@ -0,0 +1,58 @@
+using ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest.UIFramework;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest
+{
+ public class PostDialogBox
+ {
+ private ListBox _postListBox;
+ private TextBox _titleTextBox;
+ private Button _saveButton;
+
+ public PostDialogBox()
+ {
+ _postListBox = new ListBox();
+ _titleTextBox = new TextBox();
+ _saveButton = new Button();
+ _saveButton.SetEnabled(false);
+
+ _postListBox.AddEventHandler(PostSelected);
+ _titleTextBox.AddEventHandler(TitleChanged);
+ _saveButton.Click += SaveButton_Clicked;
+ }
+
+ private void PostSelected()
+ {
+ _titleTextBox.SetText(_postListBox.GetSelection());
+ _saveButton.SetEnabled(true);
+ }
+
+ private void TitleChanged() {
+ bool isTitleEmpty = _titleTextBox.GetText() == "";
+ _saveButton.SetEnabled(!isTitleEmpty);
+ }
+
+ private void SaveButton_Clicked()
+ {
+ _titleTextBox.SetText("");
+ _saveButton.SetEnabled(false);
+ }
+
+ //Simulate action
+ public void SimulateUserInteraction()
+ {
+ _postListBox.SetSelection("Post 2");
+ // _titleTextBox.SetText("");
+ System.Console.WriteLine("Title text box: " + _titleTextBox.GetText());
+ System.Console.WriteLine("Button enabled: " + _saveButton.IsEnabled());
+ System.Console.WriteLine("Clicking saveButton...");
+ _saveButton.Click();
+ System.Console.WriteLine("Button enabled: " + _saveButton.IsEnabled());
+ System.Console.WriteLine("Title text box: " + _titleTextBox.GetText());
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/Button.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/Button.cs
new file mode 100644
index 0000000..7b69afc
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/Button.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest.UIFramework
+{
+ public class Button :UIControl
+ {
+ private bool _isEnabled;
+
+ public EventHandler Click { get; internal set; }
+
+ public bool IsEnabled() {
+ return _isEnabled;
+ }
+
+ public void SetEnabled(bool isEnabled)
+ {
+ _isEnabled = isEnabled;
+ NotifyEventHandlers();
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/EventHandler.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/EventHandler.cs
new file mode 100644
index 0000000..439ff09
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/EventHandler.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest.UIFramework
+{
+ public delegate void EventHandler();
+
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/ListBox.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/ListBox.cs
new file mode 100644
index 0000000..fd7bafa
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/ListBox.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest.UIFramework
+{
+ public class ListBox :UIControl
+ {
+ private string _selection= "";
+
+ public string GetSelection()
+ {
+ return _selection;
+ }
+
+ public void SetSelection(string selection)
+ {
+ _selection = selection;
+ NotifyEventHandlers();
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/TextBox.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/TextBox.cs
new file mode 100644
index 0000000..a5397f0
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/TextBox.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest.UIFramework
+{
+ public class TextBox :UIControl
+ {
+ private string _text = "";
+
+ public string GetText()
+ {
+ return _text;
+ }
+ public void SetText(string content)
+ {
+ _text = content;
+ NotifyEventHandlers(); ;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/UIControl.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/UIControl.cs
new file mode 100644
index 0000000..922636d
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Mediator/MyTest/UIFramework/UIControl.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest.UIFramework
+{
+ public class UIControl
+ {
+ private List _eventHandlers = new List();
+
+ public void AddEventHandler(EventHandler handler)
+ {
+ _eventHandlers.Add(handler);
+ }
+
+ public void NotifyEventHandlers()
+ {
+ foreach (var handler in _eventHandlers)
+ {
+ handler();
+ }
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/Editor.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/Editor.cs
new file mode 100644
index 0000000..2962bb2
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/Editor.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Memento.MyTest
+{
+ // Originator
+ public class Editor
+ {
+ public string Title { get; set; }
+ public string Content { get; set; }
+
+ public EditorState CreateState()
+ {
+ return new EditorState(Title, Content);
+ }
+
+ public void Restore(EditorState state)
+ {
+ Title = state.GetTitle();
+ Content = state.GetContent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/EditorState.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/EditorState.cs
new file mode 100644
index 0000000..19dd402
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/EditorState.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.ConstrainedExecution;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Memento.MyTest
+{
+// Memento
+public class EditorState
+{
+ // Editor state data:
+ // `readonly` so once created we cannot change it, adding robustness to our code.
+ private readonly string _title;
+ private readonly string _content;
+
+ // State meta data:
+ private readonly DateTime _stateCreatedAt;
+
+
+ public EditorState(string title, string content)
+ {
+ _title = title;
+ _content = content;
+ _stateCreatedAt = DateTime.Now;
+ }
+
+ public string GetTitle()
+ {
+ return _title;
+ }
+
+ public string GetContent()
+ {
+ return _content;
+ }
+
+ // The rest of the methods are used by the CareTaker (History) to display meta data:
+ public DateTime GetDate()
+ {
+ return _stateCreatedAt;
+ }
+
+ public string GetName()
+ {
+ return $"{_stateCreatedAt} / ({_title})";
+ }
+}
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/History.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/History.cs
new file mode 100644
index 0000000..5c3568c
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Memento/MyTest/History.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Memento.MyTest
+{
+ // Caretaker
+ public class History
+ {
+ private List _states = new List();
+ private Editor _editor;
+
+ public History(Editor editor)
+ {
+ _editor = editor;
+ }
+
+ public void Backup()
+ {
+ _states.Add(_editor.CreateState());
+ }
+
+ public void Undo()
+ {
+ if (_states.Count == 0)
+ {
+ return;
+ }
+
+ EditorState prevState = _states.Last();
+ _states.Remove(prevState);
+
+ _editor.Restore(prevState);
+ }
+
+ public void ShowHistory()
+ {
+ Console.WriteLine("\nHistory: Here's the list of mementos:");
+
+ foreach (var state in _states)
+ {
+ Console.WriteLine(state.GetName());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/BarChart.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/BarChart.cs
new file mode 100644
index 0000000..f4c9778
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/BarChart.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Observer.MyTest
+{
+ public class BarChart : IObserver
+ {
+ private DataSource _dataSource;
+
+ public BarChart(DataSource dataSource)
+ {
+ _dataSource = dataSource;
+ }
+ public void Update()
+ {
+ Console.WriteLine("BarChart updated");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/DataSource.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/DataSource.cs
new file mode 100644
index 0000000..5283051
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/DataSource.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Observer.MyTest
+{
+ public class DataSource :Subject
+ {
+ private List _values = new List();
+ public List GetValues()
+ {
+ return _values;
+ }
+ public void SetValues(List values)
+ {
+ _values = values;
+
+ NotifyObservers();
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/IObserver.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/IObserver.cs
new file mode 100644
index 0000000..b0b3298
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/IObserver.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Observer.MyTest
+{
+ public interface IObserver
+ {
+ void Update();
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Sheet2.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Sheet2.cs
new file mode 100644
index 0000000..4341072
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Sheet2.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Observer.MyTest
+{
+ public class Sheet2 : IObserver
+ {
+ private int _total;
+ private DataSource _dataSource;
+
+ public int GetTotal()
+ {
+ return _total;
+ }
+
+ public Sheet2(DataSource dataSource)
+ {
+ _dataSource = dataSource;
+ }
+ public int CalculateTotal(List values)
+ {
+ var sum = 0;
+ foreach (var value in values)
+ {
+ sum += value;
+ }
+ return sum;
+ }
+ public void Update()
+ {
+ _total = CalculateTotal(_dataSource.GetValues());
+ Console.WriteLine($"Sheet2 updated to { _total } ");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Sheet3.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Sheet3.cs
new file mode 100644
index 0000000..a695271
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Sheet3.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Observer.MyTest
+{
+ public class Sheet3 : IObserver
+ {
+ private int _average;
+ private DataSource _dataSource;
+
+ public int GetTotal()
+ {
+ return _average;
+ }
+
+ public Sheet3(DataSource dataSource)
+ {
+ _dataSource = dataSource;
+ }
+ public int CalculateAverage(List values)
+ {
+ var sum = 0;
+ foreach (var value in values)
+ {
+ sum += value;
+ }
+ return sum / values.Count;
+ }
+ public void Update()
+ {
+ _average = CalculateAverage(_dataSource.GetValues());
+ Console.WriteLine($"Sheet3 updated to { _average} ");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Subject.cs b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Subject.cs
new file mode 100644
index 0000000..02b8d69
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Behavioral/Observer/MyTest/Subject.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Behavioral.Observer.MyTest
+{
+ public abstract class Subject
+ {
+ private List _observers = new List();
+
+ public void AddObserver(IObserver observer)
+ {
+ _observers.Add(observer);
+ }
+
+ public void RemoveObserver(IObserver observer)
+ {
+ _observers.Remove(observer);
+ }
+
+ public void NotifyObservers()
+ {
+ foreach (var observer in _observers)
+ {
+ observer.Update();
+ }
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/Controller.cs b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/Controller.cs
new file mode 100644
index 0000000..ee64e2e
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/Controller.cs
@@ -0,0 +1,23 @@
+using ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.Blade;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.BackendFramework
+{
+ public abstract class Controller
+ {
+ public void Render(string fileName, Dictionary data)
+ {
+ var viewEngine = CreateViewEngine();
+ var html = viewEngine.Render(fileName, data);
+ System.Console.WriteLine(html);
+ }
+
+ // By default, the view engine for our framework will be Blade
+ protected virtual ViewEngine CreateViewEngine()
+ {
+ return new BladeViewEngine();
+ }
+
+ // Note that we could also implement our template method as an abstract method, and so providing no default view engine, and forcing the developer to select one.
+ // protected abstract ViewEngine CreateViewEngine();
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/TwigController.cs b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/TwigController.cs
new file mode 100644
index 0000000..cc24d8e
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/TwigController.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.TwigFramwork;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.BackendFramework
+{
+ public class TwigController : Controller
+ {
+ protected override ViewEngine CreateViewEngine()
+ {
+ return new TwigViewEngine();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/ViewEngine.cs b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/ViewEngine.cs
new file mode 100644
index 0000000..119b119
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BackendFramework/ViewEngine.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.BackendFramework
+{
+ public interface ViewEngine
+ {
+ string Render(string fileName, Dictionary data);
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BladeView/BladeViewEngine.cs b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BladeView/BladeViewEngine.cs
new file mode 100644
index 0000000..99a2043
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/BladeView/BladeViewEngine.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.BackendFramework;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.Blade
+{
+ public class BladeViewEngine : ViewEngine
+ {
+ public string Render(string fileName, Dictionary data)
+ {
+ return "View rendered from " + fileName + " by Blade";
+ }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/OrdersController.cs b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/OrdersController.cs
new file mode 100644
index 0000000..c8e0fd7
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/OrdersController.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.TwigFramwork;
+using ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.BackendFramework;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest
+{
+ public class OrdersController : TwigController
+ {
+ public void ListOrders()
+ {
+ // Simulate fetching users previous orders from db
+ var orders = new Dictionary{
+ {"Red socks", "$12.98"},
+ {"Black socks", "$12.98"},
+ {"Pink T-shirt", "29.00"}
+ };
+
+ Render("orders.php", orders);
+ }
+
+ public void GetOrder(int id)
+ {
+ // Simulate getting single order by id from db
+ var order = new Dictionary{
+ {"Red Socks", "$12.98"}
+ };
+
+ Render("order.php", order);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/TwigView/TwigViewEngine.cs b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/TwigView/TwigViewEngine.cs
new file mode 100644
index 0000000..b774197
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/FactoryMethod/MyTest/TwigView/TwigViewEngine.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.BackendFramework;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest.TwigFramwork
+{
+ public class TwigViewEngine : ViewEngine
+ {
+ public string Render(string fileName, Dictionary data)
+ {
+ return "View rendered from " + fileName + " by Twig";
+ }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/Circle.cs b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/Circle.cs
new file mode 100644
index 0000000..ac8f0f1
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/Circle.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.Prototype.MyTest
+{
+ public class Circle : IShape
+ {
+ public int Radius { get; set; } = 5;
+
+ public void Draw()
+ {
+ Console.WriteLine("Drawing Circle");
+ }
+ public string GetShapeInfo()
+ {
+ return $"Circle with radius: {Radius}";
+ }
+
+ public IShape Duplicate()
+ {
+ var newCircle = new Circle();
+ newCircle.Radius = Radius;
+
+ return newCircle;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/IShape.cs b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/IShape.cs
new file mode 100644
index 0000000..c13ca6d
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/IShape.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.Prototype.MyTest
+{
+ public interface IShape
+ {
+ void Draw();
+ IShape Duplicate();
+ string GetShapeInfo();
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/Rectangle.cs b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/Rectangle.cs
new file mode 100644
index 0000000..6c6e614
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/Rectangle.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.Prototype.MyTest
+{
+ public class Rectangle : IShape
+ {
+ public int Width { get; set; } = 10;
+ public int Height { get; set; } = 5;
+
+ public void Draw()
+ {
+ Console.WriteLine("Drawing Rectangle");
+ }
+ public IShape Duplicate()
+ {
+ var newRectangle = new Rectangle();
+ newRectangle.Width = this.Width;
+ newRectangle.Height = this.Height;
+
+ return newRectangle;
+ }
+
+ public string GetShapeInfo()
+ {
+ return $"Rectangle with width: {Width} and height {Height}";
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/ShapeActions.cs b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/ShapeActions.cs
new file mode 100644
index 0000000..8958dd3
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/Prototype/MyTest/ShapeActions.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.Prototype.MyTest
+{
+ public class ShapeActions
+ {
+ public IShape Duplicate(IShape shape)
+ {
+ Console.WriteLine($"Duplicating shape { shape.GetShapeInfo() } ");
+ return shape.Duplicate();
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/Singleton/MyTest/AppSettings.cs b/ConsoleApp1/src/DesignPatterns/Creational/Singleton/MyTest/AppSettings.cs
new file mode 100644
index 0000000..ebe3c49
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/Singleton/MyTest/AppSettings.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.Singleton.MyTest;
+
+public class AppSettings
+{
+ private static AppSettings _instance;
+
+ private Dictionary _settings = new Dictionary();
+
+ private AppSettings()
+ {
+ // Private constructor to prevent instantiation
+ }
+
+ public static AppSettings GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new AppSettings();
+ }
+
+ return _instance;
+ }
+
+ public object Get(string key)
+ {
+ if (!_settings.ContainsKey(key))
+ return null;
+ return _settings[key];
+ }
+
+ public void Set(string key, object value)
+ {
+ _settings[key] = value;
+ }
+}
+
diff --git a/ConsoleApp1/src/DesignPatterns/Creational/Singleton/MyTest/Test.cs b/ConsoleApp1/src/DesignPatterns/Creational/Singleton/MyTest/Test.cs
new file mode 100644
index 0000000..252b4d3
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Creational/Singleton/MyTest/Test.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Creational.Singleton.MyTest
+{
+ public class Test
+ {
+ public static void Run()
+ {
+ var settings = AppSettings.GetInstance();
+ System.Console.WriteLine(settings.Get("AppName")); // set app_creator in Main and it will return same value when this Run() method is called
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/BlackAndWhiteColor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/BlackAndWhiteColor.cs
index 5fa2032..209118d 100644
--- a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/BlackAndWhiteColor.cs
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/BlackAndWhiteColor.cs
@@ -5,7 +5,7 @@
namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter
{
- public class BlackAndWhiteColor : Color
+ public class BlackAndWhiteColor : IColor
{
public void Apply(Video video)
{
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/Color.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/IColor.cs
similarity index 88%
rename from ConsoleApp1/src/DesignPatterns/Structural/Adapter/Color.cs
rename to ConsoleApp1/src/DesignPatterns/Structural/Adapter/IColor.cs
index 85329d9..15872f6 100644
--- a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/Color.cs
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/IColor.cs
@@ -5,7 +5,7 @@
namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter
{
- public interface Color
+ public interface IColor
{
void Apply(Video video);
}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MidnightPurpleColor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MidnightPurpleColor.cs
index 23d7947..56885b8 100644
--- a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MidnightPurpleColor.cs
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MidnightPurpleColor.cs
@@ -5,7 +5,7 @@
namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter
{
- public class MidnightColor : Color
+ public class MidnightColor : IColor
{
public void Apply(Video video)
{
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/BlackAndWhiteColor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/BlackAndWhiteColor.cs
new file mode 100644
index 0000000..7fcbcb7
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/BlackAndWhiteColor.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest
+{
+ public class BlackAndWhiteColor : IColor
+ {
+ public void Apply(Video video)
+ {
+ Console.WriteLine("Applying Black and White color"); ;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/Color.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/Color.cs
new file mode 100644
index 0000000..a274856
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/Color.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest
+{
+ public interface IColor
+ {
+ void Apply(Video video);
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/MidnightPurpleColor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/MidnightPurpleColor.cs
new file mode 100644
index 0000000..e0cf1b5
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/MidnightPurpleColor.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest
+{
+ public class MidnightPurpleColor :IColor
+ {
+ public void Apply(Video video)
+ {
+ Console.WriteLine("Applying Midnight Purple color"); ;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/RainbowAdaptor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/RainbowAdaptor.cs
new file mode 100644
index 0000000..a179ea6
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/RainbowAdaptor.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest
+{
+ public class RainbowAdaptor : IColor
+ {
+ public void Apply(Video video)
+ {
+ Console.WriteLine("Applying Rainbow");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/RainbowColor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/RainbowColor.cs
new file mode 100644
index 0000000..adc3c4c
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/RainbowColor.cs
@@ -0,0 +1,24 @@
+using ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest.ThridPartyColorLibrary;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest
+{
+ public class RainbowColor :IColor
+ {
+ private Rainbow _rainbow; // Third party library class
+ public RainbowColor(Rainbow rainbow)
+ {
+ _rainbow = rainbow;
+ }
+ public void Apply(Video video)
+ {
+ _rainbow.Setup();
+ _rainbow.Update(video);
+ Console.WriteLine("Applying Rainbow color");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/ThridPartyColorLibrary/Rainbow.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/ThridPartyColorLibrary/Rainbow.cs
new file mode 100644
index 0000000..8ac8bfd
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/ThridPartyColorLibrary/Rainbow.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest.ThridPartyColorLibrary
+{
+ public class Rainbow
+ {
+ public void Setup()
+ {
+ System.Console.WriteLine("Setting up rainbow filter");
+ }
+
+ public void Update(Video video)
+ {
+ System.Console.WriteLine("Applying rainbow filter to video");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/Video.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/Video.cs
new file mode 100644
index 0000000..9ffbeaf
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/Video.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest
+{
+ public class Video
+ {
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/VideoEditor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/VideoEditor.cs
new file mode 100644
index 0000000..435f429
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/MyTest/VideoEditor.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest
+{
+ public class VideoEditor
+ {
+ private Video _video;
+
+ public VideoEditor(Video video)
+ {
+ _video = video;
+ }
+
+ public void ApplyColor(IColor color)
+ {
+ color.Apply(_video);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowAdapter.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowAdapter.cs
index 14c0533..d58d18d 100644
--- a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowAdapter.cs
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowAdapter.cs
@@ -11,7 +11,7 @@ namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter
// Problem: this approach isn't as flexible as using composition, because, in C#, a class can only extend one class; so
// if Color was an abstract class, we wouldn't be able to extend it. In this case, we're OK, because Color is an interface,
// but you can see that inheritance is less flexible than composition, and therefore composition should be preferred.
- public class RainbowAdapter : Rainbow, Color
+ public class RainbowAdapter : Rainbow, IColor
{
public void Apply(Video video)
{
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowColor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowColor.cs
index 575bccf..2148edf 100644
--- a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowColor.cs
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/RainbowColor.cs
@@ -7,7 +7,7 @@
namespace ConsoleApp1.src.DesignPatterns.Structural.Adapter
{
// Adapter class. Rainbow is the adaptee
- public class RainbowColor : Color
+ public class RainbowColor : IColor
{
private Rainbow _rainbow; // "composition" -- RainbowColor is composed of, "has a", Rainbow. See RainbowAdapter for inheritance alternative.
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/ThirdPartyColorLibrary/Rainbow.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/ThirdPartyColorLibrary/Rainbow.cs
index 66d4514..cdd06c9 100644
--- a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/ThirdPartyColorLibrary/Rainbow.cs
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/ThirdPartyColorLibrary/Rainbow.cs
@@ -14,7 +14,7 @@ public void Setup()
public void Update(Video video)
{
- System.Console.WriteLine("Applying rainbow filter to video");
+ System.Console.WriteLine("Updating rainbow filter to video");
}
}
}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/VideoEditor.cs b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/VideoEditor.cs
index ca97742..1cc6c4f 100644
--- a/ConsoleApp1/src/DesignPatterns/Structural/Adapter/VideoEditor.cs
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Adapter/VideoEditor.cs
@@ -14,7 +14,7 @@ public VideoEditor(Video video)
_video = video;
}
- public void ApplyColor(Color color)
+ public void ApplyColor(IColor color)
{
color.Apply(_video);
}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/AdvancedRemote.cs b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/AdvancedRemote.cs
new file mode 100644
index 0000000..e432f01
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/AdvancedRemote.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Bridge.MyTest
+{
+ public class AdvancedRemoteControl : RemoteControl
+ {
+ public AdvancedRemoteControl(Device device) : base(device)
+ {
+ }
+
+ public void SetChannel(int channel)
+ {
+ System.Console.WriteLine("Setting channel to " + channel);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/Device.cs b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/Device.cs
new file mode 100644
index 0000000..2ec06c1
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/Device.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Bridge.MyTest
+{
+ public interface Device
+ {
+ void TurnOn();
+
+ void TurnOff();
+
+ void SetChannel(int channel);
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/LGRadio.cs b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/LGRadio.cs
new file mode 100644
index 0000000..b0af4a7
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/LGRadio.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Bridge.MyTest
+{
+ public class LGRadio : Device
+ {
+ public void TurnOff()
+ {
+ System.Console.WriteLine("Turning LG radio off");
+ }
+
+ public void TurnOn()
+ {
+ System.Console.WriteLine("Turning LG radio on");
+ }
+
+ public void SetChannel(int channel)
+ {
+ System.Console.WriteLine("Setting LG radio channel to " + channel);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/RemoteControl.cs b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/RemoteControl.cs
new file mode 100644
index 0000000..3433ae1
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/RemoteControl.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Bridge.MyTest
+{
+ public class RemoteControl
+ {
+ private Device _device;
+
+ public RemoteControl(Device device)
+ {
+ _device = device;
+ }
+
+ public void TurnOn()
+ {
+ _device.TurnOn();
+ }
+
+ public void TurnOff()
+ {
+ _device.TurnOff();
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/SonyRadio.cs b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/SonyRadio.cs
new file mode 100644
index 0000000..0024edd
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Bridge/MyTest/SonyRadio.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Bridge.MyTest
+{
+ public class SonyRadio :Device
+ {
+ public void TurnOff()
+ {
+ System.Console.WriteLine("Turning Sony radio off");
+ }
+ public void TurnOn()
+ {
+ System.Console.WriteLine("Turning Sony radio on");
+ }
+ public void SetChannel(int channel)
+ {
+ System.Console.WriteLine("Setting Sony radio channel to " + channel);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Box.cs b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Box.cs
new file mode 100644
index 0000000..05e4651
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Box.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Composite.MyTest
+{
+ public class Box :IItem
+ {
+ List _items = new List();
+
+ public void AddItem(IItem item)
+ {
+ _items.Add(item);
+ }
+
+ public int GetPrice()
+ {
+ int totalPrice = 0;
+ foreach (var item in _items)
+ {
+ totalPrice += item.GetPrice();
+ }
+ return totalPrice;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/IItem.cs b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/IItem.cs
new file mode 100644
index 0000000..2a764eb
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/IItem.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Composite.MyTest
+{
+ public interface IItem
+ {
+
+ int GetPrice();
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Keyboard.cs b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Keyboard.cs
new file mode 100644
index 0000000..5183b1f
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Keyboard.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Composite.MyTest
+{
+ public class Keyboard : IItem
+ {
+ private int _price;
+
+ public Keyboard(int price)
+ {
+ _price = price;
+ }
+
+ public int GetPrice()
+ {
+ return _price;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Microphone.cs b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Microphone.cs
new file mode 100644
index 0000000..2139933
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Microphone.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Composite.MyTest
+{
+ public class Microphone :IItem
+ {
+ private int _price;
+
+ public Microphone(int price)
+ {
+ _price = price;
+ }
+
+ public int GetPrice()
+ {
+ return _price;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Mouse.cs b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Mouse.cs
new file mode 100644
index 0000000..18a086e
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Composite/MyTest/Mouse.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Composite.MyTest
+{
+ public class Mouse :IItem
+ {
+ private int _price;
+ public Mouse(int price)
+ {
+ _price = price;
+ }
+ public int GetPrice()
+ {
+ return _price;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/CloudData.cs b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/CloudData.cs
new file mode 100644
index 0000000..e4b9596
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/CloudData.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Decorator.MyTest
+{
+ public class CloudData : IData
+ {
+ private string _url;
+
+ public CloudData(string url)
+ {
+ _url = url;
+ }
+ public void SaveData(string data)
+ {
+ Console.WriteLine($"Saving data to the cloud: {data} using {_url} ");
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/CompressionDecorator.cs b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/CompressionDecorator.cs
new file mode 100644
index 0000000..29c009c
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/CompressionDecorator.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Decorator.MyTest
+{
+ public class CompressionDecorator :DataDecorator
+ {
+ public CompressionDecorator(IData data) : base(data)
+ {
+ }
+ public override void SaveData(string data)
+ {
+ // Simulate compression by just indicating that the data is compressed
+ var compressedData = Compress(data);
+ base._data.SaveData(compressedData);
+ Console.WriteLine("Compressing data...");
+ }
+
+ public string Compress(string data)
+ {
+ // In a real implementation, you would have actual compression logic here.
+ return data.Substring(0,9);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/DataDecorator.cs b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/DataDecorator.cs
new file mode 100644
index 0000000..9fed187
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/DataDecorator.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Decorator.MyTest
+{
+ public abstract class DataDecorator : IData
+ {
+ protected IData _data;
+
+ public DataDecorator(IData data)
+ {
+ _data = data;
+ }
+
+ public abstract void SaveData(string data);
+
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/EncryptionDecorator.cs b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/EncryptionDecorator.cs
new file mode 100644
index 0000000..2e48834
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/EncryptionDecorator.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Decorator.MyTest
+{
+ public class EncryptionDecorator:DataDecorator
+ {
+ public EncryptionDecorator(IData data) : base(data)
+ {
+ }
+ public override void SaveData(string data)
+ {
+ // Simulate encryption by just indicating that the data is encrypted
+ var encryptedData = Encrypt(data);
+ base._data.SaveData(encryptedData);
+ Console.WriteLine("Encrypting data...");
+ }
+ public string Encrypt(string data)
+ {
+ // In a real implementation, you would have actual encryption logic here.
+ return Convert.ToBase64String(Encoding.UTF8.GetBytes(data));
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/IData.cs b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/IData.cs
new file mode 100644
index 0000000..4d00af2
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Decorator/MyTest/IData.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Decorator.MyTest
+{
+ public interface IData
+ {
+ void SaveData(string data);
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Authenticate.cs b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Authenticate.cs
new file mode 100644
index 0000000..f5e0d21
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Authenticate.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Facade.MyTest
+{
+ public class Authenticate
+ {
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Inventory.cs b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Inventory.cs
new file mode 100644
index 0000000..e59c600
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Inventory.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Facade.MyTest
+{
+ public class Inventory
+ {
+ public bool CheckInventory(string itemId)
+ {
+ return true; // just return true to keep example simple
+ }
+
+ public void ReduceInventory(string itemId, int amount)
+ {
+ System.Console.WriteLine("Reducing inventory of " + itemId + " by " + amount);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderFulfillment.cs b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderFulfillment.cs
new file mode 100644
index 0000000..7f49160
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderFulfillment.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Facade.MyTest
+{
+ public class OrderFulfillment
+ {
+ private Inventory _inventory;
+
+ public OrderFulfillment(Inventory inventory)
+ {
+ _inventory = inventory;
+ }
+
+ public void Fulfill(string name, string address, string[] items)
+ {
+ System.Console.WriteLine("Inserting order into database");
+ foreach (var item in items)
+ {
+ _inventory.ReduceInventory(item, 1);
+ }
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderRequest.cs b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderRequest.cs
new file mode 100644
index 0000000..c796dd6
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderRequest.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Facade.MyTest
+{
+ public class OrderRequest
+ {
+ public string Name { get; } = "Leif";
+ public string CardNumber { get; } = "12345";
+ public float Amount { get; } = 20.99f;
+ public string Address { get; } = "Danmarksgade 4, Vejle";
+ // item ids user wants to order
+ public string[] ItemIds { get; } = { "123", "423", "555", "989" };
+ }
+}
+
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderService.cs b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderService.cs
new file mode 100644
index 0000000..e43c74d
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/OrderService.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Facade.MyTest
+{
+ public class OrderService
+ {
+ public void Order(OrderRequest orderRequest)
+ {
+ var auth = new Authenticate();
+
+ var inventory = new Inventory();
+ foreach (var id in orderRequest.ItemIds)
+ {
+ inventory.CheckInventory(id);
+ }
+
+ var payment = new Payment(orderRequest.Name, orderRequest.CardNumber, orderRequest.Amount);
+ payment.Pay();
+
+ var orderFulfillment = new OrderFulfillment(inventory);
+ orderFulfillment.Fulfill(orderRequest.Name, orderRequest.Address, orderRequest.ItemIds);
+
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Payment.cs b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Payment.cs
new file mode 100644
index 0000000..3f0c3e3
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Facade/MyTest/Payment.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Facade.MyTest
+{
+ public class Payment
+ {
+ private readonly string _name;
+ private readonly string _cardNumber;
+ private readonly float _amount;
+
+ public Payment(string name, string cardNumber, float amount)
+ {
+ _name = name;
+ _cardNumber = cardNumber;
+ _amount = amount;
+ }
+
+ public void Pay()
+ {
+ System.Console.WriteLine("Charging card with name " + _name);
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/Crop.cs b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/Crop.cs
new file mode 100644
index 0000000..523952b
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/Crop.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Flyweight.MyTest;
+
+public class Crop
+{
+ private int _x;
+ private int _y;
+ private CropIcon _cropIcon;
+
+ public Crop(int x, int y, CropIcon cropIcon)
+ {
+ _x = x;
+ _y = y;
+ _cropIcon = cropIcon;
+ }
+
+ public void Render()
+ {
+ // here, we would use the crop icon to draw the crop at the specified location
+ Console.WriteLine($"Drawing crop at ({_x}, {_y}) with icon {_cropIcon.GetCropType()}");
+ }
+
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropIcon.cs b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropIcon.cs
new file mode 100644
index 0000000..8190391
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropIcon.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Flyweight.MyTest
+{
+ public class CropIcon
+ {
+ private readonly CropType _cropType;
+ private readonly byte[] _icon;
+
+ public CropIcon(CropType cropType, byte[] icon)
+ {
+ _cropType = cropType;
+ _icon = icon;
+ }
+
+ public CropType GetCropType()
+ {
+ return _cropType;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropIconFactory.cs b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropIconFactory.cs
new file mode 100644
index 0000000..a0680fc
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropIconFactory.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Flyweight.MyTest
+{
+ public class CropIconFactory
+ {
+ private Dictionary _icons = new Dictionary(); //Cache
+
+ public CropIcon GetCropIcon(CropType cropType)
+ {
+ if (!_icons.ContainsKey(cropType))
+ {
+ var icon = new CropIcon( cropType, null ); // In a real implementation, you would load the icon data from a file or database
+ _icons.Add(cropType, icon);
+ }
+ return _icons[cropType];
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropService.cs b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropService.cs
new file mode 100644
index 0000000..0c2632c
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropService.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Flyweight.MyTest
+{
+ public class CropService
+ {
+ private readonly CropIconFactory _cropIconFactory;
+ public CropService(CropIconFactory cropIconFactory)
+ {
+ _cropIconFactory = cropIconFactory;
+ }
+ public List GetCrops()
+ {
+ // In a real implementation, you would retrieve crop data from a database or other data source
+ List crops = new List {
+ new Crop(10, 20, _cropIconFactory.GetCropIcon(CropType.Wheat)),
+ new Crop(30, 40, _cropIconFactory.GetCropIcon(CropType.Potato)),
+ new Crop(31, 45, _cropIconFactory.GetCropIcon(CropType.Carrot)),
+ new Crop(40, 47, _cropIconFactory.GetCropIcon(CropType.Potato)),
+ new Crop(50, 58, _cropIconFactory.GetCropIcon(CropType.Wheat))
+ };
+
+ return crops;
+ }
+ }
+}
+
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropType.cs b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropType.cs
new file mode 100644
index 0000000..4a8dec9
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Flyweight/MyTest/CropType.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Flyweight.MyTest
+{
+ public enum CropType
+ {
+ Potato,
+ Carrot,
+ Wheat
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/ThirdPartyVideoLib/Video.cs b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/ThirdPartyVideoLib/Video.cs
new file mode 100644
index 0000000..81de86c
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/ThirdPartyVideoLib/Video.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Proxy.MyTest.ThirdPartyVideoLib
+{
+ public interface Video
+ {
+ void Render();
+
+
+ string GetVideoId();
+ }
+
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/ThirdPartyVideoLib/YouTubeVideo.cs b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/ThirdPartyVideoLib/YouTubeVideo.cs
new file mode 100644
index 0000000..b2920aa
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/ThirdPartyVideoLib/YouTubeVideo.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Proxy.MyTest.ThirdPartyVideoLib
+{
+ public class YouTubeVideo : Video
+ {
+ private string _videoId;
+
+
+ public YouTubeVideo(string videoId)
+ {
+ _videoId = videoId;
+ Download();
+ }
+
+
+ private void Download()
+ {
+ System.Console.WriteLine("Downloading video with id " + _videoId + " from YouTube API");
+ }
+
+
+ public void Render()
+ {
+ System.Console.WriteLine("Rendering video " + _videoId);
+ }
+
+
+ public string GetVideoId()
+ {
+ return _videoId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/VideoList.cs b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/VideoList.cs
new file mode 100644
index 0000000..8756f31
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/VideoList.cs
@@ -0,0 +1,27 @@
+using ConsoleApp1.src.DesignPatterns.Structural.Proxy.MyTest.ThirdPartyVideoLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Proxy.MyTest
+{
+ public class VideoList
+ {
+ private Dictionary _videoList = new Dictionary();
+
+
+ public void Add(Video video)
+ {
+ _videoList.Add(video.GetVideoId(), video);
+ }
+
+
+ public void Watch(string videoId)
+ {
+ var video = _videoList[videoId];
+ video.Render();
+ }
+ }
+}
diff --git a/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/YouTubeVideoProxy.cs b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/YouTubeVideoProxy.cs
new file mode 100644
index 0000000..3b505ae
--- /dev/null
+++ b/ConsoleApp1/src/DesignPatterns/Structural/Proxy/MyTest/YouTubeVideoProxy.cs
@@ -0,0 +1,34 @@
+using ConsoleApp1.src.DesignPatterns.Structural.Proxy.MyTest.ThirdPartyVideoLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp1.src.DesignPatterns.Structural.Proxy.MyTest
+{
+ public class YouTubeVideoProxy : Video
+ {
+ private string _videoId;
+ private YouTubeVideo _youTubeVideo;
+
+ public YouTubeVideoProxy(string videoId)
+ {
+ _videoId = videoId;
+ }
+ public string GetVideoId()
+ {
+ return _videoId;
+ }
+
+ public void Render()
+ {
+ if (_youTubeVideo == null)
+ {
+ _youTubeVideo = new YouTubeVideo(_videoId);
+ }
+ _youTubeVideo.Render();
+ ;
+ }
+ }
+}
diff --git a/ConsoleApp1/src/Program.cs b/ConsoleApp1/src/Program.cs
index 473aaf6..1f31251 100644
--- a/ConsoleApp1/src/Program.cs
+++ b/ConsoleApp1/src/Program.cs
@@ -1 +1,240 @@
-System.Console.WriteLine("Hello world");
\ No newline at end of file
+
+#region Creational Pattern
+
+#region Factory Method
+
+//using ConsoleApp1.src.DesignPatterns.Creational.FactoryMethod.MyTest;
+
+#endregion
+
+#region Singleton
+//using ConsoleApp1.src.DesignPatterns.Creational.Singleton.MyTest;
+
+//var appSettings = AppSettings.GetInstance();
+//appSettings.Set("AppName", "Singleton");
+//appSettings.Set("Version", "1.0.0");
+//Console.WriteLine($"App Name: {appSettings.Get("AppName")}");
+
+//Test.Run();
+#endregion
+
+#region Prototype
+//using ConsoleApp1.src.DesignPatterns.Creational.Prototype.MyTest;
+//var circle = new Circle();
+//circle.Radius = 20;
+//circle.Draw();
+//var rectangle = new Rectangle();
+//rectangle.Width = 12;
+//rectangle.Height = 6;
+//rectangle.Draw();
+
+//var shapeactions = new ShapeActions();
+//IShape duplicatedCircle = shapeactions.Duplicate(circle);
+//IShape duplicatedRectangle = shapeactions.Duplicate(rectangle);
+
+//Console.WriteLine(duplicatedCircle.GetShapeInfo());
+#endregion
+
+#endregion
+
+#region Structural Pattern
+
+#region Bridge => the Device is the bridge
+//using ConsoleApp1.src.DesignPatterns.Structural.Bridge.MyTest;
+//var lgRemoteControl = new RemoteControl(new LGRadio());
+//lgRemoteControl.TurnOn();
+//lgRemoteControl.TurnOff();
+
+//var advancedRemoteControl = new AdvancedRemoteControl(new SonyRadio());
+//advancedRemoteControl.TurnOn();
+//advancedRemoteControl.SetChannel(23);
+//advancedRemoteControl.TurnOff();
+#endregion
+
+#region Proxy
+//using ConsoleApp1.src.DesignPatterns.Structural.Proxy.MyTest;
+
+//var videoList = new VideoList();
+//string[] videoIds = { "Starwars 1", "Starwars 2", "Starwars 3", "Starwars 4" };
+
+//foreach (var videoId in videoIds)
+//{
+// videoList.Add(new YouTubeVideoProxy(videoId));
+//}
+
+//videoList.Watch("Starwars 3");
+#endregion
+
+#region Facade
+//using ConsoleApp1.src.DesignPatterns.Structural.Facade.MyTest;
+
+//var orderRequest = new OrderRequest();
+//var orderservice = new OrderService();
+//orderservice.Order(orderRequest);
+#endregion
+
+#region Decorator
+//using ConsoleApp1.src.DesignPatterns.Structural.Decorator.MyTest;
+//var url = "https://mycloudstorage.com";
+//var data = "Who is chopping with THREE CHAINSAW!! One of them in each hand, and the last one in their mouth";
+//var compress = true;
+//var encrypt = false;
+
+//IData cloudData = new CloudData(url);
+//if (compress)
+//{
+// cloudData = new CompressionDecorator(cloudData);
+//}
+//if (encrypt)
+//{
+// cloudData = new EncryptionDecorator(cloudData);
+//}
+//cloudData.SaveData(data);
+#endregion
+
+#region Flyweight
+//using ConsoleApp1.src.DesignPatterns.Structural.Flyweight.MyTest;
+
+//var cropservice = new CropService(new CropIconFactory());
+
+//foreach (var crop in cropservice.GetCrops())
+//{
+// crop.Render();
+//}
+#endregion
+
+#region Composite
+//using ConsoleApp1.src.DesignPatterns.Structural.Composite.MyTest;
+
+//var package = new Box();
+//var box1 = new Box();
+//box1.AddItem(new Mouse(20));
+//package.AddItem(box1);
+
+//var box2 = new Box();
+//box2.AddItem(new Keyboard(30));
+//package.AddItem(box2);
+
+//var box3 = new Box();
+//var box4 = new Box();
+//box3.AddItem(box4);
+//box3.AddItem(new Microphone(40));
+//package.AddItem(box3);
+
+//Console.WriteLine($"Total price of all items: {package.GetPrice()} "); // Should return 90 (20 for the mouse, 30 for the keyboard, and 40 for the microphone)
+#endregion
+
+#region Adaptor
+//using ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest;
+//using ConsoleApp1.src.DesignPatterns.Structural.Adapter.MyTest.ThridPartyColorLibrary;
+
+//VideoEditor videoEditor = new VideoEditor(new Video());
+//videoEditor.ApplyColor(new RainbowColor(new Rainbow())); // Using the adapter to apply a rainbow color filter to the video
+//videoEditor.ApplyColor(new BlackAndWhiteColor()); // Applying a black and white color filter to the video
+//videoEditor.ApplyColor(new MidnightPurpleColor()); // Applying a midnight purple color filter to the video
+#endregion
+
+#endregion
+
+#region Behavioral Pattern
+
+
+#region Command
+
+#endregion
+
+#region Memento
+//using ConsoleApp1.src.DesignPatterns.Behavioral.Memento.MyTest;
+
+//var editor = new Editor();
+//var history = new History(editor);
+
+//editor.Title = "First Title";
+//editor.Content = "This is the first content.";
+//history.Backup();
+
+//Console.WriteLine($"{editor.Title} : {editor.Content}");
+//editor.Title = "Second Title";
+//editor.Content = "This is the second content.";
+//Console.WriteLine($"{editor.Title} : {editor.Content}");
+//history.Backup();
+
+//history.Undo();
+//Console.WriteLine($"Undo");
+//Console.WriteLine($"{editor.Title} : {editor.Content}");
+//editor.Title = "New Title";
+//editor.Content = "New content.";
+//Console.WriteLine($"{editor.Title} : {editor.Content}");
+
+//history.Backup();
+//editor.Title = "Start Wars";
+//editor.Content = "Once upon a time in a galaxy far far away.";
+//Console.WriteLine($"{editor.Title} : {editor.Content}");
+//history.Backup();
+
+//history.ShowHistory();
+#endregion
+
+#region Mediator
+//using ConsoleApp1.src.DesignPatterns.Behavioral.Mediator.MyTest;
+
+//var postDialogBox = new PostDialogBox();
+//postDialogBox.SimulateUserInteraction();
+#endregion
+
+#region Observer
+//using ConsoleApp1.src.DesignPatterns.Behavioral.Observer.MyTest;
+
+//DataSource dataSource = new DataSource();
+//Sheet2 sheet2 = new Sheet2(dataSource);
+//BarChart barChart = new BarChart(dataSource);
+//Sheet3 sheet3 = new Sheet3(dataSource);
+
+//dataSource.AddObserver(sheet2);
+//dataSource.AddObserver(barChart);
+//dataSource.AddObserver(sheet3);
+//dataSource.SetValues(new List { 10, 20, 30 });
+//dataSource.SetValues(new List { 5, 10, 15 });
+#endregion
+
+#region Iterator
+//using ConsoleApp1.src.DesignPatterns.Behavioral.Iterator.MyTest;
+//using System.Runtime.CompilerServices;
+//ShoppingList shoppingList = new ShoppingList();
+//shoppingList.Push("Bread");
+//shoppingList.Push("Milk");
+//shoppingList.Push("Cola");
+
+//var iterator = shoppingList.CreateIterator();
+
+//PrintList(shoppingList);
+//shoppingList.Pop();
+//PrintList(shoppingList);
+//void PrintList(ShoppingList shoppingList)
+//{
+// iterator.Reset();
+// while (iterator.HasNext())
+// {
+// Console.WriteLine(iterator.Current());
+// iterator.Next();
+// }
+//}
+#endregion
+
+#region ChainOfResponsibility
+//using ConsoleApp1.src.DesignPatterns.Behavioral.ChainOfResponsibility.MyTest;
+
+//var validator = new Validator();
+//var authenticator = new Authenticator();
+//var logger = new Logger();
+
+//validator.SetNext(authenticator).SetNext(logger);
+
+//WebServer webServer = new WebServer(validator);
+//HTTPRequest request = new HTTPRequest("Leif", "123");
+//webServer.Handle(request);
+
+#endregion
+#endregion
+
+Console.ReadLine();
\ No newline at end of file