-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edited namespaces and added globalusing.
- Loading branch information
1 parent
d8123cf
commit 7b908aa
Showing
13 changed files
with
544 additions
and
573 deletions.
There are no files selected for viewing
19 changes: 8 additions & 11 deletions
19
src/SmartWhere/Attributes/ComparativeWhereCaluseAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
using SmartWhere.Enums; | ||
namespace SmartWhere.Attributes; | ||
|
||
namespace SmartWhere.Attributes | ||
public class ComparativeWhereCaluseAttribute : WhereClauseAttribute | ||
{ | ||
public class ComparativeWhereCaluseAttribute : WhereClauseAttribute | ||
{ | ||
public ComparisonOperator ComparisonOperator { get; set; } | ||
public ComparisonOperator ComparisonOperator { get; set; } | ||
|
||
public ComparativeWhereCaluseAttribute(ComparisonOperator comparisonOperator, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(logicalOperator) => ComparisonOperator = comparisonOperator; | ||
public ComparativeWhereCaluseAttribute(ComparisonOperator comparisonOperator, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(logicalOperator) => ComparisonOperator = comparisonOperator; | ||
|
||
public ComparativeWhereCaluseAttribute(string propertyName, ComparisonOperator comparisonOperator, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(propertyName, logicalOperator) => ComparisonOperator = comparisonOperator; | ||
} | ||
} | ||
public ComparativeWhereCaluseAttribute(string propertyName, ComparisonOperator comparisonOperator, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(propertyName, logicalOperator) => ComparisonOperator = comparisonOperator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
using SmartWhere.Enums; | ||
namespace SmartWhere.Attributes; | ||
|
||
namespace SmartWhere.Attributes | ||
public class TextualWhereClauseAttribute : WhereClauseAttribute | ||
{ | ||
public class TextualWhereClauseAttribute : WhereClauseAttribute | ||
{ | ||
public StringMethod StringMethod { get; set; } | ||
public StringMethod StringMethod { get; set; } | ||
|
||
public TextualWhereClauseAttribute(StringMethod method, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(logicalOperator) => StringMethod = method; | ||
public TextualWhereClauseAttribute(StringMethod method, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(logicalOperator) => StringMethod = method; | ||
|
||
public TextualWhereClauseAttribute(string propertyName, StringMethod method, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(propertyName, logicalOperator) => StringMethod = method; | ||
} | ||
} | ||
public TextualWhereClauseAttribute(string propertyName, StringMethod method, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
: base(propertyName, logicalOperator) => StringMethod = method; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
using SmartWhere.Enums; | ||
using System; | ||
namespace SmartWhere.Attributes; | ||
|
||
namespace SmartWhere.Attributes | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public class WhereClauseAttribute : Attribute | ||
{ | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public class WhereClauseAttribute : Attribute | ||
{ | ||
public string PropertyName { get; set; } | ||
public string PropertyName { get; set; } | ||
|
||
public LogicalOperator LogicalOperator { get; set; } | ||
public LogicalOperator LogicalOperator { get; set; } | ||
|
||
public WhereClauseAttribute(LogicalOperator logicalOperator = LogicalOperator.AND) => LogicalOperator = logicalOperator; | ||
public WhereClauseAttribute(LogicalOperator logicalOperator = LogicalOperator.AND) => LogicalOperator = logicalOperator; | ||
|
||
public WhereClauseAttribute(string propertyName, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
{ | ||
PropertyName = propertyName; | ||
LogicalOperator = logicalOperator; | ||
} | ||
public WhereClauseAttribute(string propertyName, LogicalOperator logicalOperator = LogicalOperator.AND) | ||
{ | ||
PropertyName = propertyName; | ||
LogicalOperator = logicalOperator; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
using System; | ||
namespace SmartWhere.Attributes; | ||
|
||
namespace SmartWhere.Attributes | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public class WhereClauseClassAttribute : Attribute | ||
{ | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public class WhereClauseClassAttribute : Attribute | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
namespace SmartWhere.Enums | ||
namespace SmartWhere.Enums; | ||
|
||
public enum ComparisonOperator | ||
{ | ||
public enum ComparisonOperator | ||
{ | ||
Equal, | ||
NotEqual, | ||
GreaterThan, | ||
NotGreaterThan, | ||
GreaterThanOrEqual, | ||
NotGreaterThanOrEqual, | ||
LessThan, | ||
NotLessThan, | ||
LessThanOrEqual, | ||
NotLessThanOrEqual | ||
} | ||
} | ||
Equal, | ||
NotEqual, | ||
GreaterThan, | ||
NotGreaterThan, | ||
GreaterThanOrEqual, | ||
NotGreaterThanOrEqual, | ||
LessThan, | ||
NotLessThan, | ||
LessThanOrEqual, | ||
NotLessThanOrEqual | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
namespace SmartWhere.Enums | ||
namespace SmartWhere.Enums; | ||
|
||
public enum StringMethod | ||
{ | ||
public enum StringMethod | ||
{ | ||
Contains, | ||
NotContains, | ||
StartsWith, | ||
NotStartsWith, | ||
EndsWith, | ||
NotEndsWith | ||
} | ||
} | ||
Contains, | ||
NotContains, | ||
StartsWith, | ||
NotStartsWith, | ||
EndsWith, | ||
NotEndsWith | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
using SmartWhere.Attributes; | ||
using SmartWhere.Enums; | ||
using System.Reflection; | ||
namespace SmartWhere.Extensions; | ||
|
||
namespace SmartWhere.Extensions | ||
internal static class AttributeExtensions | ||
{ | ||
public static class AttributeExtensions | ||
{ | ||
internal static WhereClauseAttribute GetWhereClauseAttribute(this MemberInfo memberInfo) => | ||
(WhereClauseAttribute)memberInfo.GetCustomAttribute(typeof(WhereClauseAttribute), false); | ||
internal static WhereClauseAttribute GetWhereClauseAttribute(this MemberInfo memberInfo) => | ||
(WhereClauseAttribute)memberInfo.GetCustomAttribute(typeof(WhereClauseAttribute), false); | ||
|
||
internal static WhereClauseClassAttribute GetWhereClauseClassAttribute(this MemberInfo memberInfo) => | ||
(WhereClauseClassAttribute)memberInfo.GetCustomAttribute(typeof(WhereClauseClassAttribute), false); | ||
internal static WhereClauseClassAttribute GetWhereClauseClassAttribute(this MemberInfo memberInfo) => | ||
(WhereClauseClassAttribute)memberInfo.GetCustomAttribute(typeof(WhereClauseClassAttribute), false); | ||
|
||
internal static MethodInfo MethodInfo(this TextualWhereClauseAttribute textualWhereClause) | ||
internal static MethodInfo MethodInfo(this TextualWhereClauseAttribute textualWhereClause) | ||
{ | ||
var methodName = textualWhereClause.StringMethod switch | ||
{ | ||
var methodName = textualWhereClause.StringMethod switch | ||
{ | ||
StringMethod.Contains => textualWhereClause.StringMethod.ToString(), | ||
StringMethod.StartsWith => textualWhereClause.StringMethod.ToString(), | ||
StringMethod.EndsWith => textualWhereClause.StringMethod.ToString(), | ||
StringMethod.NotContains => nameof(StringMethod.Contains), | ||
StringMethod.NotStartsWith => nameof(StringMethod.StartsWith), | ||
StringMethod.NotEndsWith => nameof(StringMethod.EndsWith), | ||
_ => nameof(StringMethod.Contains) | ||
}; | ||
StringMethod.Contains => textualWhereClause.StringMethod.ToString(), | ||
StringMethod.StartsWith => textualWhereClause.StringMethod.ToString(), | ||
StringMethod.EndsWith => textualWhereClause.StringMethod.ToString(), | ||
StringMethod.NotContains => nameof(StringMethod.Contains), | ||
StringMethod.NotStartsWith => nameof(StringMethod.StartsWith), | ||
StringMethod.NotEndsWith => nameof(StringMethod.EndsWith), | ||
_ => nameof(StringMethod.Contains) | ||
}; | ||
|
||
return typeof(string).GetMethod(methodName, new[] { typeof(string) | ||
}); | ||
} | ||
return typeof(string).GetMethod(methodName, new[] { typeof(string) | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.