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 pb = new PictureBox { Image = Image.FromFile(@"D:\tmp\dotnet.png") }; | |
bool down = false; | |
Cursor dragCursor = null; | |
pb.MouseDown += (sender, e) => down = true; | |
pb.MouseUp += (sender, e) => { down = false; dragCursor = null; }; | |
pb.MouseMove += (sender, e) => | |
{ | |
if (down) |
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.Linq; | |
using System.Net; | |
using System.Text; | |
using Sharebox.Utils.Collections; | |
namespace Sharebox.Communication | |
{ | |
class BasicAuthenticationModule : IAuthenticationModule | |
{ |
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.Threading; | |
namespace Utils.Threading | |
{ | |
/// <summary> | |
/// A cancellable replacement for Thread.Sleep | |
/// </summary> | |
public static class Sleeper | |
{ |
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 System.Runtime.CompilerServices | |
{ | |
[AttributeUsageAttribute(AttributeTargets.Parameter, Inherited = false)] | |
public sealed class CallerMemberNameAttribute : Attribute | |
{ | |
} | |
[AttributeUsageAttribute(AttributeTargets.Parameter, Inherited = false)] | |
public sealed class CallerFilePathAttribute : Attribute |
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 Sequence | |
{ | |
public static IEnumerable<T> Memoize<T>(this IEnumerable<T> sequence) | |
{ | |
return new MemoizedSequence<T>(sequence); | |
} | |
} | |
// This code is for illustration and is not production-ready. |
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 list1 = Enumerable.Range(0, 10000).Select(i => i.ToString()); | |
var list2 = Enumerable.Range(0, 10000).Select(i => i.ToString()); | |
var list3 = Enumerable.Range(0, 10000).Select(i => i.ToString()); | |
// First run to avoid JIT during the benchmark | |
list1.ZipOne(list2, list3, Merge).Count(); | |
list1.ZipTwo(list2, list3, Merge).Count(); | |
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.Windows.Input; | |
namespace QuestionableContent.Input | |
{ | |
public class DelegateCommand : ICommand | |
{ | |
private readonly Action _execute; | |
private readonly Func<bool> _canExecute; |
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
var field = typeof(DayOfWeek).GetField("value__"); | |
var d = DayOfWeek.Monday; | |
Console.WriteLine (d); | |
TypedReference r = __makeref(d); | |
field.SetValueDirect(r, 4); | |
Console.WriteLine (d); |
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 IEnumerable<T> Distinct<T, U>(this IEnumerable<T> source, IEqualityComparer<U> comparer) | |
where T : U | |
{ | |
IEqualityComparer<T> comparer2 = (IEqualityComparer<T>)comparer; | |
return Enumerable.Distinct<T>(source, comparer2); | |
} |
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.Runtime.InteropServices; | |
namespace ADS | |
{ | |
public static class AlternateDataStream | |
{ | |
public static FileStream Open(string path, string streamName, FileMode mode) | |
{ |
OlderNewer