├── Slides-DesignPatterns.pdf ├── Facade ├── App.xaml.cs ├── Facade.csproj ├── AssemblyInfo.cs ├── MainWindow.xaml.cs ├── MainWindow.xaml ├── Converters.cs └── App.xaml ├── Proxy ├── App.xaml.cs ├── Proxy.csproj ├── MainWindow.xaml.cs ├── AssemblyInfo.cs ├── PeopleServiceProxy.cs ├── MainWindow.xaml ├── Converters.cs └── App.xaml ├── Iterator ├── App.xaml.cs ├── Iterator.csproj ├── MainWindow.xaml.cs ├── AssemblyInfo.cs ├── MainWindow.xaml ├── Converters.cs └── App.xaml ├── Observer ├── App.xaml.cs ├── Observer.csproj ├── AssemblyInfo.cs ├── MainWindow.xaml.cs ├── MainWindow.xaml ├── Converters.cs └── App.xaml ├── People.Service ├── People.Service.http ├── appsettings.Development.json ├── Models │ ├── IPeopleProvider.cs │ ├── Person.cs │ └── HardCodedPeopleProvider.cs ├── appsettings.json ├── Properties │ └── launchSettings.json ├── People.Service.csproj ├── Controllers │ └── PeopleController.cs └── Program.cs ├── Shared ├── Shared.csproj ├── Person.cs └── People.cs ├── ChainOfResponsibility ├── ChainOfResponsibility.csproj ├── App.xaml.cs ├── AssemblyInfo.cs ├── MainWindow.xaml.cs ├── MainWindow.xaml ├── Converters.cs └── App.xaml ├── README.md ├── DesignPatterns.sln └── .gitignore /Slides-DesignPatterns.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeremybytes/learning-design-patterns/HEAD/Slides-DesignPatterns.pdf -------------------------------------------------------------------------------- /Facade/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Facade; 4 | 5 | public partial class App : Application 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /Proxy/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Proxy; 4 | 5 | public partial class App : Application 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /Iterator/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Iterator; 4 | 5 | public partial class App : Application 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /Observer/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Observer; 4 | 5 | public partial class App : Application 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /People.Service/People.Service.http: -------------------------------------------------------------------------------- 1 | @People.Service_HostAddress = http://localhost:5140 2 | 3 | GET {{People.Service_HostAddress}}/weatherforecast/ 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /People.Service/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /People.Service/Models/IPeopleProvider.cs: -------------------------------------------------------------------------------- 1 | namespace People.Service; 2 | 3 | public interface IPeopleProvider 4 | { 5 | Task> GetPeople(); 6 | Task GetPerson(int id); 7 | } -------------------------------------------------------------------------------- /People.Service/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /Shared/Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Observer/Observer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ChainOfResponsibility/ChainOfResponsibility.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ChainOfResponsibility/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace ChainOfResponsibility; 4 | 5 | public partial class App : Application 6 | { 7 | protected override void OnStartup(StartupEventArgs e) 8 | { 9 | base.OnStartup(e); 10 | Application.Current.DispatcherUnhandledException += 11 | (_, _) => MessageBox.Show("UNHANDLED EXCEPTION\n\nApplication Exiting"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Shared/Person.cs: -------------------------------------------------------------------------------- 1 | namespace Shared; 2 | 3 | public record Person(int Id, string GivenName, string FamilyName, 4 | DateTime StartDate, int Rating, string FormatString = "") 5 | { 6 | public override string ToString() 7 | { 8 | if (string.IsNullOrEmpty(FormatString)) 9 | return $"{GivenName} {FamilyName}"; 10 | return string.Format(FormatString, GivenName, FamilyName); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Proxy/Proxy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Facade/Facade.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | 7 | enable 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Iterator/Iterator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /People.Service/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "http": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "launchBrowser": false, 8 | "applicationUrl": "http://localhost:9874", 9 | "environmentVariables": { 10 | "ASPNETCORE_ENVIRONMENT": "Development" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /People.Service/Models/Person.cs: -------------------------------------------------------------------------------- 1 | namespace People.Service; 2 | 3 | public record Person(int Id, string GivenName, string FamilyName, 4 | DateTime StartDate, int Rating, string FormatString = "") 5 | { 6 | public override string ToString() 7 | { 8 | if (string.IsNullOrEmpty(FormatString)) 9 | return $"{GivenName} {FamilyName}"; 10 | return string.Format(FormatString, GivenName, FamilyName); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /People.Service/People.Service.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Proxy/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Proxy; 4 | 5 | public partial class MainWindow : Window 6 | { 7 | public MainWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private async void ClickMeButton_Click(object sender, RoutedEventArgs e) 13 | { 14 | var proxy = new PeopleServiceProxy(); 15 | var people = await proxy.GetPeople(); 16 | foreach (var person in people) 17 | { 18 | PersonListBox.Items.Add(person); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Iterator/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using Shared; 2 | using System.Windows; 3 | 4 | namespace Iterator; 5 | 6 | public partial class MainWindow : Window 7 | { 8 | public MainWindow() 9 | { 10 | InitializeComponent(); 11 | } 12 | 13 | private async void ClickMeButton_Click(object sender, RoutedEventArgs e) 14 | { 15 | IEnumerable people = People.GetPeople(); 16 | foreach (var person in people) 17 | { 18 | await Task.Delay(500); 19 | PersonListBox.Items.Add(person); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Facade/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /Proxy/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /Iterator/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /Observer/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /ChainOfResponsibility/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /People.Service/Controllers/PeopleController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace People.Service.Controllers; 4 | 5 | [Route("[controller]")] 6 | [ApiController] 7 | public class PeopleController : ControllerBase 8 | { 9 | private IPeopleProvider provider; 10 | 11 | public PeopleController(IPeopleProvider provider) 12 | { 13 | this.provider = provider; 14 | } 15 | 16 | [HttpGet] 17 | public Task> GetPeople() 18 | { 19 | return provider.GetPeople(); 20 | } 21 | 22 | [HttpGet("{id}")] 23 | public Task GetPerson(int id) 24 | { 25 | return provider.GetPerson(id); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /People.Service/Program.cs: -------------------------------------------------------------------------------- 1 | using People.Service; 2 | 3 | var builder = WebApplication.CreateBuilder(args); 4 | 5 | // Add services to the container. 6 | builder.Services.AddSingleton(); 7 | 8 | builder.Services.AddControllers() 9 | .AddJsonOptions(options => options.JsonSerializerOptions.WriteIndented = true); 10 | 11 | // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi 12 | builder.Services.AddOpenApi(); 13 | 14 | var app = builder.Build(); 15 | 16 | // Configure the HTTP request pipeline. 17 | if (app.Environment.IsDevelopment()) 18 | { 19 | app.MapOpenApi(); 20 | } 21 | 22 | app.UseAuthorization(); 23 | 24 | app.MapControllers(); 25 | 26 | app.Run(); 27 | -------------------------------------------------------------------------------- /Observer/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Observer; 4 | 5 | public partial class MainWindow : Window 6 | { 7 | public MainWindow() 8 | { 9 | InitializeComponent(); 10 | ClickMeButton.Click += Observer1; 11 | ClickMeButton.Click += Observer2; 12 | ClickMeButton.Click += Observer3; 13 | } 14 | 15 | private void Observer1(object sender, RoutedEventArgs e) 16 | { 17 | TextBlock1.Text = "Hello from Observer 1"; 18 | } 19 | 20 | private void Observer2(object sender, RoutedEventArgs e) 21 | { 22 | TextBlock2.Text = "Hello from Observer 2"; 23 | } 24 | 25 | private void Observer3(object sender, RoutedEventArgs e) 26 | { 27 | MessageBox.Show("Hello from Observer 3"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Facade/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using Shared; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using System.Windows; 5 | 6 | namespace Facade; 7 | 8 | public partial class MainWindow : Window 9 | { 10 | public MainWindow() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private async void ClickMeButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | IEnumerable people = People.GetPeople(); 18 | 19 | using IEnumerator enumerator = people.GetEnumerator(); 20 | 21 | while (enumerator.MoveNext()) 22 | { 23 | await Task.Delay(500); 24 | PersonListBox.Items.Add(enumerator.Current); 25 | } 26 | 27 | //foreach (var person in people) 28 | //{ 29 | // await Task.Delay(500); 30 | // PersonListBox.Items.Add(person); 31 | //} 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Shared/People.cs: -------------------------------------------------------------------------------- 1 | namespace Shared; 2 | 3 | public static class People 4 | { 5 | public static List GetPeople() 6 | { 7 | return new List() 8 | { 9 | new Person(1, "John", "Koenig", new DateTime(1975, 10, 17), 6, ""), 10 | new Person(2, "Dylan", "Hunt", new DateTime(2000, 10, 2), 8, ""), 11 | new Person(3, "Leela", "Turanga", new DateTime(1999, 3, 28), 8, "{1} {0}"), 12 | new Person(4, "John", "Crichton", new DateTime(1999, 3, 19), 7, ""), 13 | new Person(5, "Dave", "Lister", new DateTime(1988, 2, 15), 9, ""), 14 | new Person(6, "Laura", "Roslin", new DateTime(2003, 12, 8), 6, ""), 15 | new Person(7, "John", "Sheridan", new DateTime(1994, 1, 26), 6, ""), 16 | new Person(8, "Dante", "Montana", new DateTime(2000, 11, 1), 5, ""), 17 | new Person(9, "Isaac", "Gampu", new DateTime(1977, 9, 10), 4, ""), 18 | new Person(10, "Naomi", "Nagata", new DateTime(2015, 11, 23), 7, ""), 19 | new Person(11, "John", "Boon", new DateTime(1993, 01, 06), 5, ""), 20 | new Person(12, "Kerr", "Avon", new DateTime(1978, 01, 02), 8, ""), 21 | new Person(13, "Ed", "Mercer", new DateTime(2017, 09, 10), 8, ""), 22 | new Person(14, "Devon", "", new DateTime(1973, 09, 23), 4, "{0}"), 23 | }; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Proxy/PeopleServiceProxy.cs: -------------------------------------------------------------------------------- 1 | using Shared; 2 | using System.Net.Http; 3 | using System.Text.Json; 4 | 5 | namespace Proxy; 6 | 7 | public class PeopleServiceProxy 8 | { 9 | HttpClient client = new HttpClient(); 10 | JsonSerializerOptions options = new() { PropertyNameCaseInsensitive = true }; 11 | 12 | public PeopleServiceProxy() 13 | { 14 | client.BaseAddress = new Uri("http://localhost:9874"); 15 | } 16 | 17 | public async Task> GetPeople() 18 | { 19 | HttpResponseMessage response = await client.GetAsync("people"); 20 | if (!response.IsSuccessStatusCode) 21 | { 22 | throw new HttpRequestException($"Unable to process request. Status Code: {response.StatusCode}"); 23 | } 24 | var stringResult = await response.Content.ReadAsStringAsync(); 25 | return JsonSerializer.Deserialize>(stringResult, options)!; 26 | } 27 | 28 | public async Task GetPerson(int id) 29 | { 30 | HttpResponseMessage response = await client.GetAsync($"people/{id}"); 31 | if (!response.IsSuccessStatusCode) 32 | { 33 | throw new HttpRequestException($"Unable to process request. Status Code: {response.StatusCode}"); 34 | } 35 | var stringResult = await response.Content.ReadAsStringAsync(); 36 | return JsonSerializer.Deserialize(stringResult, options); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ChainOfResponsibility/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace ChainOfResponsibility; 4 | 5 | public partial class MainWindow : Window 6 | { 7 | public MainWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void ClickMeButton_Click(object sender, RoutedEventArgs e) 13 | { 14 | try 15 | { 16 | Method1(); 17 | } 18 | catch (ArgumentException) 19 | { 20 | TextBlock1.Text = "Caught in Click"; 21 | } 22 | } 23 | 24 | private void Method1() 25 | { 26 | try 27 | { 28 | Method2(); 29 | } 30 | catch (NullReferenceException) 31 | { 32 | TextBlock1.Text = "Caught in Method1"; 33 | } 34 | } 35 | 36 | private void Method2() 37 | { 38 | try 39 | { 40 | switch (ExceptionBox.Text) 41 | { 42 | case "AccessViolationException": 43 | throw new AccessViolationException(); 44 | case "NullReferenceException": 45 | throw new NullReferenceException(); 46 | case "ArgumentException": 47 | throw new ArgumentException(); 48 | case "Exception": 49 | throw new Exception(); 50 | } 51 | 52 | } 53 | catch (AccessViolationException) 54 | { 55 | TextBlock1.Text = "Caught in Method2"; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /People.Service/Models/HardCodedPeopleProvider.cs: -------------------------------------------------------------------------------- 1 | namespace People.Service; 2 | 3 | public class HardCodedPeopleProvider : IPeopleProvider 4 | { 5 | public Task> GetPeople() 6 | { 7 | var p = new List() 8 | { 9 | new Person(1, "John", "Koenig", new DateTime(1975, 10, 17), 6, ""), 10 | new Person(2, "Dylan", "Hunt", new DateTime(2000, 10, 2), 8, ""), 11 | new Person(3, "Leela", "Turanga", new DateTime(1999, 3, 28), 8, "{1} {0}"), 12 | new Person(4, "John", "Crichton", new DateTime(1999, 3, 19), 7, ""), 13 | new Person(5, "Dave", "Lister", new DateTime(1988, 2, 15), 9, ""), 14 | new Person(6, "Laura", "Roslin", new DateTime(2003, 12, 8), 6, ""), 15 | new Person(7, "John", "Sheridan", new DateTime(1994, 1, 26), 6, ""), 16 | new Person(8, "Dante", "Montana", new DateTime(2000, 11, 1), 5, ""), 17 | new Person(9, "Isaac", "Gampu", new DateTime(1977, 9, 10), 4, ""), 18 | new Person(10, "Naomi", "Nagata", new DateTime(2015, 11, 23), 7, ""), 19 | new Person(11, "John", "Boon", new DateTime(1993, 01, 06), 5, ""), 20 | new Person(12, "Kerr", "Avon", new DateTime(1978, 01, 02), 8, ""), 21 | new Person(13, "Ed", "Mercer", new DateTime(2017, 09, 10), 8, ""), 22 | new Person(14, "Devon", "", new DateTime(1973, 09, 23), 4, "{0}"), 23 | }; 24 | return Task.FromResult(p); 25 | } 26 | 27 | public async Task GetPerson(int id) 28 | { 29 | var people = await GetPeople(); 30 | return people.FirstOrDefault(p => p.Id == id); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /Observer/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Proxy/Converters.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Data; 2 | using System.Windows.Media; 3 | 4 | namespace Proxy; 5 | 6 | public class DecadeConverter : IValueConverter 7 | { 8 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 9 | { 10 | int year = ((DateTime)value).Year; 11 | return string.Format("{0}0s", year.ToString().Substring(0, 3)); 12 | } 13 | 14 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | 20 | public class RatingConverter : IValueConverter 21 | { 22 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 23 | { 24 | int rating = (int)value; 25 | return string.Format("{0}/10 Stars", rating.ToString()); 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | 34 | public class RatingStarConverter : IValueConverter 35 | { 36 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 37 | { 38 | int rating = (int)value; 39 | string output = string.Empty; 40 | return output.PadLeft(rating, '*'); 41 | } 42 | 43 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 44 | { 45 | string input = (string)value; 46 | //int rating = 0; 47 | 48 | //foreach (var ch in input) 49 | // if (ch == '*') 50 | // rating++; 51 | 52 | //return rating; 53 | 54 | return input.Count(c => c == '*'); 55 | } 56 | } 57 | 58 | public class DecadeBrushConverter : IValueConverter 59 | { 60 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 61 | { 62 | int decade = (((DateTime)value).Year / 10) * 10; 63 | 64 | switch (decade) 65 | { 66 | case 1970: 67 | return new SolidColorBrush(Colors.Maroon); 68 | case 1980: 69 | return new SolidColorBrush(Colors.DarkGreen); 70 | case 1990: 71 | return new SolidColorBrush(Colors.DarkSlateBlue); 72 | case 2000: 73 | return new SolidColorBrush(Colors.CadetBlue); 74 | default: 75 | return new SolidColorBrush(Colors.DarkSlateGray); 76 | } 77 | } 78 | 79 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 80 | { 81 | throw new NotImplementedException(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Iterator/Converters.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Data; 2 | using System.Windows.Media; 3 | 4 | namespace Iterator; 5 | 6 | public class DecadeConverter : IValueConverter 7 | { 8 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 9 | { 10 | int year = ((DateTime)value).Year; 11 | return string.Format("{0}0s", year.ToString().Substring(0, 3)); 12 | } 13 | 14 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | 20 | public class RatingConverter : IValueConverter 21 | { 22 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 23 | { 24 | int rating = (int)value; 25 | return string.Format("{0}/10 Stars", rating.ToString()); 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | 34 | public class RatingStarConverter : IValueConverter 35 | { 36 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 37 | { 38 | int rating = (int)value; 39 | string output = string.Empty; 40 | return output.PadLeft(rating, '*'); 41 | } 42 | 43 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 44 | { 45 | string input = (string)value; 46 | //int rating = 0; 47 | 48 | //foreach (var ch in input) 49 | // if (ch == '*') 50 | // rating++; 51 | 52 | //return rating; 53 | 54 | return input.Count(c => c == '*'); 55 | } 56 | } 57 | 58 | public class DecadeBrushConverter : IValueConverter 59 | { 60 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 61 | { 62 | int decade = (((DateTime)value).Year / 10) * 10; 63 | 64 | switch (decade) 65 | { 66 | case 1970: 67 | return new SolidColorBrush(Colors.Maroon); 68 | case 1980: 69 | return new SolidColorBrush(Colors.DarkGreen); 70 | case 1990: 71 | return new SolidColorBrush(Colors.DarkSlateBlue); 72 | case 2000: 73 | return new SolidColorBrush(Colors.CadetBlue); 74 | default: 75 | return new SolidColorBrush(Colors.DarkSlateGray); 76 | } 77 | } 78 | 79 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 80 | { 81 | throw new NotImplementedException(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Observer/Converters.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Data; 2 | using System.Windows.Media; 3 | 4 | namespace Observer; 5 | 6 | public class DecadeConverter : IValueConverter 7 | { 8 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 9 | { 10 | int year = ((DateTime)value).Year; 11 | return string.Format("{0}0s", year.ToString().Substring(0, 3)); 12 | } 13 | 14 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | 20 | public class RatingConverter : IValueConverter 21 | { 22 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 23 | { 24 | int rating = (int)value; 25 | return string.Format("{0}/10 Stars", rating.ToString()); 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | 34 | public class RatingStarConverter : IValueConverter 35 | { 36 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 37 | { 38 | int rating = (int)value; 39 | string output = string.Empty; 40 | return output.PadLeft(rating, '*'); 41 | } 42 | 43 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 44 | { 45 | string input = (string)value; 46 | //int rating = 0; 47 | 48 | //foreach (var ch in input) 49 | // if (ch == '*') 50 | // rating++; 51 | 52 | //return rating; 53 | 54 | return input.Count(c => c == '*'); 55 | } 56 | } 57 | 58 | public class DecadeBrushConverter : IValueConverter 59 | { 60 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 61 | { 62 | int decade = (((DateTime)value).Year / 10) * 10; 63 | 64 | switch (decade) 65 | { 66 | case 1970: 67 | return new SolidColorBrush(Colors.Maroon); 68 | case 1980: 69 | return new SolidColorBrush(Colors.DarkGreen); 70 | case 1990: 71 | return new SolidColorBrush(Colors.DarkSlateBlue); 72 | case 2000: 73 | return new SolidColorBrush(Colors.CadetBlue); 74 | default: 75 | return new SolidColorBrush(Colors.DarkSlateGray); 76 | } 77 | } 78 | 79 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 80 | { 81 | throw new NotImplementedException(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ChainOfResponsibility/Converters.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Data; 2 | using System.Windows.Media; 3 | 4 | namespace ChainOfResponsibility; 5 | 6 | public class DecadeConverter : IValueConverter 7 | { 8 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 9 | { 10 | int year = ((DateTime)value).Year; 11 | return string.Format("{0}0s", year.ToString().Substring(0, 3)); 12 | } 13 | 14 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | 20 | public class RatingConverter : IValueConverter 21 | { 22 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 23 | { 24 | int rating = (int)value; 25 | return string.Format("{0}/10 Stars", rating.ToString()); 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | 34 | public class RatingStarConverter : IValueConverter 35 | { 36 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 37 | { 38 | int rating = (int)value; 39 | string output = string.Empty; 40 | return output.PadLeft(rating, '*'); 41 | } 42 | 43 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 44 | { 45 | string input = (string)value; 46 | //int rating = 0; 47 | 48 | //foreach (var ch in input) 49 | // if (ch == '*') 50 | // rating++; 51 | 52 | //return rating; 53 | 54 | return input.Count(c => c == '*'); 55 | } 56 | } 57 | 58 | public class DecadeBrushConverter : IValueConverter 59 | { 60 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 61 | { 62 | int decade = (((DateTime)value).Year / 10) * 10; 63 | 64 | switch (decade) 65 | { 66 | case 1970: 67 | return new SolidColorBrush(Colors.Maroon); 68 | case 1980: 69 | return new SolidColorBrush(Colors.DarkGreen); 70 | case 1990: 71 | return new SolidColorBrush(Colors.DarkSlateBlue); 72 | case 2000: 73 | return new SolidColorBrush(Colors.CadetBlue); 74 | default: 75 | return new SolidColorBrush(Colors.DarkSlateGray); 76 | } 77 | } 78 | 79 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 80 | { 81 | throw new NotImplementedException(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Facade/Converters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace Facade; 7 | 8 | public class DecadeConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 11 | { 12 | int year = ((DateTime)value).Year; 13 | return string.Format("{0}0s", year.ToString().Substring(0, 3)); 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | } 21 | 22 | public class RatingConverter : IValueConverter 23 | { 24 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 25 | { 26 | int rating = (int)value; 27 | return string.Format("{0}/10 Stars", rating.ToString()); 28 | } 29 | 30 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 31 | { 32 | throw new NotImplementedException(); 33 | } 34 | } 35 | 36 | public class RatingStarConverter : IValueConverter 37 | { 38 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 39 | { 40 | int rating = (int)value; 41 | string output = string.Empty; 42 | return output.PadLeft(rating, '*'); 43 | } 44 | 45 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 46 | { 47 | string input = (string)value; 48 | //int rating = 0; 49 | 50 | //foreach (var ch in input) 51 | // if (ch == '*') 52 | // rating++; 53 | 54 | //return rating; 55 | 56 | return input.Count(c => c == '*'); 57 | } 58 | } 59 | 60 | public class DecadeBrushConverter : IValueConverter 61 | { 62 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 63 | { 64 | int decade = (((DateTime)value).Year / 10) * 10; 65 | 66 | switch (decade) 67 | { 68 | case 1970: 69 | return new SolidColorBrush(Colors.Maroon); 70 | case 1980: 71 | return new SolidColorBrush(Colors.DarkGreen); 72 | case 1990: 73 | return new SolidColorBrush(Colors.DarkSlateBlue); 74 | case 2000: 75 | return new SolidColorBrush(Colors.CadetBlue); 76 | default: 77 | return new SolidColorBrush(Colors.DarkSlateGray); 78 | } 79 | } 80 | 81 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 82 | { 83 | throw new NotImplementedException(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Design Patterns: Not Just for Architects 2 | Level: Introductory 3 | 4 | Design patterns are not just for architects. In fact, you already use design patterns without even knowing it. Observer, Facade, Iterator, Proxy -- these are just a few of the patterns that you have probably used. But it is really hard to use a tool effectively when you don't even know you are using it. So let's fix that. 5 | 6 | In this session, you will learn what design patterns are (and what they are not). You will see both the benefits and consequences of patterns. And you will see several of the Gang of Four patterns that you already use (they may even be built into your programming language). Don't know who the Gang of Four is? You'll learn that, too. Once we understand design patterns, we can find solutions that people way smarter than us have already implemented. This gives us another set of tools that we can use to build great software. 7 | 8 | You will learn: 9 | 10 | * What design patterns are 11 | * How you are already using design patterns (even if you don't realize it) 12 | * How intentional use of patterns can lead to better software 13 | 14 | ## Project Layout 15 | 16 | Each pattern has its own folder/project of the same name. 17 | 18 | * Observer/Observer.csproj 19 | * Iterator/Iterator.csproj 20 | * Facade/Facade.csproj 21 | * ChainOfResponsibility/ChainOfResponsibility.csproj 22 | * Proxy/Proxy.csproj 23 | 24 | In addition, there are 2 supporting projects: 25 | 26 | * People.Service/People.Service.csproj 27 | The service used by the "Proxy" sample. 28 | * Shared/Shared.csproj 29 | Shared elements like the "Person" object and sample data. 30 | 31 | ## Running the Projects 32 | Each project can be started by setting the startup project from Visual Studio 2022 or by using "dotnet run" on the command line for the project. 33 | 34 | In order for the "Proxy" sample to work, the "People.Service" service must be started. To start the service, navigate to the "Person.Service" folder from the command line and type "dotnet run". 35 | 36 | Ex: 37 | ``` 38 | C:\learning-design-patterns\People.Service> dotnet run 39 | ``` 40 | 41 | The service endpoint can be found at [http://localhost:9874/people](http://localhost:9874/people) 42 | 43 | ## Additional Resources 44 | 45 | * Blog Article: [The Use and Misuse of Design Patterns](http://jeremybytes.blogspot.com/2010/07/use-and-misuse-of-design-patterns.html) 46 | * Blog Article: [Design Patterns: Understand Your Tools](http://jeremybytes.blogspot.com/2012/05/design-patterns-understand-your-tools.html) 47 | * Demo (Factory Method Pattern & Inversion of Control Pattern): [IEnumerable, ISaveable, IDontGetIt: Interfaces in .NET](http://www.jeremybytes.com/Demos.aspx#INT) 48 | * Blog Article (MVVM Pattern): [Overview of the MVVM Design Pattern](http://www.jeremybytes.com/Demos.aspx#INT) 49 | * Blog Article (Iterator Pattern): [Next, Please! - A Closer Look at IEnumerable (Part 1)](http://jeremybytes.blogspot.com/2012/05/next-please-closer-look-at-ienumerable.html) 50 | * Blog Article (Strategy Pattern): [Next, Please! - A Closer Look at IEnumerable (Part 4)](http://jeremybytes.blogspot.com/2012/05/next-please-closer-look-at-ienumerable_24.html) 51 | * Recorded Presentation: [Learn the Lingo: Design Patterns](https://youtu.be/QmSf2FtPvKA) recorded live at Silicon Valley Code Camp (Oct 2015) 52 | * Pluralsight Course (authored by me): [Design Patterns On-Ramp](http://www.pluralsight.com/training/Courses/TableOfContents/design-patterns-on-ramp) 53 | *Note: This one is a bit old (the sample code uses .NET Framework), but the information is still relevant -- that's one of the fun things about design patterns!).* 54 | 55 | --- 56 | -------------------------------------------------------------------------------- /DesignPatterns.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32825.248 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SupportProjects", "SupportProjects", "{B4DDDEF4-DC84-409B-A3B1-4F1BA28E8A3D}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EverydayPatterns", "EverydayPatterns", "{522CBA7F-642B-4758-8FC8-B0E471248950}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Observer", "Observer\Observer.csproj", "{CAB05279-BAD3-4A34-BAB5-16A6EF5EBA47}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Iterator", "Iterator\Iterator.csproj", "{2066A552-74E3-4CB8-9767-4A4384843A26}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Facade", "Facade\Facade.csproj", "{952AE885-0386-4387-AC5F-A2E347236732}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChainOfResponsibility", "ChainOfResponsibility\ChainOfResponsibility.csproj", "{823E90C6-4AE7-4851-9300-0C92F3B44B68}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proxy", "Proxy\Proxy.csproj", "{AD51CA6D-DB62-4CD5-982B-89C2AB81445E}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "People.Service", "People.Service\People.Service.csproj", "{FB33A7E0-ED72-4466-A6E6-3F613142E2E9}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{47AC6F2E-C6E1-4BBD-A974-AC2256E338AE}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Any CPU = Debug|Any CPU 27 | Release|Any CPU = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {CAB05279-BAD3-4A34-BAB5-16A6EF5EBA47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {CAB05279-BAD3-4A34-BAB5-16A6EF5EBA47}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {CAB05279-BAD3-4A34-BAB5-16A6EF5EBA47}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {CAB05279-BAD3-4A34-BAB5-16A6EF5EBA47}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {2066A552-74E3-4CB8-9767-4A4384843A26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {2066A552-74E3-4CB8-9767-4A4384843A26}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {2066A552-74E3-4CB8-9767-4A4384843A26}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {2066A552-74E3-4CB8-9767-4A4384843A26}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {952AE885-0386-4387-AC5F-A2E347236732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {952AE885-0386-4387-AC5F-A2E347236732}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {952AE885-0386-4387-AC5F-A2E347236732}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {952AE885-0386-4387-AC5F-A2E347236732}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {823E90C6-4AE7-4851-9300-0C92F3B44B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {823E90C6-4AE7-4851-9300-0C92F3B44B68}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {823E90C6-4AE7-4851-9300-0C92F3B44B68}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {823E90C6-4AE7-4851-9300-0C92F3B44B68}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {AD51CA6D-DB62-4CD5-982B-89C2AB81445E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {AD51CA6D-DB62-4CD5-982B-89C2AB81445E}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {AD51CA6D-DB62-4CD5-982B-89C2AB81445E}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {AD51CA6D-DB62-4CD5-982B-89C2AB81445E}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {FB33A7E0-ED72-4466-A6E6-3F613142E2E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {FB33A7E0-ED72-4466-A6E6-3F613142E2E9}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {FB33A7E0-ED72-4466-A6E6-3F613142E2E9}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {FB33A7E0-ED72-4466-A6E6-3F613142E2E9}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {47AC6F2E-C6E1-4BBD-A974-AC2256E338AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {47AC6F2E-C6E1-4BBD-A974-AC2256E338AE}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {47AC6F2E-C6E1-4BBD-A974-AC2256E338AE}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {47AC6F2E-C6E1-4BBD-A974-AC2256E338AE}.Release|Any CPU.Build.0 = Release|Any CPU 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | GlobalSection(NestedProjects) = preSolution 63 | {CAB05279-BAD3-4A34-BAB5-16A6EF5EBA47} = {522CBA7F-642B-4758-8FC8-B0E471248950} 64 | {2066A552-74E3-4CB8-9767-4A4384843A26} = {522CBA7F-642B-4758-8FC8-B0E471248950} 65 | {952AE885-0386-4387-AC5F-A2E347236732} = {522CBA7F-642B-4758-8FC8-B0E471248950} 66 | {823E90C6-4AE7-4851-9300-0C92F3B44B68} = {522CBA7F-642B-4758-8FC8-B0E471248950} 67 | {AD51CA6D-DB62-4CD5-982B-89C2AB81445E} = {522CBA7F-642B-4758-8FC8-B0E471248950} 68 | {FB33A7E0-ED72-4466-A6E6-3F613142E2E9} = {B4DDDEF4-DC84-409B-A3B1-4F1BA28E8A3D} 69 | {47AC6F2E-C6E1-4BBD-A974-AC2256E338AE} = {B4DDDEF4-DC84-409B-A3B1-4F1BA28E8A3D} 70 | EndGlobalSection 71 | GlobalSection(ExtensibilityGlobals) = postSolution 72 | SolutionGuid = {44F8979F-B50A-4D4D-AF9A-D9E4359EAB15} 73 | EndGlobalSection 74 | EndGlobal 75 | -------------------------------------------------------------------------------- /.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 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 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 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /Proxy/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 56 | 57 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 71 | 73 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 119 | 120 | 121 | 122 | 123 | 126 | 127 | 128 | 129 | 130 | 133 | 134 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 151 | 152 | 153 | 154 | 155 | 156 | 165 | 166 | 167 | 171 | 174 | 178 | 179 | 184 | 185 | 190 | 191 | 196 | 197 | 202 | 203 | 204 | 205 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 223 | 224 | 225 | 227 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /Facade/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 56 | 57 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 71 | 73 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 119 | 120 | 121 | 122 | 123 | 126 | 127 | 128 | 129 | 130 | 133 | 134 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 151 | 152 | 153 | 154 | 155 | 156 | 165 | 166 | 167 | 171 | 174 | 178 | 179 | 184 | 185 | 190 | 191 | 196 | 197 | 202 | 203 | 204 | 205 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 223 | 224 | 225 | 227 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /Iterator/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 56 | 57 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 71 | 73 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 119 | 120 | 121 | 122 | 123 | 126 | 127 | 128 | 129 | 130 | 133 | 134 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 151 | 152 | 153 | 154 | 155 | 156 | 165 | 166 | 167 | 171 | 174 | 178 | 179 | 184 | 185 | 190 | 191 | 196 | 197 | 202 | 203 | 204 | 205 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 223 | 224 | 225 | 227 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /Observer/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 56 | 57 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 71 | 73 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 119 | 120 | 121 | 122 | 123 | 126 | 127 | 128 | 129 | 130 | 133 | 134 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 151 | 152 | 153 | 154 | 155 | 156 | 165 | 166 | 167 | 171 | 174 | 178 | 179 | 184 | 185 | 190 | 191 | 196 | 197 | 202 | 203 | 204 | 205 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 223 | 224 | 225 | 227 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /ChainOfResponsibility/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 56 | 57 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 71 | 73 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 119 | 120 | 121 | 122 | 123 | 126 | 127 | 128 | 129 | 130 | 133 | 134 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 151 | 152 | 153 | 154 | 155 | 156 | 165 | 166 | 167 | 171 | 174 | 178 | 179 | 184 | 185 | 190 | 191 | 196 | 197 | 202 | 203 | 204 | 205 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 223 | 224 | 225 | 227 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | --------------------------------------------------------------------------------