Last active
August 29, 2015 14:14
-
-
Save thefringeninja/f107e08182058b3defcb to your computer and use it in GitHub Desktop.
¯\_(ツ)_/¯
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 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(); | |
} | |
} |
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
Wow this is yucky.