QR Code的容错级别

QR Code容错级别有4种,可以让前端下拉列表选择H, L, M或Q

 

 

当传入服务端,处理QR Code时,Zxing模块接收的却不是字符串"H","L","M","Q"

所以,Insus.NET写一个静态扩展方法来处理这个参数:

 

 public static ErrorCorrectionLevel ToErrorCorrectionLevel(this string value)
        {
            var ecl = ErrorCorrectionLevel.H;
            switch (value)
            {
                case "H":
                    ecl = ErrorCorrectionLevel.H;
                    break;
                case "L":
                    ecl = ErrorCorrectionLevel.L;
                    break;
                case "M":
                    ecl = ErrorCorrectionLevel.M;
                    break;
                case "Q":
                    ecl = ErrorCorrectionLevel.Q;
                    break;
            }
            return ecl;
        }
Source Code

 

 

posted @ 2020-08-21 08:21  Insus.NET  阅读(838)  评论(0编辑  收藏  举报