Created
October 10, 2017 18:35
-
-
Save mczachurski/1e1054240102af7480f1c805b6151dc0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 class GraphQLQuery : ObjectGraphType | |
{ | |
public GraphQLQuery(IServiceProvider serviceProvider) | |
{ | |
var type = typeof(IResolver); | |
var resolversTypes = AppDomain.CurrentDomain.GetAssemblies() | |
.SelectMany(s => s.GetTypes()) | |
.Where(p => type.IsAssignableFrom(p)); | |
foreach(var resolverType in resolversTypes) | |
{ | |
var resolverTypeInterface = resolverType.GetInterfaces().Where(x => x != type).FirstOrDefault(); | |
if(resolverTypeInterface != null) | |
{ | |
var resolver = serviceProvider.GetService(resolverTypeInterface) as IResolver; | |
resolver.Resolve(this); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment