Ejemplo n.º 1
0
        /// <exclude />
        public static XElement BuildStaticCallPopulatedSelectorFormsMarkup(ParameterList parameters, string label, HelpDefinition helpDefinition, string bindingSourceName, Type optionsGeneratingStaticType, string optionsGeneratingStaticMethodName, object optionsGeneratingStaticMethodParameterValue, string optionsObjectKeyPropertyName, string optionsObjectLabelPropertyName, bool multiSelect, bool compactMode, bool required, bool bindToString)
        {
            string tagName             = (multiSelect == true? "MultiKeySelector": "KeySelector");
            string bindingPropertyName = (multiSelect && bindToString ? "SelectedAsString" : "Selected");

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

            selector.Add(
                new XAttribute("OptionsKeyField", optionsObjectKeyPropertyName),
                new XAttribute("OptionsLabelField", optionsObjectLabelPropertyName),
                new XAttribute("Required", required),
                (multiSelect ? new XAttribute("CompactMode", compactMode) : null),
                new XElement(selector.Name.Namespace + (tagName + ".Options"),
                             new XElement(f + "StaticMethodCall",
                                          new XAttribute("Type", TypeManager.SerializeType(optionsGeneratingStaticType)),
                                          new XAttribute("Method", optionsGeneratingStaticMethodName))));

            if (optionsGeneratingStaticMethodParameterValue != null)
            {
                selector.Descendants(f + "StaticMethodCall").First().Add(
                    new XAttribute("Parameters", optionsGeneratingStaticMethodParameterValue));
            }

            return(selector);
        }
Ejemplo n.º 2
0
 public XElement GetWidgetMarkup(ParameterList parameters, string label, HelpDefinition helpDefinition, string bindingSourceName)
 {
     return(StandardWidgetFunctions.BuildStaticCallPopulatedSelectorFormsMarkup(
                parameters,
                label,
                helpDefinition,
                bindingSourceName,
                _type,
                _methodName,
                _parameterValue,
                _keyPropertyName,
                _labelPropertyName,
                _multiSelector,
                _compact,
                _required,
                false));
 }
Ejemplo n.º 3
0
        /// <exclude />
        public static WidgetFunctionProvider GetDefaultWidgetFunctionProviderByType(Type type, bool required)
        {
            if (type == typeof(string))
            {
                return(StandardWidgetFunctions.TextBoxWidget);
            }
            if (type == typeof(int) || type == typeof(int?))
            {
                return(StandardWidgetFunctions.IntegerTextBoxWidget);
            }
            if (type == typeof(Decimal) || type == typeof(Decimal?))
            {
                return(StandardWidgetFunctions.DecimalTextBoxWidget);
            }
            if (type == typeof(DateTime) || type == typeof(DateTime?))
            {
                return(StandardWidgetFunctions.DateSelectorWidget);
            }
            if (type == typeof(Guid) || type == typeof(Guid?))
            {
                return(StandardWidgetFunctions.GuidTextBoxWidget);
            }
            if (type == typeof(bool) || type == typeof(bool?))
            {
                return(StandardWidgetFunctions.CheckBoxWidget);
            }

            if (type == typeof(DataReference <IImageFile>))
            {
                return(StandardWidgetFunctions.GetImageSelectorWidget(required));
            }
            if (type == typeof(NullableDataReference <IImageFile>))
            {
                return(StandardWidgetFunctions.GetImageSelectorWidget(false));
            }
            if (type == typeof(DataReference <IMediaFile>))
            {
                return(StandardWidgetFunctions.GetMediaFileSelectorWidget(required));
            }
            if (type == typeof(NullableDataReference <IMediaFile>))
            {
                return(StandardWidgetFunctions.GetMediaFileSelectorWidget(false));
            }

            if (type == typeof(XhtmlDocument))
            {
                return(StandardWidgetFunctions.VisualXhtmlDocumentEditorWidget);
            }

            IEnumerable <string> functionNames = FunctionFacade.GetWidgetFunctionNamesByType(type);

            foreach (string functionName in functionNames)
            {
                IWidgetFunction widgetFunction = FunctionFacade.GetWidgetFunction(functionName);
                bool            sameType       = widgetFunction.ReturnType == type;

                if (!sameType &&
                    !required &&
                    type.IsGenericType && type.GetGenericTypeDefinition() == typeof(DataReference <>) &&
                    type.IsAssignableFrom(widgetFunction.ReturnType) &&
                    widgetFunction.ReturnType == typeof(NullableDataReference <>).MakeGenericType(type.GetGenericArguments()))
                {
                    sameType = true;
                }

                if (sameType && !widgetFunction.ParameterProfiles.Any(p => p.IsRequired))
                {
                    return(new WidgetFunctionProvider(widgetFunction));
                }
            }

            if (type.IsLazyGenericType())
            {
                var lazyType = type.GetGenericArguments().First();

                var provider = GetDefaultWidgetFunctionProviderByType(lazyType, required);

                if (provider != null)
                {
                    return(provider);
                }
            }


            return(null);
        }