本文整理汇总了C#中IRequest.CreateBlock方法的典型用法代码示例。如果您正苦于以下问题:C# IRequest.CreateBlock方法的具体用法?C# IRequest.CreateBlock怎么用?C# IRequest.CreateBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRequest
的用法示例。
在下文中一共展示了IRequest.CreateBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertArguments
private object[] ConvertArguments(MethodInfo methodInfo, IRequest request, Field[] args)
{
var methodParams = methodInfo.GetParameters();
if (methodParams.Length != args.Length)
throw new InvalidOperationException(); // TODO: support the case of the Unbounded parameters
var values = new object[args.Length];
for (int i = 0; i < args.Length; i++) {
var paramType = methodParams[i].ParameterType;
if ((paramType == typeof (ISession) ||
paramType == typeof(IRequest) ||
paramType == typeof(IQuery)) &&
i > 0)
throw new InvalidOperationException("The request parameter must be the first in method signature.");
object arg;
if (paramType == typeof (ISession)) {
arg = request.Query.Session;
} else if (paramType == typeof (IQuery)) {
arg = request.Query;
} else if (paramType == typeof(IRequest)) {
arg = request.CreateBlock();
} else {
var sqlType = PrimitiveTypes.FromType(paramType);
arg = sqlType.ConvertTo(args[i].Value, paramType);
}
values[i] = arg;
}
return values;
}
示例2: Fire
public void Fire(TableEvent tableEvent, IRequest context)
{
var oldState = GetOldState(context);
try {
var triggerType = TriggerInfo.TriggerType;
var tableName = tableEvent.Table.TableInfo.TableName;
context.Context.OnEvent(new TriggerEvent(triggerType, Name, tableName, tableEvent.EventTime, tableEvent.EventType,
tableEvent.OldRowId, tableEvent.NewRow));
var newState = new OldNewTableState(tableName, tableEvent.OldRowId.RowNumber, tableEvent.NewRow,
tableEvent.EventTime == TriggerEventTime.Before);
SetState(context, newState);
using (var block = context.CreateBlock()) {
FireTrigger(tableEvent, block);
}
} catch (TriggerException) {
throw;
} catch (Exception ex) {
throw new TriggerException(String.Format("An unknown error occurred while executing trigger '{0}'.", Name), ex);
} finally {
SetState(context, oldState);
}
}