private string GetFullTemplateName(string templateName)
        {
            List <string> list = new List <string>
            {
                templateName
            };
            OptionsOwnerBuilder optionsOwnerBuilder = this;

            while (optionsOwnerBuilder.Owner != null)
            {
                string          text           = optionsOwnerBuilder.JsName;
                ICollectionItem collectionItem = optionsOwnerBuilder as ICollectionItem;
                if (collectionItem != null)
                {
                    int num = collectionItem.Index;
                    IDictionary <string, object> options = optionsOwnerBuilder.Owner.Options;
                    if (options.ContainsKey(text))
                    {
                        num += (options[text] as ICollection).Count;
                    }
                    text += num.ToString();
                }
                list.Insert(0, text);
                optionsOwnerBuilder = optionsOwnerBuilder.Owner;
            }
            WidgetBuilder widgetBuilder = (WidgetBuilder)optionsOwnerBuilder;

            list.Insert(0, widgetBuilder.InternalID.GetStatic());
            return(string.Join("-", list));
        }
 private bool HasParentOwner(OptionsOwnerBuilder owner, string[] names)
 {
     if (owner == null)
     {
         return(false);
     }
     if (names.Contains(owner.JsName))
     {
         return(true);
     }
     return(HasParentOwner(owner.Owner, names));
 }
Beispiel #3
0
        private void PrepareEditorOptionsForModelErrors(ViewContext viewContext, IEnumerable <IDictionary <string, object> > simpleItems)
        {
            ModelStateDictionary modelState = viewContext.ViewData.ModelState;

            foreach (IDictionary <string, object> simpleItem in simpleItems)
            {
                if (simpleItem.TryGetValue("dataField", out object value) && modelState.TryGetValue(value as string, out ModelStateEntry value2) && value2.Errors.Count > 0)
                {
                    IDictionary <string, object> nestedOptions = OptionsOwnerBuilder.GetNestedOptions(simpleItem, "editorOptions");
                    nestedOptions["isValid"]         = false;
                    nestedOptions["validationError"] = new
                    {
                        message = value2.Errors.First().ErrorMessage
                    };
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="jsName">对应的Js控件名称</param>
 /// <param name="owner">拥有者,谁拥有控件。保留未用。</param>
 /// <param name="html">Html适配器,控件在哪个页面创建。</param>
 public OptionsOwnerContext(string jsName, OptionsOwnerBuilder owner, IHtmlHelperAdapter html)
 {
     JsName = jsName;
     Owner  = owner;
     Html   = html;
 }