Skip to content

Instantly share code, notes, and snippets.

@miteshsureja
miteshsureja / ChatRoom.cs
Created March 30, 2018 14:07
Mediator Design Pattern Example
using System;
using System.Collections.Generic;
using System.Linq;
namespace MediatorPattern
{
//Concrete Mediator
public class ChatRoom : IChatRoom
{
private Dictionary<string, Participant> participants =
@miteshsureja
miteshsureja / MyCollection.cs
Created June 11, 2017 07:55
Iterator Pattern using IEnumerable example
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IteratorPattern
{
public class MyCollection : IEnumerable
{
@miteshsureja
miteshsureja / Aggregate.cs
Created June 11, 2017 07:52
Iterator Design Pattern Example
using System;
using System.Collections;
using System.Collections.Generic;
namespace IteratorPattern
{
//Aggregate
public abstract class Aggregate
{
public abstract Iterator GetIterator();
@miteshsureja
miteshsureja / MainWindow.xaml
Created May 29, 2017 13:39
Async and Await - Asynchronous Programming
<Window x:Class="AsyncAwaitExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AsyncAwaitExample"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<TextBlock Text="Enter number to sum:" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,50,0,0"/>
@miteshsureja
miteshsureja / Program.cs
Created May 21, 2017 13:11
Program to display series - 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RandomNumbers
{
class Program
{
@miteshsureja
miteshsureja / Program.cs
Created May 21, 2017 13:04
Find Max and Min value from List
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RandomNumbers
{
class Program
{
@miteshsureja
miteshsureja / Program.cs
Created May 21, 2017 13:00
Display Prime Numbers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RandomNumbers
{
class Program
{
@miteshsureja
miteshsureja / Context.cs
Created May 10, 2017 14:41
Interpreter Design Pattern
//Context class
public class Context
{
public int Input { get; set; }
public Context(int inputValue)
{
Input = inputValue;
}
}
@miteshsureja
miteshsureja / BuyCommand.cs
Created May 1, 2017 12:46
Command Pattern
//Concrete Command class
public class BuyCommand : ICommand
{
private Product Product;
public string Name
{
get
{
return "Buy Command";
}
@miteshsureja
miteshsureja / ParallelInvoke
Created April 30, 2017 14:09
Parallel.Invoke
namespace ParallelInvoke
{
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Parallel.Invoke(() =>
{