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
void Main() | |
{ | |
var fooInstance = new Foo(); | |
fooInstance.Id = "FOOOO"; | |
var barInstance = new Bar(); | |
barInstance.Id = "BARRR"; | |
MessageRouter router = new MessageRouter(); | |
router.AddHandler(new Handler1()); | |
router.AddHandler(new Handler2()); |
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
<# | |
.SYNOPSIS | |
This function updates the Public instance IP of the WorkerRoles | |
.DESCRIPTION | |
This will update the Public Instance IP of the WorkerRole in a Cloud Service. | |
.EXAMPLE |
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 BuilderDemo | |
{ | |
public static void Main() | |
{ | |
TennisBall ball = new TennisBall() { Make = Make.Balbolat, Count = 1 }; | |
TennisHeadband headBand = new TennisHeadband() { Make = Make.Head, Count = 1 }; | |
TennisRacquet racquet = new TennisRacquet() { Make = Make.Wilson, Count = 3 }; | |
TennisShoes shoes = new TennisShoes() { Make = Make.Balbolat, Count = 1 }; | |
TennisKit kit = new TennisKit.TennisKitBuilder() |
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
// ... Use of This KeyWord and The Use of Closure ... | |
function L1(id,name) | |
{ | |
this.Id = id; | |
this.Name = name; | |
var that = this; | |
return function() | |
{ | |
console.log(that.Id + " " + that.Name); |
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
// Call and Apply Methods on Object to change the context in which methods are called | |
var x = 10; | |
var x1 = { | |
x : 20 | |
}; | |
function f(someparameter) | |
{ | |
console.log(someparameter); | |
console.log(this.x); |
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
//Linqpad Share Url :: http://share.linqpad.net/nwodei.linq | |
void Main() | |
{ | |
var asyncLazyTask = new AsyncLazy<int>(async () => { "started".Dump(); await Task.Delay(1000); "completed".Dump(); return 1; }); | |
asyncLazyTask.Value.Dump(); | |
"COMPLETED".Dump(); | |
} | |
public class AsyncLazy<T> : Lazy<Task<T>> |
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 static class Guard | |
{ | |
public static void NotNull<T>(string argumentName, T value) | |
where T : class | |
{ | |
if (value == null) | |
throw new ArgumentNullException(argumentName); | |
} | |
public static void NotEmpty(string argumentName, string value) |
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
void Main() | |
{ | |
var tasks = new List<Task>(); | |
for (int i = 0; i < 100; i++) | |
{ | |
tasks.Add(Task.Run(() => {var x = new Test();})); | |
} | |
Task.WaitAll(tasks.ToArray()); | |
} |
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
void Main() | |
{ | |
var manager = new NameVersionObjectManager<Test>(); | |
manager.Add(new DefaultObjectCreator<Test>(typeof(Test))); | |
var x = manager.GetObject(new Test().GetType().ToString(),new Test().GetType().ToString()); | |
x.Dump(); | |
} | |
// Define other methods and classes here | |
public class Test |
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
void Main() | |
{ | |
System.Threading.EventWaitHandle stopper = new ManualResetEvent(false); | |
new Thread(() => Monitor("Processor", "% Processor Time", "_Total", stopper)).Start(); | |
new Thread(() => Monitor("LogicalDisk", "% Idle Time", "C:", stopper)).Start(); | |
Console.WriteLine("Monitoring - press any key to quit"); | |
Console.Read(); | |
stopper.Set(); | |
} |
OlderNewer