private bool TryCreateImplicitSorting( PropertyInfo property, [NotNullWhen(true)] out SortOperationDefintion?definition) { Type type = property.PropertyType; if (type.IsGenericType && System.Nullable.GetUnderlyingType(type) is { } nullableType) { type = nullableType; } if (typeof(IComparable).IsAssignableFrom(type)) { definition = SortOperationDescriptor .CreateOperation(property, Context) .CreateDefinition(); return(true); } if (Context.TypeInspector.TryCreateTypeInfo(type, out ITypeInfo? typeInfo) && typeInfo.GetExtendedType()?.IsList is {} isList) { if (type.IsClass && !isList) { definition = SortObjectOperationDescriptor .CreateOperation(property, Context) .CreateDefinition(); return(true); } } definition = null; return(false); }
private bool TryCreateImplicitSorting( PropertyInfo property, out SortOperationDefintion definition) { Type type = property.PropertyType; if (type.IsGenericType && System.Nullable.GetUnderlyingType(type) is Type nullableType) { type = nullableType; } if (typeof(IComparable).IsAssignableFrom(type)) { definition = SortOperationDescriptor .CreateOperation(property, Context) .CreateDefinition(); return(true); } if (type.IsClass && !DotNetTypeInfoFactory.IsListType(type)) { definition = SortObjectOperationDescriptor .CreateOperation(property, Context) .CreateDefinition(); return(true); } definition = null; return(false); }
public ISortObjectOperationDescriptor <TObject> SortableObject <TObject>( Expression <Func <T, TObject> > property) where TObject : class { if (property.ExtractMember() is PropertyInfo p) { return(Fields.GetOrAddDescriptor(p, () => SortObjectOperationDescriptor <TObject> .CreateOperation(p, Context))); } // TODO : resources throw new ArgumentException( "Only properties are allowed for input types.", nameof(property)); }
public ISortObjectOperationDescriptor <TObject> SortableObject <TObject>( Expression <Func <T, TObject> > property) where TObject : class { if (property.ExtractMember() is PropertyInfo p) { return(Fields.GetOrAddDescriptor(p, () => SortObjectOperationDescriptor <TObject> .CreateOperation(p, Context))); } // TODO : resources throw new ArgumentException( SortingResources.SortInputTypeDescriptor_Ignore_OnlyPopertiesAreAllowed, nameof(property)); }
public new static SortObjectOperationDescriptor <TObject> CreateOperation( PropertyInfo property, IDescriptorContext context) { var operation = new SortOperation(property, true); var name = context.Naming.GetMemberName(property, MemberKind.InputObjectField); var typeReference = new ClrTypeReference( typeof(SortInputType <>).MakeGenericType(typeof(TObject)), TypeContext.Input); return(SortObjectOperationDescriptor <TObject> .New( context, name, typeReference, operation)); }
public static SortObjectOperationDescriptor CreateOperation( PropertyInfo property, IDescriptorContext context) { Type type = property.PropertyType; var operation = new SortOperation(property, true); NameString name = context.Naming.GetMemberName( property, MemberKind.InputObjectField); var typeReference = context.TypeInspector.GetTypeRef( typeof(SortInputType <>).MakeGenericType(type), TypeContext.Input); return(SortObjectOperationDescriptor.New( context, name, typeReference, operation)); }
private bool TryCreateImplicitSorting( PropertyInfo property, out SortOperationDefintion definition) { if (typeof(IComparable).IsAssignableFrom(property.PropertyType)) { definition = SortOperationDescriptor .CreateOperation(property, Context) .CreateDefinition(); return(true); } if ( property.PropertyType.IsClass && !typeof(IEnumerable <>).IsAssignableFrom(property.PropertyType)) { definition = SortObjectOperationDescriptor .CreateOperation(property, Context) .CreateDefinition(); return(true); } definition = null; return(false); }