This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HashEncryption | |
{ | |
/// <summary> | |
/// Encrypts a string using the MD5 hash encryption algorithm. | |
/// Message Digest is 128-bit and is commonly used to verify data, by checking | |
/// the 'MD5 checksum' of the data. Information on MD5 can be found at: | |
/// | |
/// http://www.faqs.org/rfcs/rfc1321.html | |
/// </summary> | |
/// <param name="Data">A string containing the data to encrypt.</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security; | |
using System.Net; | |
using System.Net.Sockets; | |
namespace Demo | |
{ | |
public class NetworkUtils | |
{ | |
/// <summary> | |
/// Performs a hostname lookup from an IP. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DesignPatterns | |
{ | |
/// <summary> | |
/// Defines the methods/properties the plugin can support. | |
/// </summary> | |
public interface IPlugin | |
{ | |
string GetDetails(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DesignPatterns | |
{ | |
public abstract class AbstractPluginFactory | |
{ | |
public static AbstractPluginFactory GetFactory(string renderer) | |
{ | |
switch (renderer) | |
{ | |
case "ASPX": | |
return new ASPXRendererFactory(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class Singleton | |
{ | |
Singleton() | |
{ | |
} | |
public static Singleton Instance | |
{ | |
get | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DesignPatterns | |
{ | |
private static void IteratorTest() | |
{ | |
IteratorExample example = new IteratorExample(); | |
foreach (string item in example) | |
{ | |
Console.WriteLine(item); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DesignPatterns | |
{ | |
public class User | |
{ | |
public string Name { get; set; } | |
public int Age { get; set; } | |
public override string ToString() | |
{ | |
return string.Format("{0} {1}", Name, Age); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class FooBarDaddy | |
{ | |
public void Run() | |
{ | |
Foobar1 fb = new Foobar1(); | |
} | |
/// Only accessible inside FooBarDaddy | |
private class Foobar1 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DesignPatterns | |
{ | |
public delegate void MessageReceivedEventHandler(string message, string from); | |
public class Mediator | |
{ | |
public event MessageReceivedEventHandler MessageReceived; | |
public void Send(string message, string from) | |
{ | |
if (MessageReceived != null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DesignPatterns | |
{ | |
/// <summary> | |
/// The use of an interface here mightseem a bit redundent, but it's to keep | |
/// inline with the original gang of 4 definition of the pattern. The implementing class | |
/// is still responsible for wiring itself to the Subject's notify event. | |
/// </summary> | |
public interface IObserver | |
{ | |
void Update(string message); |