Skip to content

Instantly share code, notes, and snippets.

@thefringeninja
Last active August 29, 2015 14:14
Show Gist options
  • Save thefringeninja/f107e08182058b3defcb to your computer and use it in GitHub Desktop.
Save thefringeninja/f107e08182058b3defcb to your computer and use it in GitHub Desktop.
¯\_(ツ)_/¯
public static class RavenDocumentStore
{
static RavenDocumentStore()
{
using (Create())
{ }
}
private static Type FindAssemblyLoaderType<T>()
{
return (from type in typeof(T).Assembly.GetTypes()
where type.FullName == "Costura.AssemblyLoader"
select type).FirstOrDefault();
}
private static Action ಠ_ಠ<T>()
{
var attacherType = FindAssemblyLoaderType<T>();
var attachMethod = attacherType.GetMethod("Attach", BindingFlags.Static | BindingFlags.Public);
return () => attachMethod.Invoke(null, null);
}
public static void ForceAssemblyResolution<T>()
{
ಠ_ಠ<T>()();
}
public static IDocumentStore Create()
{
return new EmbeddableDocumentStore
{
RunInMemory = true,
Conventions =
{
DefaultQueryingConsistency = ConsistencyOptions.AlwaysWaitForNonStaleResultsAsOfLastWrite,
},
Configuration =
{
AssembliesDirectory = "~/assemblies-" + Guid.NewGuid().ToString("n")
}
}.Initialize();
}
}
@gregoryyoung
Copy link

Wow this is yucky.

@damianh
Copy link

damianh commented Feb 6, 2015

Don't use Fody Costura in libraries folks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment