本文整理汇总了C#中System.Dynamic.InvokeMemberBinder.NamedArgumentsToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# InvokeMemberBinder.NamedArgumentsToDictionary方法的具体用法?C# InvokeMemberBinder.NamedArgumentsToDictionary怎么用?C# InvokeMemberBinder.NamedArgumentsToDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.InvokeMemberBinder
的用法示例。
在下文中一共展示了InvokeMemberBinder.NamedArgumentsToDictionary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCriteriaDictionary
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;
}
示例2: ParseFromBinder
internal static IDictionary<string, object> ParseFromBinder(InvokeMemberBinder binder, IList<object> args)
{
if (binder == null) throw new ArgumentNullException("binder");
if (binder.CallInfo.ArgumentNames != null && binder.CallInfo.ArgumentNames.Count > 0)
{
return ParseFromMethodName(binder.Name, binder.NamedArgumentsToDictionary(args));
}
return ParseFromMethodName(binder.Name, args);
}
示例3: GetCriteriaExpression
private static SimpleExpression GetCriteriaExpression(InvokeMemberBinder binder, object[] args, DynamicTable table)
{
var criteria = binder.Name.Equals("delete", StringComparison.InvariantCultureIgnoreCase) ?
binder.NamedArgumentsToDictionary(args)
:
MethodNameParser.ParseFromBinder(binder, args);
return ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteria);
}
示例4: Execute
public object Execute(Database database, string tableName, InvokeMemberBinder binder, object[] args)
{
var criteria = binder.Name.Equals("delete", StringComparison.InvariantCultureIgnoreCase) ?
binder.NamedArgumentsToDictionary(args)
:
MethodNameParser.ParseFromBinder(binder, args);
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(tableName, criteria);
return database.Adapter.Delete(tableName, criteriaExpression);
}
示例5: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var criteria = args.OfType<SimpleExpression>().SingleOrDefault() ?? new SimpleEmptyExpression();
var data = binder.NamedArgumentsToDictionary(args).Where(kv=>!(kv.Value is SimpleExpression)).ToDictionary();
var updatedCount = dataStrategy.Update(table.GetQualifiedName(), data, criteria);
return updatedCount.ResultSetFromModifiedRowCount();
}
示例6: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
SimpleExpression criteriaExpression;
if (binder.Name.Equals("FindAllBy") || binder.Name.Equals("find_all_by"))
{
criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), binder.NamedArgumentsToDictionary(args));
}
else
{
criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
}
return new SimpleQuery(dataStrategy, table.GetQualifiedName()).Where(criteriaExpression);
}
示例7: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (binder.HasSingleUnnamedArgument())
{
return UpdateByKeyFields(table.GetQualifiedName(), dataStrategy, args[0],
MethodNameParser.ParseCriteriaNamesFromMethodName(binder.Name));
}
var criteria = MethodNameParser.ParseFromBinder(binder, args);
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteria);
var data = binder.NamedArgumentsToDictionary(args)
.Where(kvp => !criteria.ContainsKey(kvp.Key))
.ToDictionary();
return dataStrategy.Update(table.GetQualifiedName(), data, criteriaExpression);
}
示例8: Execute
public object Execute(Database database, string tableName, InvokeMemberBinder binder, object[] args)
{
if (binder.HasSingleUnnamedArgument())
{
return UpdateCommand.UpdateByKeyFields(tableName, database, args[0],
MethodNameParser.ParseCriteriaNamesFromMethodName(binder.Name));
}
var criteria = MethodNameParser.ParseFromBinder(binder, args);
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(tableName, criteria);
var data = binder.NamedArgumentsToDictionary(args)
.Where(kvp => !criteria.ContainsKey(kvp.Key))
.ToDictionary();
return database.Adapter.Update(tableName, data, criteriaExpression);
}
示例9: CreateCriteriaDictionary
private static IDictionary<string, object> CreateCriteriaDictionary(InvokeMemberBinder binder, IList<object> args)
{
IDictionary<string, object> criteriaDictionary = null;
if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
{
if (binder.CallInfo.ArgumentNames != null && binder.CallInfo.ArgumentNames.Count > 0)
{
criteriaDictionary = binder.NamedArgumentsToDictionary(args);
}
}
else
{
criteriaDictionary = MethodNameParser.ParseFromBinder(binder, args);
}
return criteriaDictionary;
}
示例10: ParseFromBinder
internal static IDictionary<string, object> ParseFromBinder(InvokeMemberBinder binder, IList<object> args)
{
if (binder == null) throw new ArgumentNullException("binder");
if (binder.CallInfo.ArgumentNames != null && binder.CallInfo.ArgumentNames.Count > 0)
{
return ParseFromMethodName(binder.Name, binder.NamedArgumentsToDictionary(args));
}
if (binder.Name.Equals("findby", StringComparison.OrdinalIgnoreCase) || binder.Name.Equals("find_by", StringComparison.OrdinalIgnoreCase))
{
if (args.Count == 1)
{
return args[0].ObjectToDictionary();
}
throw new InvalidOperationException("Invalid criteria specification.");
}
return ParseFromMethodName(binder.Name, args);
}
示例11: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var criteria = args.OfType<SimpleExpression>().SingleOrDefault() ?? new SimpleEmptyExpression();
var data = binder.NamedArgumentsToDictionary(args).Where(kv=>!(kv.Value is SimpleExpression)).ToDictionary();
if (data.Count == 0)
data = args.OfType<IDictionary<string, object>>().SingleOrDefault();
if (data == null)
{
throw new SimpleDataException("Could not resolve data.");
}
var updatedCount = dataStrategy.Run.Update(table.GetQualifiedName(), data, criteria);
return updatedCount.ResultSetFromModifiedRowCount();
}
示例12: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
object[] objects;
if (binder.CallInfo.ArgumentNames.Count > 0 && binder.CallInfo.ArgumentNames.All(s => !string.IsNullOrWhiteSpace(s)))
{
objects = new object[] {binder.NamedArgumentsToDictionary(args)};
}
else if (args.Length == 0 || args.Length > 2)
{
throw new ArgumentException("Incorrect number of arguments to Upsert method.");
}
else
{
objects = args;
}
var result = UpsertUsingKeys(dataStrategy, table, objects, !binder.IsResultDiscarded());
return ResultHelper.TypeResult(result, table, dataStrategy);
}
示例13: GetCriteriaExpression
private static SimpleExpression GetCriteriaExpression(InvokeMemberBinder binder, object[] args, DynamicTable table)
{
IDictionary<string, object> criteria;
if (binder.Name.Equals("delete", StringComparison.InvariantCultureIgnoreCase))
{
criteria = binder.NamedArgumentsToDictionary(args);
if (criteria.Count == 0 && args.Length == 1)
{
criteria = args[0] as IDictionary<string, object> ?? args[0].ObjectToDictionary();
}
}
else
{
criteria = MethodNameParser.ParseFromBinder(binder, args);
}
if (criteria.Count == 0) throw new InvalidOperationException("No criteria specified for Delete. To delete all data, use DeleteAll().");
return ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteria);
}
示例14: CreateCriteriaDictionary
private static IEnumerable<KeyValuePair<string, object>> CreateCriteriaDictionary(InvokeMemberBinder binder, IList<object> args)
{
IDictionary<string, object> criteriaDictionary = null;
if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
{
if (args.Count == 0) throw new ArgumentException("FindBy requires arguments.");
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);
}
return criteriaDictionary;
}
示例15: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
object result;
if (binder.HasSingleUnnamedArgument() || args.Length == 2 && args[1] is ErrorCallback)
{
result = UpsertByKeyFields(table.GetQualifiedName(), dataStrategy, args[0],
MethodNameParser.ParseCriteriaNamesFromMethodName(binder.Name),
!binder.IsResultDiscarded(),
args.Length == 2 ? (ErrorCallback)args[1] : ((item, exception) => false));
}
else
{
var criteria = MethodNameParser.ParseFromBinder(binder, args);
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(),
criteria);
var data = binder.NamedArgumentsToDictionary(args);
result = dataStrategy.Upsert(table.GetQualifiedName(), data, criteriaExpression, !binder.IsResultDiscarded());
}
return ResultHelper.TypeResult(result, table, dataStrategy);
}