Skip to content

Instantly share code, notes, and snippets.

@imwower
imwower / IsAssignableFrom
Created April 29, 2014 07:18
reflect types to find implement from interface
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var assembly = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory+ "ConsoleApplication2.exe");
var types = assembly.GetTypes();
var interfaces = types.Where(t => t.IsInterface);
var implemetions = types.Where(t => !t.IsInterface && !t.IsAbstract);
@imwower
imwower / RestSharpJsonDeserializer
Created April 28, 2014 15:40
newtonsoft.json deserializer for restsharp
public class RestSharpJsonDeserializer : IDeserializer
{
private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
public string DateFormat { get; set; }
@imwower
imwower / estSharpJsonSerializer
Created April 28, 2014 15:40
newtonsoft.json serializer for restsharp
public class RestSharpJsonSerializer : ISerializer
{
private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
public RestSharpJsonSerializer()
{
@imwower
imwower / LoadAssemblies
Last active August 29, 2015 14:00
dynamic load assemblies from asp.net project folder
//folder is virtual path
private void LoadAssemblies(string folder)
{
try
{
var directory = new DirectoryInfo(HostingEnvironment.MapPath(folder));
var binFiles = directory.GetFiles("*.dll", SearchOption.AllDirectories).ToList();
if (binFiles.Count == 0)
{
logger.Warn("no dlls found!");