Skip to content

Instantly share code, notes, and snippets.

/// <summary>
/// Implements a heuristic for ninject property injection.
/// </summary>
public interface IObjectBuilderPropertyHeuristic : IInjectionHeuristic
{
/// <summary>
/// Gets the registered types.
/// </summary>
/// <value>The registered types.</value>
IList<Type> RegisteredTypes
/// <summary>
/// Component logger which allows to log component outputs.
/// </summary>
public class ComponentLogger : ILog, IInitializable
{
private static readonly IDictionary<string, IEnumerable<IAppender>> ComponentAppender = new Dictionary<string, IEnumerable<IAppender>>();
private readonly IComponentLoggerAppenderFactory appenderFactory;
private readonly IComponentLoggerContext context;
private readonly string loggerName;
@danielmarbach
danielmarbach / SafeObservableCollection
Created May 17, 2011 18:18
Thread safe observable collection
[DebuggerDisplay("Count = {Count}")]
[ComVisible(false)]
public class SafeObservableCollection<T> : ObservableCollection<T>
{
private readonly Dispatcher dispatcher;
public SafeObservableCollection()
: this(Enumerable.Empty<T>())
{
}
@danielmarbach
danielmarbach / ClientProxyInterceptor.cs
Created May 18, 2011 22:30
Client proxy interceptor for WCF and dynamic proxy
public class ClientProxyInterceptor : IInterceptor
{
private readonly Func<ICommunicationObject> proxyCreator;
private readonly Type typeToProxy;
private ICommunicationObject proxyInstance;
public ClientProxyInterceptor(Func<ICommunicationObject> proxyCreator, Type typeToProxy)
{
this.typeToProxy = typeToProxy;
this.proxyCreator = proxyCreator;
@danielmarbach
danielmarbach / IConfigurator.cs
Created March 22, 2012 19:28
NUnit Action Container magic
public interface IConfigurator
{
T GetInstance<T>();
void Inject<T>(T instance);
}
@danielmarbach
danielmarbach / Fiddler
Created November 6, 2012 11:05
Simple.Web Tryouts
User-Agent: Fiddler
Accept: image/png
Host: localhost:52649
GET http://localhost:52649/menu
throws UnsupportedMediaTypeException
@danielmarbach
danielmarbach / DoNotDisposeMultipleTimes.cs
Created January 11, 2013 07:56
"Microsoft.Usage", "CA2202:Do not dispose objects multiple times"
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream) { AutoFlush = true })
{
writer.Write(message.Xml);
stream.Seek(0, SeekOrigin.Begin);
this.documentSession.StoreAttachement(
"someId", null, stream, new RavenJObject { { "Content-Type", "application/xml" }, });
}
@danielmarbach
danielmarbach / MoqToFakeItEasy.DotSettings
Last active July 3, 2024 18:26
Structural Search and Replace Pattern for Migration from Moq to FakeItEasy with Resharper
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/Comment/@EntryValue">Replace Mock Field with FakeItEasy</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/CustomPatternPlaceholder/=fieldName/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/CustomPatternPlaceholder/=fieldName/Properties/=CaseSensitive/@EntryIndexedValue">True</s:String>
<s:String x:Key="/Default/PatternsAndTempla
@danielmarbach
danielmarbach / AssemblyInfo.cs
Created July 22, 2013 17:56
My InMemory approach for unit testing and acceptance testing with NServiceBus which uses custom IBus, FluentAssertions and NUnit actions
[assembly: WithBus]
@danielmarbach
danielmarbach / gist:9787441
Last active August 29, 2015 13:57
Mapping
namespace Here
{
public class Root
{
public string Foo { get; set; }
public Child Child { get; set; }