コード例 #1
0
 private static Type GetIDictionaryType(MapTypeContext context)
 {
     return(context.TargetType.GetInterfaces()
            .Where(i => i.IsGenericType)
            .FirstOrDefault(i => i.GetGenericTypeDefinition() == typeof(IDictionary <,>) && i.GenericTypeArguments[0] == typeof(string))
            ?? throw MapCompilerException.InvalidDictionaryTargetType(context.TargetType));
 }
コード例 #2
0
 private static ConstructorInfo GetDictionaryConstructor(Type targetType)
 {
     return(targetType.GetConstructor(Type.EmptyTypes) ?? throw MapCompilerException.InvalidDictionaryTargetType(targetType));
 }
コード例 #3
0
 private static MethodInfo GetIDictionaryAddMethod(Type targetType, Type idictType)
 {
     return(idictType.GetMethod(nameof(IDictionary <string, object> .Add)) ?? throw MapCompilerException.InvalidDictionaryTargetType(targetType));
 }