public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition helpDefinition, string bindingSourceName)
        {
            BaseRuntimeTreeNode runtimeTreeNode;

            if (!parameters.TryGetParameterRuntimeTreeNode(Parameter_Options, out runtimeTreeNode))
            {
                throw new InvalidOperationException("Could not get BaseRuntimeTreeNode for parameter 'Options'.");
            }

            const string selectorName = "KeySelector";

            IEnumerable options           = runtimeTreeNode.GetValue <IEnumerable>();
            IDictionary dictionaryOptions = options as IDictionary;

            XElement treeNodeElement = runtimeTreeNode.Serialize().Elements().First();

            XElement functionMarkup = treeNodeElement;


            XElement selector = StandardWidgetFunctions.BuildBasicFormsMarkup(
                Namespaces.BindingFormsStdUiControls10,
                selectorName,
                "Selected",
                label,
                helpDefinition,
                bindingSourceName);

            if (dictionaryOptions != null)
            {
                selector.Add(new XAttribute("OptionsKeyField", "Key"));
                selector.Add(new XAttribute("OptionsLabelField", "Value"));
            }
            else
            {
                string keyFieldName = parameters.GetParameter <string>(Parameter_KeyFieldName);
                if (keyFieldName != null)
                {
                    selector.Add(new XAttribute("OptionsKeyField", keyFieldName));
                }

                string labelFieldName = parameters.GetParameter <string>(Parameter_LabelFieldName);
                if (labelFieldName != null)
                {
                    selector.Add(new XAttribute("OptionsLabelField", labelFieldName));
                }
            }

            bool required = parameters.GetParameter <bool>(Parameter_Required);

            selector.Add(new XAttribute("Required", required));

            selector.Add(new XElement(selector.Name.Namespace + (selectorName + ".Options"), functionMarkup));

            return(selector);
        }
示例#2
0
        private XElement BuildFormMarkUp(
            ParameterList parameters,
            string label,
            HelpDefinition helpDefinition,
            string bindingSourceName,
            Type optionsGeneratingStaticType,
            string optionsGeneratingStaticMethodName,
            object optionsGeneratingStaticMethodParameterValue,
            string optionsObjectKeyPropertyName,
            string optionsObjectLabelPropertyName,
            bool required)
        {
            if (!parameters.TryGetParameter(nameof(SitemapScope), out SitemapScope sitemapScope))
            {
                throw new ArgumentException(nameof(SitemapScope));
            }

            string
                keySelTag    = "KeySelector",
                statMethTag  = "StaticMethodCall",
                compFuncName = $"{Constants.SerializeFuncNamespace}.{Resources.default_text.SerializeMarkupParamsFuncName}";

            XNamespace
                uc = Namespaces.BindingFormsStdUiControls10,
                f  = Namespaces.BindingFormsStdFuncLib10,
                bf = Namespaces.BindingForms10,
                ft = Namespaces.Function10;

            XElement keySelector = StandardWidgetFunctions.BuildBasicFormsMarkup(uc, keySelTag, "Selected", label, helpDefinition, bindingSourceName);

            XElement keySelectorOptions = new XElement(uc + $"{keySelTag}.Options",
                                                       new XElement(f + statMethTag,
                                                                    new XAttribute("Type", TypeManager.SerializeType(optionsGeneratingStaticType)),
                                                                    new XAttribute("Method", optionsGeneratingStaticMethodName),
                                                                    new XElement(uc + $"{statMethTag}.Parameters",
                                                                                 new XElement(ft + "function",
                                                                                              new XAttribute("name", compFuncName),
                                                                                              new XElement(ft + "param",
                                                                                                           new XAttribute("name", Constants.TypeNameParamName),
                                                                                                           new XAttribute("value", optionsGeneratingStaticMethodParameterValue)),
                                                                                              new XElement(ft + "param", new XAttribute("name", Constants.PageIdParamName),
                                                                                                           new XElement(bf + "read", new XAttribute("source", "PageId"))),
                                                                                              new XElement(ft + "param",
                                                                                                           new XAttribute("name", Constants.SitemapScopeIdParamName),
                                                                                                           new XAttribute("value", (int)sitemapScope))))));

            keySelector.Add(
                new XAttribute("OptionsKeyField", optionsObjectKeyPropertyName),
                new XAttribute("OptionsLabelField", optionsObjectLabelPropertyName),
                new XAttribute("Required", required),
                keySelectorOptions);

            return(keySelector);
        }
        public override XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition helpDefinition, string bindingSourceName)
        {
            string tagName = "TypeSelector";

            XElement   selector = StandardWidgetFunctions.BuildBasicFormsMarkup(Namespaces.BindingFormsStdUiControls10, tagName, "SelectedType", label, helpDefinition, bindingSourceName);
            XNamespace f        = Namespaces.BindingFormsStdFuncLib10;

            selector.Add(
                new XElement(selector.Name.Namespace + (tagName + ".TypeOptions"),
                             new XElement(f + "StaticMethodCall",
                                          new XAttribute("Type", TypeManager.SerializeType(this.GetType())),
                                          new XAttribute("Method", "GetOptions"))));

            return(selector);
        }
 /// <exclude />
 protected XElement BuildBasicWidgetMarkup(string uiControlName, string bindingPropertyName, string label, HelpDefinition help, string bindingSourceName)
 {
     return(StandardWidgetFunctions.BuildBasicFormsMarkup(Namespaces.BindingFormsStdUiControls10, uiControlName, bindingPropertyName, label, help, bindingSourceName));
 }