public static Type GetBuilderType(this Type adapteeType) { if (adapteeType == null) { throw new ArgumentNullException(nameof(adapteeType)); } var result = Adaptable.GetAdapterType(adapteeType, AdapterRole.Builder); if (result == null || AdapterRole.IsBuilderType(result, adapteeType)) { return(result); } return(null); }
private static Type GetConventionAdapterType(Type adapteeType, string adapterRoleName) { if (IsSupportedAdapter(adapterRoleName)) { string qualifierName = adapteeType.Namespace + "."; if (string.IsNullOrEmpty(adapteeType.Namespace)) { qualifierName = null; } if (adapteeType.GetTypeInfo().DeclaringType != null) { qualifierName = adapteeType.DeclaringType.FullName + "+"; } // Get the type which is named by convention for this adapter role. // Replacing the - in the conventions map gives us the lookup string conventionType = qualifierName + Conventions[adapterRoleName].Replace("-", adapteeType.Name); var result = adapteeType.GetTypeInfo().Assembly.GetType(conventionType); if (result == null) { return(null); } switch (adapterRoleName) { case "Builder": return(AdapterRole.IsBuilderType(result, adapteeType) ? result : null); case "StreamingSource": return(AdapterRole.IsStreamingSourceType(result) ? result : null); case "ActivationProvider": return(AdapterRole.IsActivationProviderType(result) ? result : null); case "Template": return(AdapterRole.IsTemplateType(result) ? result : null); case "Null": return(result); } } return(null); }