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.IO; | |
namespace Mjollnir | |
{ | |
static class ByteArrayFactory | |
{ | |
public static byte[] Create(Action<Stream> action) | |
{ | |
if (action == null) throw new ArgumentNullException("action"); |
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.Text; | |
namespace Mjollnir | |
{ | |
static class StringFactory | |
{ | |
public static string Create(Action<StringBuilder> action) | |
{ | |
if (action == null) throw new ArgumentNullException("action"); |
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
static class Syncronized | |
{ | |
public static void Invoke(Action<ManualResetEvent> action) | |
{ | |
if (action == null) throw new ArgumentException("action"); | |
using (var signal = new ManualResetEvent(false)) | |
{ | |
action(signal); | |
signal.WaitOne(); |
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
static class TaskExtensions | |
{ | |
public static void Await(this Task task) | |
{ | |
if (task == null) throw new ArgumentNullException("task"); | |
task.Wait(); | |
if (task.IsCompleted) | |
{ |
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
<#@ template debug="false" hostspecific="false" language="C#" #> | |
<#@ output extension=".cs" #> | |
<# | |
var recipes = new[] | |
{ | |
new | |
{ | |
Parameters = "", | |
Arguments1 = "", | |
Arguments2 = "", |
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; | |
namespace Mjollnir | |
{ | |
static class Lock | |
{ | |
public static TResult Invoke<TResult>(object syncRoot, Func<TResult> func) | |
{ | |
lock (syncRoot) | |
{ |
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.IO; | |
namespace Mjollnir.IO | |
{ | |
static class StreamExtensions | |
{ | |
const int DefaultBufferSize = 4096; | |
public static long CopyTo(this Stream source, Stream destination) |
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.IO; | |
using System.Text; | |
namespace Mjollnir | |
{ | |
static class StringExtensions | |
{ | |
public static Stream ToStream(this string source, Encoding encoding) | |
{ |
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.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
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.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
OlderNewer