Skip to content

Instantly share code, notes, and snippets.

ok = response.Terminal.Value.ToUpper() == "OK" ? true : false;
Task save = new Task(new Action(() => _orderService.SaveOrderParametersAsync(parameters)));
save.Start();
Task.WaitAny(new Task[] { save });
using System;
using System.Threading;
public class RwLock : IDisposable
{
private readonly ReaderWriterLockSlim _innerLock = new ReaderWriterLockSlim();
private bool _disposed = false;
public IDisposable Read()
{
public class Linx
{
[Test]
public void Select()
{
var ints = new[] { 1, 2, 3 };
var squares = ints.Select(x => x * x);
CollectionAssert.AreEqual(new[] { 1, 4, 9 }, squares);
}
@JohanLarsson
JohanLarsson / AddOwner.cs
Last active August 29, 2015 14:11
R# templates for wpf
public static readonly DependencyProperty $propertyName$Property = $ownerType$.$propertyName$Property.AddOwner(
typeof($containingType$),
new FrameworkPropertyMetadata(default($propertyType$), FrameworkPropertyMetadataOptions.None));
public $propertyType$ $propertyName$
{
get
{
return ($propertyType$)this.GetValue($propertyName$Property);
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Gu.Reactive;
Task save = new Task(new Action(() => _orderService.SaveOrderParametersAsync(parameters)));
save.Start();
Task.WaitAny(new Task[] { save });
new Angle\((?!, AngleUnit.Radians)(.*), AngleUnit.Radians\)
Angle.FromRadians($1)
new Angle\((?!, AngleUnit.Degrees)(.*), AngleUnit.Degrees\)
Angle.FromDegrees($1)
new Length\((?!, LengthUnit.MilliMeters)(.*), LengthUnit.MilliMeters\)
Length.FromMillimetres($1)
new Density\((?!, DensityUnit.GramsPerCubicCentiMeters)(.*), DensityUnit.GramsPerCubicCentiMeters\)
namespace Gu.Units.Fsharp.Tests
open NUnit.Framework;
open Gu.Units;
[<Measure>] type sec
[<Measure>] type kg
[<Measure>] type m
[<Measure>] type cm
[<Measure>] type inch
module Tests=
using Newtonsoft.Json;
using NUnit.Framework;
public class Demo
{
private JsonSerializerSettings _settings;
[SetUp]
public void SetUp()
{
_settings = new JsonSerializerSettings()
protected static void OnMyCollectionItemsSourceChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
var newCol = args.NewValue as INotifyCollectionChanged;
if (newCol != null)
{
// CollectionChangedEventManager.AddListener(newCol, this); // You probably wanna do this in a control
newCol.CollectionChanged += OnCollectionChanged;
}
var oldCol = args.OldValue as INotifyCollectionChanged;
if (oldCol != null)