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
<Query Kind="Program"> | |
<NuGetReference>Newtonsoft.Json</NuGetReference> | |
<NuGetReference>System.Text.Json</NuGetReference> | |
<Namespace>Newtonsoft.Json</Namespace> | |
<Namespace>System.Text.Json</Namespace> | |
<Namespace>System.Xml.Serialization</Namespace> | |
</Query> | |
void Main() | |
{ |
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.Net; | |
using Owin; | |
static class OwinExtensions | |
{ | |
public static IAppBuilder RedirectRootTo(this IAppBuilder app, string destination) | |
{ | |
app.Use(async (ctx, next) => | |
{ | |
if (ctx.Request.Path.Value == "/") |
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 Ext | |
{ | |
private static IEnumerable<decimal> LinearInterpolate(decimal lowerBound, decimal upperBound, int pointCount) | |
{ | |
var gradient = (upperBound - lowerBound) / (pointCount + 1); | |
for(var i = 1; i <= pointCount; i++) | |
{ | |
yield return lowerBound + gradient * i; | |
} | |
} |
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
// Used to kick off the scheduler whenever the endpoint starts | |
class StartSchedulerCommand : ICommand | |
{ | |
public Guid Key { get; set; } | |
} | |
// The scheduler saga sends one of these every midnight | |
class RunProcessCommand : ICommand | |
{ | |
} |
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
class EchoSatellite : ISatellite | |
{ | |
public bool Handle(TransportMessage message) | |
{ | |
string replyToAddress; | |
if (message.Headers.TryGetValue(Headers.ReplyToAddress, out replyToAddress)) | |
{ | |
dispatcher.Send(message, new SendOptions(replyToAddress)); | |
return true; | |
} |
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
class PublishHandledEventsAtStartup : Feature | |
{ | |
protected override void Setup(FeatureConfigurationContext context) | |
{ | |
var conventions = context.Settings.Get<Conventions>(); | |
context.RegisterStartupTask(b => | |
{ | |
var handlerRegistry = b.Build<MessageHandlerRegistry>(); | |
return new PublishedHandledEventsToConsole(handlerRegistry.GetMessageTypes().Where(conventions.IsEventType)); |
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 RequestTracing | |
{ | |
public static void EnableRequestTracing(this EndpointConfiguration cfg) | |
{ | |
cfg.Pipeline.Register(typeof(LogIncomingBehavior), "Log incoming messages"); | |
cfg.Pipeline.Register(typeof(LogOutgoingBehavior), "Log outgoing messages"); | |
} | |
class LogOutgoingBehavior : Behavior<IDispatchContext> | |
{ |
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 class PipelineInspector : IWantToRunWhenBusStartsAndStops | |
{ | |
private readonly ReadOnlySettings settings; | |
public PipelineInspector(ReadOnlySettings settings) | |
{ | |
this.settings = settings; | |
} | |
public void Start() |
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 ignores = new Regex[] | |
{ | |
new Regex(@"Approval"), | |
new Regex(@"Test"), | |
new Regex(@"Demo") | |
}; | |
var serviceControl = @"C:\Code\Particular\ServiceControl\src\"; | |
Util.Image("http://yuml.me/diagram/scruffy;scale:150/class/" + String.Join(",", GetDependencies(serviceControl, ignores))).Dump(); |
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
// With massive help from http://securityxploded.com/iepasswordsecrets.php | |
var urlBytes = System.Text.Encoding.Unicode.GetBytes((url + '\0').ToLower()); | |
byte[] hashBytes; | |
using(var sha1 = new SHA1Managed()) | |
hashBytes = sha1.ComputeHash(urlBytes); | |
var checksum = hashBytes.Aggregate((x,y) => (byte)((int)x + (int)y)); | |
var keyBytes = hashBytes.Concat(new[] { checksum }).ToArray(); | |
var regKey = String.Join("", keyBytes.Select(x => x.ToString("X2"))); |
NewerOlder