mirror of
				https://github.com/Biarity/Sieve.git
				synced 2025-10-31 08:49:15 +01:00 
			
		
		
		
	Style fixes
This commit is contained in:
		| @@ -1,9 +1,9 @@ | |||||||
| using Sieve.Models; | using System; | ||||||
| using System; | using Sieve.Models; | ||||||
|  |  | ||||||
| namespace Sieve.Attributes | namespace Sieve.Attributes | ||||||
| { | { | ||||||
| 	[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] |     [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] | ||||||
|     public class SieveAttribute : Attribute, ISievePropertyMetadata |     public class SieveAttribute : Attribute, ISievePropertyMetadata | ||||||
|     { |     { | ||||||
|         /// <summary> |         /// <summary> | ||||||
|   | |||||||
| @@ -1,7 +1,5 @@ | |||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Reflection; | using System.Reflection; | ||||||
| using System.Text; |  | ||||||
|  |  | ||||||
| namespace Sieve.Extensions | namespace Sieve.Extensions | ||||||
| { | { | ||||||
| @@ -74,7 +72,7 @@ namespace Sieve.Extensions | |||||||
|                 // Check that the parameter counts and types match,  |                 // Check that the parameter counts and types match,  | ||||||
|                 // with 'loose' matching on generic parameters |                 // with 'loose' matching on generic parameters | ||||||
|                 ParameterInfo[] parameterInfos = methodInfo.GetParameters(); |                 ParameterInfo[] parameterInfos = methodInfo.GetParameters(); | ||||||
|                  |  | ||||||
|                 if (parameterInfos[0].ParameterType.IsSimilarType(firstType)) |                 if (parameterInfos[0].ParameterType.IsSimilarType(firstType)) | ||||||
|                 { |                 { | ||||||
|                     if (matchingMethod == null) |                     if (matchingMethod == null) | ||||||
|   | |||||||
| @@ -5,17 +5,17 @@ using System.Reflection; | |||||||
|  |  | ||||||
| namespace Sieve.Extensions | namespace Sieve.Extensions | ||||||
| { | { | ||||||
| 	public static partial class LinqExtentions |     public static partial class LinqExtentions | ||||||
|     { |     { | ||||||
|         public static IQueryable<TEntity> OrderByDynamic<TEntity>(this IQueryable<TEntity> source, string fullPropertyName, PropertyInfo propertyInfo, |         public static IQueryable<TEntity> OrderByDynamic<TEntity>(this IQueryable<TEntity> source, string fullPropertyName, PropertyInfo propertyInfo, | ||||||
|                           bool desc, bool useThenBy) |                           bool desc, bool useThenBy) | ||||||
|         { |         { | ||||||
|             string command = desc ? |             string command = desc ? | ||||||
|                 ( useThenBy ? "ThenByDescending" : "OrderByDescending") : |                 (useThenBy ? "ThenByDescending" : "OrderByDescending") : | ||||||
|                 ( useThenBy ? "ThenBy" : "OrderBy"); |                 (useThenBy ? "ThenBy" : "OrderBy"); | ||||||
|             var type = typeof(TEntity); |             var type = typeof(TEntity); | ||||||
|             var parameter = Expression.Parameter(type, "p"); |             var parameter = Expression.Parameter(type, "p"); | ||||||
|              |  | ||||||
|             dynamic propertyValue = parameter; |             dynamic propertyValue = parameter; | ||||||
|             if (fullPropertyName.Contains(".")) |             if (fullPropertyName.Contains(".")) | ||||||
|             { |             { | ||||||
| @@ -25,7 +25,7 @@ namespace Sieve.Extensions | |||||||
|                     propertyValue = Expression.PropertyOrField(propertyValue, parts[i]); |                     propertyValue = Expression.PropertyOrField(propertyValue, parts[i]); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|              |  | ||||||
|             var propertyAccess = Expression.MakeMemberAccess(propertyValue, propertyInfo); |             var propertyAccess = Expression.MakeMemberAccess(propertyValue, propertyInfo); | ||||||
|             var orderByExpression = Expression.Lambda(propertyAccess, parameter); |             var orderByExpression = Expression.Lambda(propertyAccess, parameter); | ||||||
|             var resultExpression = Expression.Call(typeof(Queryable), command, new Type[] { type, propertyInfo.PropertyType }, |             var resultExpression = Expression.Call(typeof(Queryable), command, new Type[] { type, propertyInfo.PropertyType }, | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| namespace Sieve.Models | namespace Sieve.Models | ||||||
| { | { | ||||||
| 	public enum FilterOperator |     public enum FilterOperator | ||||||
|     { |     { | ||||||
|         Equals, |         Equals, | ||||||
|         NotEquals, |         NotEquals, | ||||||
|   | |||||||
| @@ -1,5 +1,4 @@ | |||||||
| using System; | using System.Collections.Generic; | ||||||
| using System.Collections.Generic; |  | ||||||
|  |  | ||||||
| namespace Sieve.Models | namespace Sieve.Models | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| namespace Sieve.Models | namespace Sieve.Models | ||||||
| { | { | ||||||
| 	public interface ISievePropertyMetadata |     public interface ISievePropertyMetadata | ||||||
|     { |     { | ||||||
|         string Name { get; set; } |         string Name { get; set; } | ||||||
|         string FullName { get; } |         string FullName { get; } | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| namespace Sieve.Models | namespace Sieve.Models | ||||||
| { | { | ||||||
| 	public interface ISortTerm |     public interface ISortTerm | ||||||
|     { |     { | ||||||
|         string Sort { set; } |         string Sort { set; } | ||||||
|         bool Descending { get; } |         bool Descending { get; } | ||||||
|   | |||||||
| @@ -1,5 +1,4 @@ | |||||||
| using System; | using System.Collections.Generic; | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.ComponentModel.DataAnnotations; | using System.ComponentModel.DataAnnotations; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Runtime.Serialization; | using System.Runtime.Serialization; | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| namespace Sieve.Models | namespace Sieve.Models | ||||||
| { | { | ||||||
| 	public class SieveOptions |     public class SieveOptions | ||||||
|     { |     { | ||||||
|         public bool CaseSensitive { get; set; } = false; |         public bool CaseSensitive { get; set; } = false; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| namespace Sieve.Models | namespace Sieve.Models | ||||||
| { | { | ||||||
| 	public class SievePropertyMetadata : ISievePropertyMetadata |     public class SievePropertyMetadata : ISievePropertyMetadata | ||||||
|     { |     { | ||||||
|         public string Name { get; set; } |         public string Name { get; set; } | ||||||
|         public string FullName { get; set; } |         public string FullName { get; set; } | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ namespace Sieve.Models | |||||||
|         public SortTerm() { } |         public SortTerm() { } | ||||||
|  |  | ||||||
|         private string _sort; |         private string _sort; | ||||||
|          |  | ||||||
|         public string Sort |         public string Sort | ||||||
|         { |         { | ||||||
|             set |             set | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| namespace Sieve.Services | namespace Sieve.Services | ||||||
| { | { | ||||||
| 	public interface ISieveCustomFilterMethods |     public interface ISieveCustomFilterMethods | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| namespace Sieve.Services | namespace Sieve.Services | ||||||
| { | { | ||||||
| 	public interface ISieveCustomSortMethods |     public interface ISieveCustomSortMethods | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -227,7 +227,7 @@ namespace Sieve.Services | |||||||
|                     } |                     } | ||||||
|                     else |                     else | ||||||
|                     { |                     { | ||||||
|                         result = ApplyCustomMethod(result, filterTermName, _customFilterMethods,  |                         result = ApplyCustomMethod(result, filterTermName, _customFilterMethods, | ||||||
|                             new object[] { |                             new object[] { | ||||||
|                                             result, |                                             result, | ||||||
|                                             filterTerm.Operator, |                                             filterTerm.Operator, | ||||||
| @@ -356,13 +356,13 @@ namespace Sieve.Services | |||||||
|             string name) |             string name) | ||||||
|         { |         { | ||||||
|             var property = mapper.FindProperty<TEntity>(canSortRequired, canFilterRequired, name, _options.Value.CaseSensitive); |             var property = mapper.FindProperty<TEntity>(canSortRequired, canFilterRequired, name, _options.Value.CaseSensitive); | ||||||
|             if(property.Item1 == null) |             if (property.Item1 == null) | ||||||
|             { |             { | ||||||
|                 var prop = FindPropertyBySieveAttribute<TEntity>(canSortRequired, canFilterRequired, name, _options.Value.CaseSensitive); |                 var prop = FindPropertyBySieveAttribute<TEntity>(canSortRequired, canFilterRequired, name, _options.Value.CaseSensitive); | ||||||
|                 return (prop?.Name, prop); |                 return (prop?.Name, prop); | ||||||
|             } |             } | ||||||
|             return property; |             return property; | ||||||
|                  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private PropertyInfo FindPropertyBySieveAttribute<TEntity>( |         private PropertyInfo FindPropertyBySieveAttribute<TEntity>( | ||||||
|   | |||||||
| @@ -1,20 +1,20 @@ | |||||||
| using Sieve.Models; | using System; | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Linq.Expressions; | using System.Linq.Expressions; | ||||||
| using System.Reflection; | using System.Reflection; | ||||||
|  | using Sieve.Models; | ||||||
|  |  | ||||||
| namespace Sieve.Services | namespace Sieve.Services | ||||||
| { | { | ||||||
| 	public class SievePropertyMapper |     public class SievePropertyMapper | ||||||
|     { |     { | ||||||
|         private readonly Dictionary<Type, ICollection<KeyValuePair<PropertyInfo, ISievePropertyMetadata>>> _map |         private readonly Dictionary<Type, ICollection<KeyValuePair<PropertyInfo, ISievePropertyMetadata>>> _map | ||||||
|             = new Dictionary<Type, ICollection<KeyValuePair<PropertyInfo, ISievePropertyMetadata>>>(); |             = new Dictionary<Type, ICollection<KeyValuePair<PropertyInfo, ISievePropertyMetadata>>>(); | ||||||
|  |  | ||||||
|         public PropertyFluentApi<TEntity> Property<TEntity>(Expression<Func<TEntity, object>> expression) |         public PropertyFluentApi<TEntity> Property<TEntity>(Expression<Func<TEntity, object>> expression) | ||||||
|         { |         { | ||||||
|             if(!_map.ContainsKey(typeof(TEntity))) |             if (!_map.ContainsKey(typeof(TEntity))) | ||||||
|             { |             { | ||||||
|                 _map.Add(typeof(TEntity), new List<KeyValuePair<PropertyInfo, ISievePropertyMetadata>>()); |                 _map.Add(typeof(TEntity), new List<KeyValuePair<PropertyInfo, ISievePropertyMetadata>>()); | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user