├── .gitattributes ├── .gitignore ├── AbstractFactoryPattern ├── AbstractFactoryPattern.csproj ├── App.config ├── Caching │ ├── Caching.cs │ ├── MemoryCache.cs │ └── RedisCache.cs ├── CrossCuttingConcers.cs ├── Factory1.cs ├── Factory2.cs ├── Logger │ ├── Log4Net.cs │ ├── Logger.cs │ └── Nlog.cs ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── AdapterPattern ├── AdapterPattern.csproj ├── App.config ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── BridgePattern ├── App.config ├── BridgePattern.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── BuilderPattern ├── App.config ├── BuilderPattern.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── ChainOfResponsibilityPattern ├── App.config ├── ChainOfResponsibilityPattern.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── CompositePattern ├── App.config ├── CompositePattern.csproj ├── Interface │ └── IPerson.cs ├── Model │ └── Emplooye.cs ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── Decorator ├── App.config ├── Decorator.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── DecoratorPattern ├── App.config ├── DecoratorPattern.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── DesignPatterns.sln ├── DesignPatterns ├── App.config ├── DesignPatterns.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── FactoryPattern ├── App.config ├── FactoryPattern.csproj ├── ILoggerFactory.cs ├── Logger │ ├── ILogger.cs │ ├── Log4NetLogger.cs │ └── NLog.cs ├── LoggerFactory.cs ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── MediatorPattern ├── App.config ├── MediatorPattern.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── MememtoPattern ├── App.config ├── MememtoPattern.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── ObserverPattern ├── App.config ├── ObserverPattern.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── Prototype ├── App.config ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── Prototype.csproj ├── ProxyPattern ├── App.config ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── ProxyPattern.csproj ├── SingletonPattern ├── App.config ├── GuidService.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── SingletonPattern.csproj └── StrategyPattern ├── App.config ├── Program.cs ├── Properties └── AssemblyInfo.cs └── StrategyPattern.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /AbstractFactoryPattern/AbstractFactoryPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {06DBCADD-0FFA-42F9-ACD5-111EEC6EDD67} 8 | Exe 9 | AbstractFactoryPattern 10 | AbstractFactoryPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Caching/Caching.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern.Caching 8 | { 9 | public abstract class Caching 10 | { 11 | public abstract void WriteCache(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Caching/MemoryCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern.Caching 8 | { 9 | public class MemoryCache : Caching 10 | { 11 | public override void WriteCache() 12 | { 13 | Console.WriteLine("Memory Log Cache"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Caching/RedisCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern.Caching 8 | { 9 | public class RedisCache : Caching 10 | { 11 | public override void WriteCache() 12 | { 13 | Console.WriteLine("Redis Cache"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/CrossCuttingConcers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern 8 | { 9 | public abstract class CrossCuttingConcers 10 | { 11 | public abstract Caching.Caching GetCaching(); 12 | public abstract Logger.Logger GetLogger(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Factory1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using AbstractFactoryPattern.Caching; 7 | using AbstractFactoryPattern.Logger; 8 | 9 | namespace AbstractFactoryPattern 10 | { 11 | public class Factory1 : CrossCuttingConcers 12 | { 13 | public override Caching.Caching GetCaching() 14 | { 15 | return new Caching.MemoryCache(); 16 | } 17 | 18 | public override Logger.Logger GetLogger() 19 | { 20 | return new Logger.Log4Net(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Factory2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using AbstractFactoryPattern.Caching; 7 | using AbstractFactoryPattern.Logger; 8 | 9 | namespace AbstractFactoryPattern 10 | { 11 | public class Factory2 : CrossCuttingConcers 12 | { 13 | public override Caching.Caching GetCaching() 14 | { 15 | return new Caching.RedisCache(); 16 | } 17 | 18 | public override Logger.Logger GetLogger() 19 | { 20 | return new Logger.Nlog(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Logger/Log4Net.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern.Logger 8 | { 9 | public class Log4Net : Logger 10 | { 11 | public override void WriteLog() 12 | { 13 | Console.WriteLine("Log4Net logging"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Logger/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern.Logger 8 | { 9 | public abstract class Logger 10 | { 11 | public abstract void WriteLog(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Logger/Nlog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern.Logger 8 | { 9 | public class Nlog : Logger 10 | { 11 | public override void WriteLog() 12 | { 13 | Console.WriteLine("Nlog logging"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AbstractFactoryPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | var fa1 = new Factory1(); 14 | var fa2 = new Factory2(); 15 | 16 | fa1.GetCaching().WriteCache(); 17 | fa1.GetLogger().WriteLog(); 18 | 19 | fa2.GetCaching().WriteCache(); 20 | fa2.GetLogger().WriteLog(); 21 | 22 | Console.ReadLine(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /AbstractFactoryPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AbstractFactoryPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AbstractFactoryPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("06dbcadd-0ffa-42f9-acd5-111eec6edd67")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AdapterPattern/AdapterPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2402C2E1-5569-4930-9968-84ABCA2CFB51} 8 | Exe 9 | AdapterPattern 10 | AdapterPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /AdapterPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AdapterPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AdapterPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /AdapterPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AdapterPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AdapterPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2402c2e1-5569-4930-9968-84abca2cfb51")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BridgePattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BridgePattern/BridgePattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {6109FBDC-D0CC-48CD-A3DE-59DC18C7D6FD} 8 | Exe 9 | BridgePattern 10 | BridgePattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /BridgePattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BridgePattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | CustomerManager customerManager = new CustomerManager 14 | { 15 | MessageSender = new EmailSender() 16 | }; 17 | 18 | customerManager.Update(); 19 | 20 | ProductManager productManager = new ProductManager() 21 | { 22 | MessageSender = new SmsSender() 23 | }; 24 | 25 | productManager.Update(); 26 | 27 | Console.ReadLine(); 28 | } 29 | abstract class MessageSender 30 | { 31 | public abstract void Send(); 32 | } 33 | 34 | class EmailSender : MessageSender 35 | { 36 | public override void Send() 37 | { 38 | Console.WriteLine("Email ile gönderildi"); 39 | } 40 | } 41 | 42 | class SmsSender : MessageSender 43 | { 44 | public override void Send() 45 | { 46 | Console.WriteLine("Sms ile gönderildi"); 47 | } 48 | } 49 | 50 | class CustomerManager 51 | { 52 | public MessageSender MessageSender { get; set; } 53 | public void Update() 54 | { 55 | Console.WriteLine("Müşteri Update edildi"); 56 | MessageSender.Send(); 57 | } 58 | } 59 | 60 | class ProductManager 61 | { 62 | public MessageSender MessageSender { get; set; } 63 | public void Update() 64 | { 65 | Console.WriteLine("Ürün Update edildi"); 66 | MessageSender.Send(); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /BridgePattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BridgePattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BridgePattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("6109fbdc-d0cc-48cd-a3de-59dc18c7d6fd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BuilderPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BuilderPattern/BuilderPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B507C9F9-CFA7-4823-A238-27DB6B78F78C} 8 | Exe 9 | BuilderPattern 10 | BuilderPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /BuilderPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BuilderPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | var vr = new ProductBuilderDirector(new NewCustomerProcduct()); 14 | var md = vr.CreateWithDiscount(); 15 | var me = vr.CreateWithoutDiscount(); 16 | 17 | } 18 | 19 | 20 | 21 | 22 | } 23 | 24 | class ProcuctModelView 25 | { 26 | public int Id { get; set; } 27 | public string Name { get; set; } 28 | public int Price { get; set; } 29 | public int DiscountPriced { get; set; } 30 | public bool DiscountApply { get; set; } 31 | } 32 | 33 | abstract class ProductBuilder 34 | { 35 | public abstract void GenerateProduct(); 36 | public abstract void AppliyPrice(); 37 | public abstract ProcuctModelView GetProcuct(); 38 | 39 | 40 | } 41 | 42 | class NewCustomerProcduct : ProductBuilder 43 | { 44 | ProcuctModelView vm = new ProcuctModelView(); 45 | public override void AppliyPrice() 46 | { 47 | vm.DiscountApply = true; 48 | vm.DiscountPriced = 10; 49 | } 50 | 51 | public override void GenerateProduct() 52 | { 53 | vm.Id = 1; 54 | vm.Name = "Laptop"; 55 | vm.Price = 50; 56 | } 57 | 58 | public override ProcuctModelView GetProcuct() 59 | { 60 | return vm; 61 | } 62 | } 63 | 64 | class OldCustomerProduct : ProductBuilder 65 | { 66 | ProcuctModelView vm = new ProcuctModelView(); 67 | public override void AppliyPrice() 68 | { 69 | throw new NotImplementedException(); 70 | } 71 | 72 | public override void GenerateProduct() 73 | { 74 | vm.Name = "Fare"; 75 | vm.Price = 10; 76 | } 77 | 78 | public override ProcuctModelView GetProcuct() 79 | { 80 | return vm; 81 | } 82 | } 83 | 84 | class ProductBuilderDirector 85 | { 86 | ProductBuilder productBuilder; 87 | public ProductBuilderDirector(ProductBuilder productBuilder) 88 | { 89 | this.productBuilder = productBuilder; 90 | } 91 | public ProcuctModelView CreateWithDiscount() 92 | { 93 | productBuilder.GenerateProduct(); 94 | productBuilder.AppliyPrice(); 95 | return productBuilder.GetProcuct(); 96 | } 97 | 98 | public ProcuctModelView CreateWithoutDiscount() 99 | { 100 | productBuilder.GenerateProduct(); 101 | return productBuilder.GetProcuct(); 102 | } 103 | } 104 | } 105 | 106 | 107 | -------------------------------------------------------------------------------- /BuilderPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BuilderPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BuilderPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b507c9f9-cfa7-4823-a238-27db6b78f78c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ChainOfResponsibilityPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ChainOfResponsibilityPattern/ChainOfResponsibilityPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A4B987D7-A892-4ABA-8C7E-D17963F7F090} 8 | Exe 9 | ChainOfResponsibilityPattern 10 | ChainOfResponsibilityPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ChainOfResponsibilityPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ChainOfResponsibilityPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | var mng = new ManagerExpense(); 14 | var vice = new VicePresidentExpense(); 15 | var president = new PresidentExpense(); 16 | 17 | mng.SetSuccescor(vice); 18 | vice.SetSuccescor(president); 19 | 20 | mng.Expense(new Expense() { Amount = 1200 }); 21 | 22 | Console.ReadLine(); 23 | } 24 | } 25 | 26 | abstract class ExpenseHandler 27 | { 28 | protected ExpenseHandler _succesor; 29 | public abstract void Expense( Expense expense); 30 | 31 | public void SetSuccescor(ExpenseHandler expenseHandler) 32 | { 33 | _succesor = expenseHandler; 34 | } 35 | } 36 | 37 | class Expense 38 | { 39 | public decimal Amount { get; set; } 40 | } 41 | 42 | class ManagerExpense : ExpenseHandler 43 | { 44 | public override void Expense(Expense expense) 45 | { 46 | if (expense.Amount <= 100) 47 | Console.WriteLine("Manager ok"); 48 | else if (_succesor != null) 49 | _succesor.Expense(expense); 50 | } 51 | } 52 | 53 | class VicePresidentExpense : ExpenseHandler 54 | { 55 | public override void Expense(Expense expense) 56 | { 57 | if (expense.Amount > 100 && expense.Amount<=1000) 58 | Console.WriteLine("Vice ok"); 59 | else if (_succesor != null) 60 | _succesor.Expense(expense); 61 | } 62 | } 63 | 64 | class PresidentExpense : ExpenseHandler 65 | { 66 | public override void Expense(Expense expense) 67 | { 68 | if (expense.Amount > 1000) 69 | Console.WriteLine("President ok"); 70 | else if (_succesor != null) 71 | _succesor.Expense(expense); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ChainOfResponsibilityPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ChainOfResponsibilityPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ChainOfResponsibilityPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a4b987d7-a892-4aba-8c7e-d17963f7f090")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /CompositePattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CompositePattern/CompositePattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3D6A65EC-EA74-4941-A7E1-2DB33761F10E} 8 | Exe 9 | CompositePattern 10 | CompositePattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /CompositePattern/Interface/IPerson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CompositePattern.Interface 8 | { 9 | public interface IPerson 10 | { 11 | string Name { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CompositePattern/Model/Emplooye.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CompositePattern.Interface; 8 | 9 | namespace CompositePattern.Model 10 | { 11 | public class Emplooye : Interface.IPerson,IEnumerable 12 | { 13 | public string Name { get; set; } 14 | List _subordinates = new List(); 15 | public void AddSubOrdinate(IPerson person) 16 | { 17 | _subordinates.Add(person); 18 | } 19 | 20 | public void RemoveSubOrdinate(IPerson person) 21 | { 22 | _subordinates.Remove(person); 23 | } 24 | public IPerson GetSubordinate(int index) 25 | { 26 | return _subordinates[index]; 27 | } 28 | 29 | 30 | public IEnumerator GetEnumerator() 31 | { 32 | foreach (var subordinate in _subordinates) 33 | yield return subordinate; 34 | } 35 | 36 | IEnumerator IEnumerable.GetEnumerator() 37 | { 38 | return GetEnumerator(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CompositePattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CompositePattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | 14 | var emp1 = new Model.Emplooye() { Name = "Murat" }; 15 | var emp2 = new Model.Emplooye() { Name = "Ali" }; 16 | var emp3 = new Model.Emplooye() { Name = "Veli" }; 17 | var emp4 = new Model.Emplooye() { Name = "Ahmet" }; 18 | var emp5 = new Model.Emplooye() { Name = "Mehmet" }; 19 | var emp6 = new Model.Emplooye() { Name = "Cevdet" }; 20 | var emp7 = new Model.Emplooye() { Name = "Mahmut" }; 21 | 22 | var emp8 = new Model.Emplooye() { Name = "Mehmet" }; 23 | var emp9 = new Model.Emplooye() { Name = "Cevdet" }; 24 | var emp10 = new Model.Emplooye() { Name = "Mahmut" }; 25 | 26 | var emp11 = new Model.Emplooye() { Name = "Mahmut" }; 27 | 28 | emp1.AddSubOrdinate(emp2); 29 | emp1.AddSubOrdinate(emp3); 30 | emp4.AddSubOrdinate(emp4); 31 | 32 | 33 | emp5.AddSubOrdinate(emp6); 34 | emp7.AddSubOrdinate(emp8); 35 | emp4.AddSubOrdinate(emp4); 36 | 37 | Console.WriteLine(emp1.Name); 38 | foreach (Model.Emplooye mng in emp1) 39 | { 40 | Console.WriteLine(mng.Name); 41 | } 42 | 43 | Console.ReadLine(); 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /CompositePattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CompositePattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CompositePattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3d6a65ec-ea74-4941-a7e1-2db33761f10e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Decorator/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Decorator/Decorator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E54476E5-54B9-4049-8E47-017D133F4325} 8 | Exe 9 | Decorator 10 | Decorator 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Decorator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Decorator 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Decorator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Decorator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Decorator")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e54476e5-54b9-4049-8e47-017d133f4325")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DecoratorPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DecoratorPattern/DecoratorPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CC563DD8-3CC5-4E13-A05E-BCA43DAAA500} 8 | Exe 9 | DecoratorPattern 10 | DecoratorPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /DecoratorPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DecoratorPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | var personelCar = new PersonalCar() { HirePrice = 1000, Make = "BMW", Model = "3.20" }; 14 | 15 | SpecialOffer specialOffer = new SpecialOffer(personelCar) 16 | { 17 | DiscountPercent = 20 18 | }; 19 | 20 | Console.WriteLine("Conrete :{0}", personelCar.HirePrice); 21 | Console.WriteLine("Special offer :{0}", specialOffer.HirePrice); 22 | Console.ReadLine(); 23 | } 24 | 25 | abstract class CarBase 26 | { 27 | public abstract string Make { get; set; } 28 | public abstract string Model { get; set; } 29 | public abstract decimal HirePrice { get; set; } 30 | } 31 | 32 | class PersonalCar : CarBase 33 | { 34 | public override string Make { get; set; } 35 | public override string Model { get; set; } 36 | public override decimal HirePrice { get; set; } 37 | 38 | } 39 | 40 | class CommerialCar : CarBase 41 | { 42 | public override string Make { get; set; } 43 | public override string Model { get; set; } 44 | public override decimal HirePrice { get; set; } 45 | } 46 | 47 | abstract class CarDecoratorBase:CarBase 48 | { 49 | private CarBase CarBase; 50 | protected CarDecoratorBase(CarBase carBase) 51 | { 52 | CarBase = carBase; 53 | } 54 | } 55 | 56 | class SpecialOffer : CarDecoratorBase 57 | { 58 | public int DiscountPercent { get; set; } 59 | CarBase CarBase; 60 | public SpecialOffer(CarBase car):base(car) 61 | { 62 | CarBase = car; 63 | } 64 | 65 | public override string Make { get; set; } 66 | public override string Model { get; set; } 67 | public override decimal HirePrice { get { 68 | return CarBase.HirePrice - (CarBase.HirePrice * DiscountPercent / 100); 69 | 70 | } set { } } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /DecoratorPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DecoratorPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DecoratorPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("cc563dd8-3cc5-4e13-a05e-bca43daaa500")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DesignPatterns.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.421 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingletonPattern", "SingletonPattern\SingletonPattern.csproj", "{14A88932-152E-4EE7-BCF4-7293BA35B8C7}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryPattern", "FactoryPattern\FactoryPattern.csproj", "{BF3B46B1-4CD3-48E0-9F89-9DB61E01F46D}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractFactoryPattern", "AbstractFactoryPattern\AbstractFactoryPattern.csproj", "{06DBCADD-0FFA-42F9-ACD5-111EEC6EDD67}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Prototype\Prototype.csproj", "{DDFA2442-32A4-4E5F-A3B0-D3F05EB8EBA3}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuilderPattern", "BuilderPattern\BuilderPattern.csproj", "{B507C9F9-CFA7-4823-A238-27DB6B78F78C}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdapterPattern", "AdapterPattern\AdapterPattern.csproj", "{2402C2E1-5569-4930-9968-84ABCA2CFB51}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompositePattern", "CompositePattern\CompositePattern.csproj", "{3D6A65EC-EA74-4941-A7E1-2DB33761F10E}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyPattern", "ProxyPattern\ProxyPattern.csproj", "{A257873A-A715-4DDD-87D6-6A7F3B9DD5ED}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decorator", "Decorator\Decorator.csproj", "{E54476E5-54B9-4049-8E47-017D133F4325}" 23 | EndProject 24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecoratorPattern", "DecoratorPattern\DecoratorPattern.csproj", "{CC563DD8-3CC5-4E13-A05E-BCA43DAAA500}" 25 | EndProject 26 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BridgePattern", "BridgePattern\BridgePattern.csproj", "{6109FBDC-D0CC-48CD-A3DE-59DC18C7D6FD}" 27 | EndProject 28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrategyPattern", "StrategyPattern\StrategyPattern.csproj", "{692A83EE-7649-483F-9E9D-7F1BAE66C2F0}" 29 | EndProject 30 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObserverPattern", "ObserverPattern\ObserverPattern.csproj", "{9BDDC4CE-8639-4A29-9334-C289241EBCA4}" 31 | EndProject 32 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainOfResponsibilityPattern", "ChainOfResponsibilityPattern\ChainOfResponsibilityPattern.csproj", "{A4B987D7-A892-4ABA-8C7E-D17963F7F090}" 33 | EndProject 34 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MememtoPattern", "MememtoPattern\MememtoPattern.csproj", "{C0FE5061-4383-4EC2-AB31-0819A55355E7}" 35 | EndProject 36 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediatorPattern", "MediatorPattern\MediatorPattern.csproj", "{9F4874D9-EC10-464A-AC50-FFC4017901F1}" 37 | EndProject 38 | Global 39 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 40 | Debug|Any CPU = Debug|Any CPU 41 | Release|Any CPU = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 44 | {14A88932-152E-4EE7-BCF4-7293BA35B8C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {14A88932-152E-4EE7-BCF4-7293BA35B8C7}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {14A88932-152E-4EE7-BCF4-7293BA35B8C7}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {14A88932-152E-4EE7-BCF4-7293BA35B8C7}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {BF3B46B1-4CD3-48E0-9F89-9DB61E01F46D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {BF3B46B1-4CD3-48E0-9F89-9DB61E01F46D}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {BF3B46B1-4CD3-48E0-9F89-9DB61E01F46D}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {BF3B46B1-4CD3-48E0-9F89-9DB61E01F46D}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {06DBCADD-0FFA-42F9-ACD5-111EEC6EDD67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {06DBCADD-0FFA-42F9-ACD5-111EEC6EDD67}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {06DBCADD-0FFA-42F9-ACD5-111EEC6EDD67}.Release|Any CPU.ActiveCfg = Release|Any CPU 55 | {06DBCADD-0FFA-42F9-ACD5-111EEC6EDD67}.Release|Any CPU.Build.0 = Release|Any CPU 56 | {DDFA2442-32A4-4E5F-A3B0-D3F05EB8EBA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 57 | {DDFA2442-32A4-4E5F-A3B0-D3F05EB8EBA3}.Debug|Any CPU.Build.0 = Debug|Any CPU 58 | {DDFA2442-32A4-4E5F-A3B0-D3F05EB8EBA3}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {DDFA2442-32A4-4E5F-A3B0-D3F05EB8EBA3}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {B507C9F9-CFA7-4823-A238-27DB6B78F78C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 61 | {B507C9F9-CFA7-4823-A238-27DB6B78F78C}.Debug|Any CPU.Build.0 = Debug|Any CPU 62 | {B507C9F9-CFA7-4823-A238-27DB6B78F78C}.Release|Any CPU.ActiveCfg = Release|Any CPU 63 | {B507C9F9-CFA7-4823-A238-27DB6B78F78C}.Release|Any CPU.Build.0 = Release|Any CPU 64 | {2402C2E1-5569-4930-9968-84ABCA2CFB51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {2402C2E1-5569-4930-9968-84ABCA2CFB51}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {2402C2E1-5569-4930-9968-84ABCA2CFB51}.Release|Any CPU.ActiveCfg = Release|Any CPU 67 | {2402C2E1-5569-4930-9968-84ABCA2CFB51}.Release|Any CPU.Build.0 = Release|Any CPU 68 | {3D6A65EC-EA74-4941-A7E1-2DB33761F10E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 69 | {3D6A65EC-EA74-4941-A7E1-2DB33761F10E}.Debug|Any CPU.Build.0 = Debug|Any CPU 70 | {3D6A65EC-EA74-4941-A7E1-2DB33761F10E}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 | {3D6A65EC-EA74-4941-A7E1-2DB33761F10E}.Release|Any CPU.Build.0 = Release|Any CPU 72 | {A257873A-A715-4DDD-87D6-6A7F3B9DD5ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 73 | {A257873A-A715-4DDD-87D6-6A7F3B9DD5ED}.Debug|Any CPU.Build.0 = Debug|Any CPU 74 | {A257873A-A715-4DDD-87D6-6A7F3B9DD5ED}.Release|Any CPU.ActiveCfg = Release|Any CPU 75 | {A257873A-A715-4DDD-87D6-6A7F3B9DD5ED}.Release|Any CPU.Build.0 = Release|Any CPU 76 | {E54476E5-54B9-4049-8E47-017D133F4325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 77 | {E54476E5-54B9-4049-8E47-017D133F4325}.Debug|Any CPU.Build.0 = Debug|Any CPU 78 | {E54476E5-54B9-4049-8E47-017D133F4325}.Release|Any CPU.ActiveCfg = Release|Any CPU 79 | {E54476E5-54B9-4049-8E47-017D133F4325}.Release|Any CPU.Build.0 = Release|Any CPU 80 | {CC563DD8-3CC5-4E13-A05E-BCA43DAAA500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 81 | {CC563DD8-3CC5-4E13-A05E-BCA43DAAA500}.Debug|Any CPU.Build.0 = Debug|Any CPU 82 | {CC563DD8-3CC5-4E13-A05E-BCA43DAAA500}.Release|Any CPU.ActiveCfg = Release|Any CPU 83 | {CC563DD8-3CC5-4E13-A05E-BCA43DAAA500}.Release|Any CPU.Build.0 = Release|Any CPU 84 | {6109FBDC-D0CC-48CD-A3DE-59DC18C7D6FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 85 | {6109FBDC-D0CC-48CD-A3DE-59DC18C7D6FD}.Debug|Any CPU.Build.0 = Debug|Any CPU 86 | {6109FBDC-D0CC-48CD-A3DE-59DC18C7D6FD}.Release|Any CPU.ActiveCfg = Release|Any CPU 87 | {6109FBDC-D0CC-48CD-A3DE-59DC18C7D6FD}.Release|Any CPU.Build.0 = Release|Any CPU 88 | {692A83EE-7649-483F-9E9D-7F1BAE66C2F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 89 | {692A83EE-7649-483F-9E9D-7F1BAE66C2F0}.Debug|Any CPU.Build.0 = Debug|Any CPU 90 | {692A83EE-7649-483F-9E9D-7F1BAE66C2F0}.Release|Any CPU.ActiveCfg = Release|Any CPU 91 | {692A83EE-7649-483F-9E9D-7F1BAE66C2F0}.Release|Any CPU.Build.0 = Release|Any CPU 92 | {9BDDC4CE-8639-4A29-9334-C289241EBCA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 93 | {9BDDC4CE-8639-4A29-9334-C289241EBCA4}.Debug|Any CPU.Build.0 = Debug|Any CPU 94 | {9BDDC4CE-8639-4A29-9334-C289241EBCA4}.Release|Any CPU.ActiveCfg = Release|Any CPU 95 | {9BDDC4CE-8639-4A29-9334-C289241EBCA4}.Release|Any CPU.Build.0 = Release|Any CPU 96 | {A4B987D7-A892-4ABA-8C7E-D17963F7F090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 97 | {A4B987D7-A892-4ABA-8C7E-D17963F7F090}.Debug|Any CPU.Build.0 = Debug|Any CPU 98 | {A4B987D7-A892-4ABA-8C7E-D17963F7F090}.Release|Any CPU.ActiveCfg = Release|Any CPU 99 | {A4B987D7-A892-4ABA-8C7E-D17963F7F090}.Release|Any CPU.Build.0 = Release|Any CPU 100 | {C0FE5061-4383-4EC2-AB31-0819A55355E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 101 | {C0FE5061-4383-4EC2-AB31-0819A55355E7}.Debug|Any CPU.Build.0 = Debug|Any CPU 102 | {C0FE5061-4383-4EC2-AB31-0819A55355E7}.Release|Any CPU.ActiveCfg = Release|Any CPU 103 | {C0FE5061-4383-4EC2-AB31-0819A55355E7}.Release|Any CPU.Build.0 = Release|Any CPU 104 | {9F4874D9-EC10-464A-AC50-FFC4017901F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 105 | {9F4874D9-EC10-464A-AC50-FFC4017901F1}.Debug|Any CPU.Build.0 = Debug|Any CPU 106 | {9F4874D9-EC10-464A-AC50-FFC4017901F1}.Release|Any CPU.ActiveCfg = Release|Any CPU 107 | {9F4874D9-EC10-464A-AC50-FFC4017901F1}.Release|Any CPU.Build.0 = Release|Any CPU 108 | EndGlobalSection 109 | GlobalSection(SolutionProperties) = preSolution 110 | HideSolutionNode = FALSE 111 | EndGlobalSection 112 | GlobalSection(ExtensibilityGlobals) = postSolution 113 | SolutionGuid = {F4057B49-A733-46CB-A3A1-4D2E63587B96} 114 | EndGlobalSection 115 | EndGlobal 116 | -------------------------------------------------------------------------------- /DesignPatterns/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DesignPatterns/DesignPatterns.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7EFB2567-580F-4B98-B029-8D7B4271FC3B} 8 | Exe 9 | DesignPatterns 10 | DesignPatterns 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /DesignPatterns/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DesignPatterns 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DesignPatterns/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DesignPatterns")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DesignPatterns")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7efb2567-580f-4b98-b029-8d7b4271fc3b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FactoryPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /FactoryPattern/FactoryPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {BF3B46B1-4CD3-48E0-9F89-9DB61E01F46D} 8 | Exe 9 | FactoryPattern 10 | FactoryPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /FactoryPattern/ILoggerFactory.cs: -------------------------------------------------------------------------------- 1 | using FactoryPattern.Logger; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace FactoryPattern 9 | { 10 | public interface ILoggerFactory 11 | { 12 | ILogger GetLogger(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FactoryPattern/Logger/ILogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace FactoryPattern.Logger 8 | { 9 | public interface ILogger 10 | { 11 | void WriteLog(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FactoryPattern/Logger/Log4NetLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace FactoryPattern.Logger 8 | { 9 | public class Log4NetLogger : ILogger 10 | { 11 | public void WriteLog() 12 | { 13 | Console.WriteLine("Log wiht Log4Net"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FactoryPattern/Logger/NLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace FactoryPattern.Logger 8 | { 9 | public class NLog : ILogger 10 | { 11 | public void WriteLog() 12 | { 13 | Console.WriteLine("Log with NLog"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FactoryPattern/LoggerFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FactoryPattern.Logger; 7 | 8 | namespace FactoryPattern 9 | { 10 | public class LoggerFactory : ILoggerFactory 11 | { 12 | private static ILogger _logger; 13 | private static object _lock = new object(); 14 | public ILogger GetLogger() 15 | { 16 | return GetAsLogger(); 17 | 18 | } 19 | private ILogger GetAsLogger() 20 | { 21 | lock (_lock) 22 | { 23 | if(_logger==null) 24 | { 25 | var type = System.Configuration.ConfigurationManager.AppSettings["LogType"].ToString(); 26 | if (type == "Log4Net") 27 | _logger = new Log4NetLogger(); 28 | else 29 | _logger = new NLog(); 30 | } 31 | } 32 | 33 | return _logger; 34 | } 35 | 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /FactoryPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace FactoryPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | var logger = new LoggerFactory().GetLogger(); 14 | logger.WriteLog(); 15 | Console.ReadLine(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FactoryPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FactoryPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FactoryPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("bf3b46b1-4cd3-48e0-9f89-9db61e01f46d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /MediatorPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MediatorPattern/MediatorPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9F4874D9-EC10-464A-AC50-FFC4017901F1} 8 | Exe 9 | MediatorPattern 10 | MediatorPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /MediatorPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MediatorPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | var mediator = new Mediator(); 14 | var teacher = new Teacher(mediator) { Name="murat" }; 15 | mediator.Teacher = teacher; 16 | 17 | var ogr1 = new Student(mediator) { Name = "ali" }; 18 | var ogr2 = new Student(mediator) { Name = "veli" }; 19 | var ogr3 = new Student(mediator) { Name = "ahmet" }; 20 | 21 | mediator.students = new List() 22 | { 23 | ogr1,ogr2,ogr3 24 | }; 25 | 26 | teacher.SendNewImageUrl("image url"); 27 | 28 | Console.ReadLine(); 29 | 30 | } 31 | } 32 | 33 | abstract class CourseMember 34 | { 35 | protected Mediator Mediator; 36 | protected CourseMember(Mediator mediator) 37 | { 38 | Mediator = mediator; 39 | } 40 | public abstract string Name { get; set; } 41 | } 42 | 43 | class Student : CourseMember 44 | { 45 | public Student(Mediator mediator):base(mediator) 46 | { 47 | } 48 | 49 | public override string Name { get; set; } 50 | 51 | internal void RecieveImgUrl(string url) 52 | { 53 | Console.WriteLine("Receive İmage:{0}", url); 54 | } 55 | 56 | internal void RecieveAnswer(string answer) 57 | { 58 | Console.WriteLine("Answer:{0}", answer); 59 | } 60 | } 61 | 62 | class Teacher : CourseMember 63 | { 64 | public Teacher(Mediator mediator):base(mediator) 65 | { 66 | 67 | } 68 | 69 | public override string Name { get; set; } 70 | 71 | internal void RecieveQuestion(string question, Student student) 72 | { 73 | throw new NotImplementedException(); 74 | } 75 | 76 | public void SendNewImageUrl(string url) 77 | { 78 | Console.WriteLine("Resim gönderildi"); 79 | Mediator.UpdateImage(url); 80 | } 81 | 82 | public void AnswerQuestion(string answer,Student student) 83 | { 84 | Console.WriteLine("Asnwered: {0}, student:{1}", answer, student.Name); 85 | Mediator.SendAnswer(answer, student); 86 | } 87 | } 88 | 89 | class Mediator 90 | { 91 | public Teacher Teacher; 92 | public List students; 93 | 94 | public void UpdateImage(string url) 95 | { 96 | foreach (var student in students) 97 | student.RecieveImgUrl(url); 98 | } 99 | 100 | public void SendQuestion(string question, Student student) 101 | { 102 | Teacher.RecieveQuestion(question, student); 103 | } 104 | 105 | public void SendAnswer(string answer, Student student) 106 | { 107 | student.RecieveAnswer(answer); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /MediatorPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MediatorPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MediatorPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9f4874d9-ec10-464a-ac50-ffc4017901f1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /MememtoPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MememtoPattern/MememtoPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C0FE5061-4383-4EC2-AB31-0819A55355E7} 8 | Exe 9 | MememtoPattern 10 | MememtoPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /MememtoPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MememtoPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | } 14 | } 15 | 16 | class Person 17 | { 18 | private string _name; 19 | private string _address; 20 | private int _id; 21 | private string _phone; 22 | private DateTime _lastEdit; 23 | 24 | public int Id { get { return _id; } set { _id = value; SetLasEdited(); } } 25 | public string Name { get { return _name; } set { _name = value; SetLasEdited(); } } 26 | public string Address { get { return _address; } set { _address = value; SetLasEdited(); } } 27 | public string Phone { get { return _phone; } set { _phone = value; SetLasEdited(); } } 28 | 29 | 30 | private void SetLasEdited() 31 | { 32 | _lastEdit = DateTime.Now; 33 | } 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /MememtoPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MememtoPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MememtoPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c0fe5061-4383-4ec2-ab31-0819a55355e7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ObserverPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ObserverPattern/ObserverPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9BDDC4CE-8639-4A29-9334-C289241EBCA4} 8 | Exe 9 | ObserverPattern 10 | ObserverPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ObserverPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ObserverPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | SaleManager saleManager = new SaleManager(); 14 | saleManager.Attach(new CustomerObserver()); 15 | saleManager.Attach(new EmployeObserver()); 16 | 17 | saleManager.UpdatePrice(); 18 | Console.ReadLine(); 19 | } 20 | 21 | } 22 | 23 | abstract class Observer 24 | { 25 | public abstract void Update(); 26 | } 27 | 28 | class CustomerObserver : Observer 29 | { 30 | public override void Update() 31 | { 32 | Console.WriteLine("Custoemer Observer"); 33 | } 34 | } 35 | 36 | 37 | class EmployeObserver : Observer 38 | { 39 | public override void Update() 40 | { 41 | Console.WriteLine("Employee Observer"); 42 | } 43 | } 44 | 45 | class SaleManager 46 | { 47 | List observers = new List(); 48 | 49 | public void Attach(Observer observer) 50 | { 51 | observers.Add(observer); 52 | } 53 | 54 | public void Dettach(Observer observer) 55 | { 56 | observers.Remove(observer); 57 | } 58 | 59 | public void UpdatePrice() 60 | { 61 | Console.WriteLine("Customer Update"); 62 | Notify(); 63 | 64 | } 65 | 66 | private void Notify() 67 | { 68 | foreach (var observer in observers) 69 | observer.Update(); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /ObserverPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ObserverPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ObserverPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9bddc4ce-8639-4a29-9334-c289241ebca4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Prototype/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Prototype/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Prototype 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | Customer cus1 = new Customer() { CityName = "Alanya", Id = 1, Name = "Murat", SirName = "Kurtboğan" }; 14 | Console.WriteLine(cus1.Name + " " + cus1.SirName); 15 | 16 | Customer cus2 = (Customer)cus1.Clone(); 17 | cus2.Name = "Yasar"; 18 | Console.WriteLine(cus2.Name + " " + cus2.SirName); 19 | 20 | Console.ReadLine(); 21 | } 22 | } 23 | 24 | public abstract class Person 25 | { 26 | public abstract Person Clone(); 27 | public int Id { get; set; } 28 | public string Name { get; set; } 29 | public string SirName { get; set; } 30 | 31 | } 32 | 33 | public class Customer:Person 34 | { 35 | public string CityName { get; set; } 36 | 37 | public override Person Clone() 38 | { 39 | return (Person)MemberwiseClone(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Prototype/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Prototype")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Prototype")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ddfa2442-32a4-4e5f-a3b0-d3f05eb8eba3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Prototype/Prototype.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {DDFA2442-32A4-4E5F-A3B0-D3F05EB8EBA3} 8 | Exe 9 | Prototype 10 | Prototype 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ProxyPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ProxyPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace ProxyPattern 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | var crediManager = new CrediManager(); 15 | 16 | var aa = crediManager.Calculate(); 17 | Console.Write(aa.ToString()); 18 | 19 | var creaditManagerProxy = new CreaditManagerProxy(); 20 | var asd = creaditManagerProxy.Calculate(); 21 | Console.WriteLine(asd); 22 | 23 | var asr = creaditManagerProxy.Calculate(); 24 | Console.WriteLine(asr); 25 | 26 | Console.ReadLine(); 27 | } 28 | } 29 | 30 | abstract class CreditBase 31 | { 32 | public abstract int Calculate(); 33 | } 34 | 35 | class CrediManager : CreditBase 36 | { 37 | public override int Calculate() 38 | { 39 | int result = 1; 40 | 41 | for (int i = 1; i < 10; i++) 42 | { 43 | result *= i; 44 | Thread.Sleep(5000); 45 | } 46 | 47 | return result; 48 | } 49 | } 50 | 51 | class CreaditManagerProxy : CreditBase 52 | { 53 | public CrediManager crediManager = null; 54 | public int _price = 0; 55 | public override int Calculate() 56 | { 57 | if (crediManager == null) 58 | { 59 | crediManager = new CrediManager(); 60 | _price = crediManager.Calculate(); 61 | } 62 | return _price; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ProxyPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ProxyPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ProxyPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a257873a-a715-4ddd-87d6-6a7f3b9dd5ed")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ProxyPattern/ProxyPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A257873A-A715-4DDD-87D6-6A7F3B9DD5ED} 8 | Exe 9 | ProxyPattern 10 | ProxyPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /SingletonPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SingletonPattern/GuidService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SingletonPattern 4 | { 5 | public class GuidService 6 | { 7 | private static Guid _guid; 8 | private static object _lock = new object(); 9 | private GuidService() 10 | { 11 | 12 | } 13 | 14 | public static Guid CreateAsGuid() 15 | { 16 | lock (_lock) 17 | { 18 | if (_guid == Guid.Empty) 19 | _guid = Guid.NewGuid(); 20 | } 21 | 22 | return _guid; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SingletonPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SingletonPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | for (int i = 0; i < 10; i++) 14 | { 15 | Console.WriteLine(GuidService.CreateAsGuid().ToString()); 16 | } 17 | 18 | Console.ReadLine(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SingletonPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SingletonPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SingletonPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("14a88932-152e-4ee7-bcf4-7293ba35b8c7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SingletonPattern/SingletonPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {14A88932-152E-4EE7-BCF4-7293BA35B8C7} 8 | Exe 9 | SingletonPattern 10 | SingletonPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /StrategyPattern/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /StrategyPattern/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace StrategyPattern 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | var customerManager = new CustomerManager() 14 | { 15 | CreaditCalculateBase = new CalculateBefore2010() 16 | }; 17 | 18 | customerManager.Save(); 19 | customerManager.CreaditCalculateBase = new CalculateAfter2010(); 20 | customerManager.Save(); 21 | Console.ReadLine(); 22 | 23 | } 24 | } 25 | 26 | abstract class CreaditCalculateBase 27 | { 28 | public abstract void CalculateSave(); 29 | } 30 | 31 | class CalculateBefore2010 : CreaditCalculateBase 32 | { 33 | public override void CalculateSave() 34 | { 35 | Console.WriteLine("Calculate before 2010"); 36 | } 37 | } 38 | 39 | class CalculateAfter2010 : CreaditCalculateBase 40 | { 41 | public override void CalculateSave() 42 | { 43 | Console.WriteLine("Calculate after 2010"); 44 | } 45 | } 46 | 47 | class CustomerManager 48 | { 49 | public CreaditCalculateBase CreaditCalculateBase { get; set; } 50 | public void Save() 51 | { 52 | CreaditCalculateBase.CalculateSave(); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /StrategyPattern/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("StrategyPattern")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("StrategyPattern")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("692a83ee-7649-483f-9e9d-7f1bae66c2f0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /StrategyPattern/StrategyPattern.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {692A83EE-7649-483F-9E9D-7F1BAE66C2F0} 8 | Exe 9 | StrategyPattern 10 | StrategyPattern 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | --------------------------------------------------------------------------------