Ejemplo n.º 1
0
 /// <summary>
 /// Registers type mapping from CLR type to <see cref="AutoRegisteringObjectGraphType{T}"/> and/or <see cref="AutoRegisteringInputObjectGraphType{T}"/>.
 /// <br/>
 /// These mappings are used for type inference when constructing fields using expressions:
 /// <br/>
 /// <c>
 /// Field(x => x.Filters);
 /// </c>
 /// </summary>
 /// <param name="schema">The schema for which the mapping is registered.</param>
 /// <param name="clrType">The CLR property type from which to infer the GraphType.</param>
 /// <param name="mode">Which registering mode to use - input only, output only or both.</param>
 public static void AutoRegister(this ISchema schema, Type clrType, AutoRegisteringMode mode = AutoRegisteringMode.Both)
 {
     if (mode.HasFlag(AutoRegisteringMode.Output))
     {
         schema.RegisterTypeMapping(clrType, typeof(AutoRegisteringObjectGraphType <>).MakeGenericType(clrType));
     }
     if (mode.HasFlag(AutoRegisteringMode.Input))
     {
         schema.RegisterTypeMapping(clrType, typeof(AutoRegisteringInputObjectGraphType <>).MakeGenericType(clrType));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Registers type mapping from CLR type to <see cref="AutoRegisteringObjectGraphType{T}"/> and/or <see cref="AutoRegisteringInputObjectGraphType{T}"/>.
 /// <br/>
 /// These mappings are used for type inference when constructing fields using expressions:
 /// <br/>
 /// <c>
 /// Field(x => x.Filters);
 /// </c>
 /// </summary>
 /// <param name="schema">The schema for which the mapping is registered.</param>
 /// <typeparam name="TClrType">The CLR property type from which to infer the GraphType.</typeparam>
 /// <param name="mode">Which registering mode to use - input only, output only or both.</param>
 public static void AutoRegister <TClrType>(this ISchema schema, AutoRegisteringMode mode = AutoRegisteringMode.Both)
 {
     schema.AutoRegister(typeof(TClrType), mode);
 }