This file contains hidden or 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 IntervalComparisons | |
{ | |
[Scenario] | |
public void Linq_NoBaseClass() | |
{ | |
var result = | |
from left in "Given an interval".Of(Interval.WholeStep) | |
from right in "And a lesser interval".Of(Interval.HalfStep) | |
select "When comparing them".Do(left.CompareTo(right)); |
This file contains hidden or 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 WorkItem : Aggregate | |
{ | |
public WorkItem(EntityId id, string description, TimeSpan retryInterval) | |
{ | |
Announce(new WorkItemCreatedEvent(id, description, retryInterval)); | |
} | |
public string Description { get; private set; } | |
public Progress Progress { get; private set; } | |
public TimeSpan RetryInterval { get; private set; } |
This file contains hidden or 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 string GetCanonicalizedHeaders(HttpWebRequest request) | |
{ | |
ArrayList headerNameList = new ArrayList(); | |
StringBuilder sb = new StringBuilder(); | |
foreach (string headerName in request.Headers.Keys) | |
{ | |
if (headerName.ToLowerInvariant().StartsWith("x-ms-", StringComparison.Ordinal)) | |
{ | |
headerNameList.Add(headerName.ToLowerInvariant()); | |
} |
This file contains hidden or 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 consumer = new EventingBasicConsumer(); | |
model.BasicConsume(_queueName, noAck: false, consumer: consumer); | |
var messages = Observable.FromEventPattern<BasicDeliverEventHandler, BasicDeliverEventArgs>( | |
handlerAdapter => consumer.Received += handlerAdapter, | |
handlerAdapter => consumer.Received -= handlerAdapter); |
This file contains hidden or 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 FixUpSquares : ExpressionVisitor | |
{ | |
protected override Expression VisitBinary(BinaryExpression node) | |
{ | |
if(node.NodeType == ExpressionType.Add) | |
{ | |
if(addNode.Left.NodeType == ExpressionType.Constant && addNode.Right.NodeType == ExpressionType.Constant) | |
{ | |
var left = (ConstantExpression) addNode.Left; | |
var right = (ConstantExpression) addNode.Right; |
This file contains hidden or 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
// http://blogs.msdn.com/b/mattwar/archive/2007/08/01/linq-building-an-iqueryable-provider-part-iii.aspx | |
public static class ExpressionEvaluator | |
{ | |
public static Expression EvaluateSubtrees(Expression expression, Func<Expression, bool> canBeEvaluated) | |
{ | |
return new SubtreeEvaluator(canBeEvaluated).Evaluate(expression); | |
} | |
public static Expression EvaluateSubtrees(Expression expression) |
This file contains hidden or 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 abstract class JsonbExpressionVisitor : ExpressionVisitor | |
{ | |
protected override Expression VisitExtension(Expression node) | |
{ | |
var jsonbNode = node as JsonbExpression; | |
return jsonbNode == null ? node : VisitJsonb(jsonbNode); | |
} | |
protected virtual Expression VisitJsonb(JsonbExpression node) |
This file contains hidden or 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 ConfiguredTaskAwaitable OnThreadpool(this Task task) | |
{ | |
return task.ConfigureAwait(false); | |
} | |
public static ConfiguredTaskAwaitable<TResult> OnThreadpool<TResult>(this Task<TResult> task) | |
{ | |
return task.ConfigureAwait(false); | |
} |
This file contains hidden or 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 Format | |
{ | |
public static string Invariant(object value) | |
{ | |
return String.Format(CultureInfo.InvariantCulture, "{0}", value); | |
} | |
public static string Current(object value) | |
{ | |
return String.Format(CultureInfo.CurrentCulture, "{0}", value); |
This file contains hidden or 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
[JsonConverter(typeof(Count32JsonConverter))] | |
[TypeConverter(typeof(Count32TypeConverter))] | |
public readonly struct Count32 : IEquatable<Count32>, IEquatable<int>, IComparable<Count32>, IComparable<int> | |
{ | |
readonly int _value; | |
Count32(int value) => | |
_value = value; | |
public override string ToString() => |
OlderNewer