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(IdJsonConverter))] | |
[TypeConverter(typeof(IdTypeConverter))] | |
public sealed class Id : IEquatable<Id>, IEquatable<Guid>, IComparable<Id>, IComparable<Guid> | |
{ | |
readonly Guid _value; | |
Id(Guid value) => | |
_value = value; | |
public override string ToString() => |
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(TextJsonConverter))] | |
[TypeConverter(typeof(TextTypeConverter))] | |
public sealed class Text : IEquatable<Text>, IEquatable<string>, IComparable<Text>, IComparable<string> | |
{ | |
readonly string _value; | |
Text(string value) => | |
_value = value; | |
public override string ToString() => |
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() => |
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
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 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
// 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 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
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 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()); | |
} |
NewerOlder