/// <summary>
 /// Add all reflected properties as fields (unless they are specified in <paramref name="excludedProperties"/>.
 /// </summary>
 /// <typeparam name="TSourceType"></typeparam>
 /// <param name="type"></param>
 /// <param name="excludedProperties"></param>
 public static void AddAllPropertiesAsFields <TSourceType>(this ComplexGraphType <TSourceType> type, params Expression <Func <TSourceType, object> >[] excludedProperties)
 {
     GraphObjectTypeReflectionHelper.SetFields(
         type,
         GetRegisteredProperties(typeof(TSourceType)),
         new GraphObjectTypeReflectionOptions <TSourceType>
     {
         ExcludedProperties = excludedProperties,
     }
         );
 }
 /// <summary>
 /// Add all reflected properties as fields (unless they are specified in <paramref name="excludedProperties"/>.
 ///
 /// Properties with names already registered will be excluded automatically, allowing you to do this after first specifying those fields you want to control manually.
 /// </summary>
 /// <typeparam name="TSourceType"></typeparam>
 /// <param name="type"></param>
 /// <param name="nullable"></param>
 /// <param name="excludedProperties"></param>
 public static void AddRemainingPropertiesAsFields <TSourceType>(this ComplexGraphType <TSourceType> type, bool?nullable = null, params Expression <Func <TSourceType, object> >[] excludedProperties)
 {
     GraphObjectTypeReflectionHelper.SetFields(
         type,
         GetRegisteredProperties(typeof(TSourceType)),
         new GraphObjectTypeReflectionOptions <TSourceType>
     {
         Nullable           = nullable,
         ExcludedProperties = excludedProperties,
         SkipExisting       = true,
     }
         );
 }
Exemple #3
0
 protected virtual IEnumerable <PropertyInfo> GetRegisteredProperties()
 {
     return(typeof(TSourceType)
            .GetProperties(BindingFlags.Public | BindingFlags.Instance)
            .Where(p => GraphObjectTypeReflectionHelper.IsEnabledForRegister(p.PropertyType, true)));
 }
Exemple #4
0
 /// <summary>
 /// Creates a GraphQL type from <typeparamref name="TSourceType"/> by specifying additional options.
 /// </summary>
 public ReflectedInputObjectGraphType(GraphObjectTypeReflectionOptions <TSourceType> options)
 {
     GraphObjectTypeReflectionHelper.SetFields(this, GetRegisteredProperties(), options);
 }
 private static IEnumerable <PropertyInfo> GetRegisteredProperties(Type sourceType)
 {
     return(sourceType
            .GetProperties(BindingFlags.Public | BindingFlags.Instance)
            .Where(p => GraphObjectTypeReflectionHelper.IsEnabledForRegister(p.PropertyType, true)));
 }