Skip to content

Instantly share code, notes, and snippets.

@AlexanderByndyu
AlexanderByndyu / CustomSmtpAppender.cs
Last active February 28, 2020 07:02
log4net, custom SmtpAppender with Subject layout. Download NuGet: https://nuget.org/packages/log4net.Appender.SmtpAppenderWithSubjectLayout
public class CustomSmtpAppender : SmtpAppender
{
public PatternLayout SubjectLayout { get; set; }
protected override void SendBuffer(LoggingEvent[] events)
{
PrepareSubject(events);
base.SendBuffer(events);
}
@kradcliffe
kradcliffe / AutoMapperExtensions.cs
Created February 28, 2012 12:28
Automapper extension to IGNORE unmapped properties for a given type
public static class AutoMapperExtensions
{
public static IMappingExpression<TSource, TDestination>
IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
{
var sourceType = typeof(TSource);
var destinationType = typeof(TDestination);
var existingMaps = Mapper.GetAllTypeMaps().First(x => x.SourceType.Equals(sourceType) && x.DestinationType.Equals(destinationType));
foreach (var property in existingMaps.GetUnmappedPropertyNames())
{