forked from markrendle/Simple.Data
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
478cc90
commit 782ea4c
Showing
29 changed files
with
136 additions
and
216 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Simple.Data.Commands | ||
{ | ||
using System.Dynamic; | ||
using Extensions; | ||
|
||
internal static class ArgumentHelper | ||
{ | ||
internal static void CheckFindArgs(object[] args, InvokeMemberBinder binder) | ||
{ | ||
if (args.Length == 0) throw new ArgumentException(binder.Name + "requires arguments."); | ||
if (args.Length == 1) | ||
{ | ||
if (ReferenceEquals(args[0], null) && binder.CallInfo.ArgumentNames.Count == 0) | ||
throw new ArgumentException(binder.Name + " does not accept unnamed null argument."); | ||
} | ||
} | ||
|
||
internal static IEnumerable<KeyValuePair<string, object>> CreateCriteriaDictionary(InvokeMemberBinder binder, IList<object> args, params string[] exactNames) | ||
{ | ||
IDictionary<string, object> criteriaDictionary = null; | ||
if (exactNames.Contains(binder.Name)) | ||
{ | ||
if (binder.CallInfo.ArgumentNames != null && binder.CallInfo.ArgumentNames.Count > 0) | ||
{ | ||
criteriaDictionary = binder.NamedArgumentsToDictionary(args); | ||
} | ||
else if (args.Count == 1) | ||
{ | ||
if (ReferenceEquals(args[0], null)) throw new ArgumentException("FindBy does not accept unnamed null argument."); | ||
criteriaDictionary = args[0].ObjectToDictionary(); | ||
} | ||
} | ||
else | ||
{ | ||
criteriaDictionary = MethodNameParser.ParseFromBinder(binder, args); | ||
} | ||
|
||
if (criteriaDictionary == null || criteriaDictionary.Count == 0) | ||
{ | ||
throw new ArgumentException(binder.Name + " requires an equal number of column names and values to filter data by."); | ||
} | ||
return criteriaDictionary; | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.