本文整理汇总了C#中Params.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Params.Set方法的具体用法?C# Params.Set怎么用?C# Params.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Params
的用法示例。
在下文中一共展示了Params.Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
//.........这里部分代码省略.........
controllerName = last[1];
actionName = last[2];
id = 0;
}
// If the middle one is an int, the first should be the controller and the last could be an action or a controller
// .../controller/12/action_or_controller
else if (int.TryParse(last[1], out id) && _controllers.ContainsKey(last[0])) {
controller = _controllers[last[0]].Prototype;
// If the last part is a method on the controller, do that
if (controller.HasMethod(last[2].ToCamelCase())) {
controllerName = last[0];
actionName = last[2];
}
// Else, the last part must be a controller
else if (_controllers.ContainsKey(last[2])) {
controllerName = last[2];
actionName = "index";
id = 0;
}
// Else, false alarm
else {
}
}
// Check the rest of the parts for IDs
int partID, tryID;
for (var i = 1; i < segments.Length; i++) {
if (int.TryParse(segments[i], out partID) && !int.TryParse(segments[i - 1], out tryID))
parameters.Set(segments[i - 1].ToLower() + "_id", partID.ToString());
}
break;
}
// Check if the controller exists and action is not empty
if (string.IsNullOrEmpty(controllerName) || !_controllers.ContainsKey(controllerName) || string.IsNullOrEmpty(actionName))
return ProcessingResult.Continue;
// Get the controller context and set action name to camelcase
controllerContext = _controllers[controllerName];
actionName = actionName.ToCamelCase();
// Set id in parameters
if (id > 0)
parameters.Set("id", id.ToString());
// Check if controller has method
if (!controllerContext.Prototype.HasMethod(actionName))
return ProcessingResult.Continue;
Logger.Log(String.Format("{0} - [{1}] \"{2} {3}\"", httpContext.RemoteEndPoint.Address, DateTime.UtcNow, request.Method, request.Uri.AbsolutePath));
controller = null;
bool ret = false;
try {
lock (context)
controller = controllerContext.Pop();
controller.SetRequest(request, response, null, parameters, client);
// Get controller response
object result = controller.GetType().GetMethod(actionName).Invoke(controller, new object[0]);