示例#1
0
文件: YZRequest.cs 项目: radtek/EMIP
    public Version GetVersion(string param, bool allowNull, Version defaultValue)
    {
        string value = this.Context.Request.Params[param];

        if (allowNull && String.IsNullOrEmpty(value))
        {
            return(defaultValue);
        }

        Version rv;

        if (!Version.TryParse(value, out rv))
        {
            throw new Exception(String.Format(YZStringHelper.ServerSideResourceStringProcess(Resources.YZStrings.Aspx_Request_Params_Invalid_Version), param, value));
        }

        return(rv);
    }
示例#2
0
文件: YZRequest.cs 项目: radtek/EMIP
    public Guid GetGuid(string param, bool allowNull)
    {
        string value = this.Context.Request.Params[param];

        if (allowNull && String.IsNullOrEmpty(value))
        {
            return(Guid.Empty);
        }

        Guid rv;

        if (!Guid.TryParse(value, out rv))
        {
            throw new Exception(String.Format(YZStringHelper.ServerSideResourceStringProcess(Resources.YZStrings.Aspx_Request_Params_Invalid_Guid), param, value));
        }

        return(rv);
    }
示例#3
0
文件: YZRequest.cs 项目: radtek/EMIP
    public T GetEnum <T>(string param, bool allowNull, T defaultValue) where T : struct
    {
        string value = this.Context.Request.Params[param];
        T      rv;

        if (!Enum.TryParse <T>(value, true, out rv))
        {
            if (allowNull)
            {
                return(defaultValue);
            }

            throw new Exception(String.Format(YZStringHelper.ServerSideResourceStringProcess(Resources.YZStrings.Aspx_Request_Params_Invalid_Type), param, value, typeof(T).Name));
        }
        else
        {
            return(rv);
        }
    }