private static MvcHtmlString InputHelper(HtmlHelper htmlHelper, InputType inputType, ModelMetadata metadata, string name, object value, bool useViewData, bool isChecked, bool setId, bool isExplicitValue, string format, IDictionary <string, object> htmlAttributes)
        {
            ModelState state;
            string     fullHtmlFieldName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);

            if (string.IsNullOrEmpty(fullHtmlFieldName))
            {
                throw new ArgumentException("", "name");
            }
            TagBuilder tagBuilder = new TagBuilder("input");

            tagBuilder.MergeAttributes <string, object>(htmlAttributes);
            tagBuilder.MergeAttribute("type", HtmlHelper.GetInputTypeString(inputType));
            if (inputType != InputType.CheckBox)
            {
                tagBuilder.MergeAttribute("name", fullHtmlFieldName, true);
            }
            else
            {
                tagBuilder.MergeAttribute("onchange", "oncheckboxchange(this);");
            }
            string           str2             = htmlHelper.FormatValue(value, format);
            bool             flag             = false;
            HtmlHelperCustom htmlHelperCustom = new HtmlHelperCustom(htmlHelper);

            switch (inputType)
            {
            case InputType.CheckBox:
            {
                bool?modelStateValue = htmlHelperCustom.GetModelStateValue(fullHtmlFieldName, typeof(bool)) as bool?;
                if (modelStateValue.HasValue)
                {
                    isChecked = modelStateValue.Value;
                    flag      = true;
                }
                break;
            }

            case InputType.Password:
                if (value != null)
                {
                    tagBuilder.MergeAttribute("value", str2, isExplicitValue);
                }
                goto Label_016A;

            case InputType.Radio:
                break;

            default:
            {
                string str3 = (string)htmlHelperCustom.GetModelStateValue(fullHtmlFieldName, typeof(string));
                tagBuilder.MergeAttribute("value", str3 ?? (useViewData ? htmlHelperCustom.EvalString(fullHtmlFieldName, format) : str2), isExplicitValue);
                goto Label_016A;
            }
            }
            if (!flag)
            {
                string a = htmlHelperCustom.GetModelStateValue(fullHtmlFieldName, typeof(string)) as string;
                if (a != null)
                {
                    isChecked = string.Equals(a, str2, StringComparison.Ordinal);
                    flag      = true;
                }
            }
            if (!flag & useViewData)
            {
                isChecked = htmlHelperCustom.EvalBoolean(fullHtmlFieldName);
            }
            if (isChecked)
            {
                tagBuilder.MergeAttribute("checked", "checked");
            }
            tagBuilder.MergeAttribute("value", str2, isExplicitValue);
Label_016A:
            if (setId)
            {
                tagBuilder.GenerateId(fullHtmlFieldName);
            }
            if (htmlHelper.ViewData.ModelState.TryGetValue(fullHtmlFieldName, out state) && (state.Errors.Count > 0))
            {
                tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);
            }
            tagBuilder.MergeAttributes <string, object>(htmlHelper.GetUnobtrusiveValidationAttributes(name, metadata));
            if (inputType == InputType.CheckBox)
            {
                StringBuilder builder1 = new StringBuilder();
                TagBuilder    builder2 = new TagBuilder("input");
                builder2.MergeAttribute("type", HtmlHelper.GetInputTypeString(InputType.Hidden));
                builder2.MergeAttribute("name", fullHtmlFieldName);
                builder2.MergeAttribute("value", isChecked ? "true" : "false");
                builder1.Append(builder2.ToString(TagRenderMode.SelfClosing));
                builder1.Append(tagBuilder.ToString(TagRenderMode.SelfClosing));
                //TagBuilder labelTag = new TagBuilder("label");
                //string forId = string.Format("ckb{0}", fullHtmlFieldName);
                //if (htmlAttributes.ContainsKey("id"))
                //{
                //    object _id = "";
                //    if (htmlAttributes.TryGetValue("id", out _id)){
                //        forId = _id.ToString();
                //    }
                //}
                //labelTag.MergeAttribute("for", forId);
                //labelTag.SetInnerText
                //builder1.Append(labelTag.ToString(TagRenderMode.Normal));
                return(MvcHtmlString.Create(builder1.ToString()));
            }
            return(tagBuilder.ToMvcHtmlString(TagRenderMode.SelfClosing));
        }