当前位置: 首页>>代码示例>>C#>>正文


C# IRequest.TryGetParamIntOrKnownValueOnError方法代码示例

本文整理汇总了C#中IRequest.TryGetParamIntOrKnownValueOnError方法的典型用法代码示例。如果您正苦于以下问题:C# IRequest.TryGetParamIntOrKnownValueOnError方法的具体用法?C# IRequest.TryGetParamIntOrKnownValueOnError怎么用?C# IRequest.TryGetParamIntOrKnownValueOnError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRequest的用法示例。


在下文中一共展示了IRequest.TryGetParamIntOrKnownValueOnError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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); 
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:87,代码来源:Poll.cs


注:本文中的IRequest.TryGetParamIntOrKnownValueOnError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。