Skip to content

Instantly share code, notes, and snippets.

View jbogard's full-sized avatar

Jimmy Bogard jbogard

View GitHub Profile
public class PdfModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += context_BeginRequest;
}
private void context_BeginRequest(object sender, EventArgs e)
{
var httpApplication = (HttpApplication) sender;
public PdfFilter(Stream oldFilter, string baseUrl)
{
_oldFilter = oldFilter;
_baseUrl = baseUrl;
_memStream = new MemoryStream();
}
public override void Write(byte[] buffer, int offset, int count)
{
_memStream.Write(buffer, offset, count);
}
public override void Close()
{
var converter = new PdfConverter
{
MediaType = "print",
};
converter.PdfDocumentOptions.LiveUrlsEnabled = false;
_memStream.Position = 0;
public interface INullableConverterFactory
{
INullableConverter Create(Type nullableType);
}
public class NullableConverterFactoryOverride : INullableConverterFactory
{
public INullableConverter Create(Type nullableType)
{
return new NullableConverterImpl(new NullableConverter(nullableType));
}
public class EnumMapper : IObjectMapper
{
private static readonly INullableConverterFactory NullableConverterFactory =
PlatformAdapter.Resolve<INullableConverterFactory>();
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Build sequence modification -->
<Target Name="CopyAutoMapperAssembly"
AfterTargets="ResolveAssemblyReferences">
<CreateItem Include="%(ReferencePath.FullPath)"
Condition="$([System.String]::new('%(ReferencePath.Filename)').StartsWith('AutoMapper.'))">
<Output TaskParameter="Include"
ItemName="_AutoMapperReference"/>
public class BatchSaga : IContainSagaData {
public int TotalWork { get; set; }
public int WorkCompleted { get; set }
public void Handle(WorkCompleted message) {
WorkCompleted++;
if (WorkCompleted == TotalWork) {
Bus.Send(new BatchDone());
MarkAsComplete();
public TResult Send<TResult>(ICommand<TResult> message)
{
var defaultHandler = GetHandler(message);
TResult result = defaultHandler.Handle(message);
var eventHandlers = GetEventHandlers(message);
foreach (var eventHandler in eventHandlers)
{