本文整理汇总了C#中IRequest.GetParamStringOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# IRequest.GetParamStringOrEmpty方法的具体用法?C# IRequest.GetParamStringOrEmpty怎么用?C# IRequest.GetParamStringOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRequest
的用法示例。
在下文中一共展示了IRequest.GetParamStringOrEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseRequestURLForCommand
///// <summary>
///// Gets description of error
///// </summary>
///// <param name="error">ErrorCode</param>
///// <returns>Error description</returns>
//private string GetErrorDescription(ErrorCode error)
//{
// string errorDescription;
// switch (error)
// {
// case ErrorCode.ERRORCODE_UNSPECIFIED: errorDescription = "Unknown/Unspecified error"; break;
// case ErrorCode.ERRORCODE_UNKNOWNCMD: errorDescription ="Unknown cmd param"; break;
// case ErrorCode.ERRORCODE_BADPARAMS: errorDescription = "Invalid parameters (e.g. missing cmd/s_redirectto param)"; break;
// case ErrorCode.ERRORCODE_BADPOLLID: errorDescription = "Invalid poll id"; break;
// case ErrorCode.ERRORCODE_NEEDUSER: errorDescription = "User required for operation (User not logged in)"; break;
// case ErrorCode.ERRORCODE_ACCESSDENIED: errorDescription = "Access denied/operation not allowed"; break;
// case ErrorCode.ERRORCODE_AUTHORCANNOTVOTE: errorDescription = "Page author cannot vote"; break;
// default: errorDescription = "Unknown/Unspecified error"; break;
// }
// return errorDescription;
//}
/// <summary>
/// Tries to parse the request url to see what command has been sent through
/// </summary>
/// <param name="request">The request object</param>
/// <returns>True if command found, false if not OR something went wrong</returns>
public virtual bool ParseRequestURLForCommand(IRequest request)
{
// Get the command from the request
string command = request.GetParamStringOrEmpty("cmd", "Get the command for the poll");
if (command.Length > 0)
{
// See if we're adding a vote
if (command == "vote")
{
// Now get the response to the poll vote
int response = request.TryGetParamIntOrKnownValueOnError("response", ResponseMin - 1, "Try to get the response for the poll vote");
return Vote(response);
}
else if (command == "removevote")
{
// We're wanting to remove a vote
return RemoveVote();
}
else if (command == "config")
{
// Config command is meant to configure poll. For now
// we only have hide/unhide config feature. In the
// future we may have more. When this happens it would
// be wise to refactor code below making it more extendible.
// E.g, throw it in a virtual Config() function.
// See if we want to hide/unhide
if (request.DoesParamExist("hide", _docSPollHideParam))
{
// Now see if we're trying to hide or unhide
bool hide;
if (request.GetParamIntOrZero("hide", _docSPollHideParam) > 0)
{
hide = true;
}
else
{
hide = false;
}
// Return the result form the hide
return HidePoll(hide);
}
}
else if (command == "hidepoll")
{
// We're trying to hide a poll
return HidePoll(true);
}
else if (command == "unhidepoll")
{
// We're trying to unhide a poll
return HidePoll(false);
}
}
// Did not match the command given, or not given!
return UnhandledCommand(command);
}
示例2: ParseRequestURLForCommand
/// <summary>
/// Tries to parse the request url to see what command has been sent through
/// </summary>
/// <param name="request">The request object</param>
/// <returns>True if command found, false if not OR something went wrong</returns>
public override bool ParseRequestURLForCommand(IRequest request)
{
// Get the redirect from the url
_redirectURL = request.GetParamStringOrEmpty("s_redirectto", "Check the redirect for the poll exists");
if (RedirectURL.Length == 0)
{
// Add an error to the xml and logs
_appContext.Diagnostics.WriteWarningToLog("PollContentRating", "'s_redirectto' parameter not found!");
return AddErrorXml(ErrorCode.ERRORCODE_BADPARAMS.ToString(), "'s_redirectto' not set by skin", null);
}
// Now let the base class do it's stuff
return base.ParseRequestURLForCommand(request);
}