示例#1
0
        public static IHtmlString ReCaptchaScript(this HtmlHelper _helpers, Render render = Render.Onload, ReCaptchaLanguage language = ReCaptchaLanguage.Default, string onLoadCallBack = null)
        {
            TagBuilder tagDiv = new TagBuilder("script");

            string url = ReConfigurationCaptcha.GetCaptchaApiUrl();

            url = url + "?render=" + render.GetValueLower();

            if (!string.IsNullOrEmpty(onLoadCallBack))
            {
                url = url + "&onload=" + onLoadCallBack;
            }

            if (language != ReCaptchaLanguage.Default)
            {
                string valueHl = null;
                if (_find.TryGetValue(language.ToString(), out valueHl))
                {
                    url = url + "&hl=" + valueHl;
                }
            }

            tagDiv.Attributes.Add("src", url);

            return(new HtmlString(tagDiv.ToString().Replace("></", " async defer></")));
        }
        public static string GetLanguage(this ReCaptchaLanguage language)
        {
            if (language == ReCaptchaLanguage.Auto)
            {
                var newLanguage = GetLanguageByCulture(CultureInfo.CurrentUICulture);
                return(GetLanguage(newLanguage.GetValueOrDefault()));
            }
            var attribute = language.GetType().GetMember(language.ToString()).Select(m => m.GetCustomAttribute <LanguageAttribute>()).FirstOrDefault() ?? new LanguageAttribute(string.Empty);

            return(attribute.Value);
        }
        public static string GetLanguage(this ReCaptchaLanguage language)
        {
            var attribute = language.GetType().GetMember(language.ToString()).Select(m => m.GetCustomAttribute <LanguageAttribute>()).FirstOrDefault() ?? new LanguageAttribute(string.Empty);

            return(attribute.Value);
        }