private static IEnumerable <ResourceDescriptor> FindIdentifiableTypes(Assembly assembly) { foreach (var type in assembly.GetTypes()) { if (TypeLocator.TryGetResourceDescriptor(type, out var descriptor)) { yield return(descriptor); } } }
private static IEnumerable <ResourceDescriptor> ScanForResourceDescriptors(Assembly assembly) { foreach (var type in assembly.GetTypes()) { var resourceDescriptor = TypeLocator.TryGetResourceDescriptor(type); if (resourceDescriptor != null) { yield return(resourceDescriptor); } } }
private static HashSet <ResourceDescriptor> GetResourceTypesFromServiceImplementation(Type type) { var resourceDescriptors = new HashSet <ResourceDescriptor>(); var interfaces = type.GetInterfaces(); foreach (var i in interfaces) { if (i.IsGenericType) { var firstGenericArgument = i.GenericTypeArguments.FirstOrDefault(); if (TypeLocator.TryGetResourceDescriptor(firstGenericArgument, out var resourceDescriptor)) { resourceDescriptors.Add(resourceDescriptor); } } } return(resourceDescriptors); }
private static ResourceDescriptor TryGetResourceTypeFromServiceImplementation(Type serviceType) { foreach (Type @interface in serviceType.GetInterfaces()) { Type firstGenericArgument = @interface.IsGenericType ? @interface.GenericTypeArguments.First() : null; if (firstGenericArgument != null) { ResourceDescriptor resourceDescriptor = TypeLocator.TryGetResourceDescriptor(firstGenericArgument); if (resourceDescriptor != null) { return(resourceDescriptor); } } } return(null); }