Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / Backup.cs
Created April 3, 2018 14:42
Memento Design Pattern Example
using System;
using System.Collections.Generic;
using System.Linq;
namespace MementoPattern
{
//Originator class
public class Backup
{
public string BackupName { get; set; }
@miteshsureja
miteshsureja / IStockPriceWatcher.cs
Created May 5, 2018 06:14
Observer Design Pattern
using System;
using System.Collections.Generic;
namespace ObserverPattern
{
//Observer
public interface IStockPriceWatcher
{
string Name { get; set; }
Subject Subject { get; set; }
@miteshsureja
miteshsureja / Program.cs
Last active May 13, 2018 14:21
State Design Pattern
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StatePattern
{
//state
public abstract class State
@miteshsureja
miteshsureja / ReadFromExcel.Ps1
Created May 8, 2018 14:36
Read data from Excel file using PowerShell script
#select excel file you want to read
$file = "C:\PowerShell\MyContacts.xlsx"
$sheetName = "Sheet1"
#create new excel COM object
$excel = New-Object -com Excel.Application
#open excel file
$wb = $excel.workbooks.open($file)
@miteshsureja
miteshsureja / Program.cs
Last active May 13, 2018 14:15
Strategy Design Pattern
using System;
namespace StrategyPattern
{
//strategy
public interface IPaymentStrategy
{
void Pay(double amount);
}
//concrete strategy
@miteshsureja
miteshsureja / Program.cs
Created May 13, 2018 14:12
Template Method Design Pattern
using System;
namespace TemplatePattern
{
//Template abstract class
public abstract class OrderTemplate
{
public abstract void SelectProduct();
public abstract void Payment();
public abstract void Deliver();