예제 #1
0
        private static object GenerateDropDownListSourceByConfiguration(DropdownPropertyDataSourceConfigurationElement config)
        {
            Type type = config.GetTypeInfo();

            MethodInfo mi = type.GetMethod(config.Method);

            (mi != null).FalseThrow("不能在类型{0}中找到方法{1}", type.FullName, config.Method);

            return(mi.Invoke(config.CreateInstance(), new object[] { }));
        }
예제 #2
0
        public object GetDataSource(string dataSourceID)
        {
            List <InlineDataSourceItem> result = new List <InlineDataSourceItem>();

            if (dataSourceID.IsNotEmpty())
            {
                DropdownPropertyDataSourceConfigurationElement configElement = DropdownPropertyDataSourceSettings.GetConfig().PropertySources[dataSourceID];

                if (configElement != null)
                {
                    foreach (InlineDropdownPropertyDataSourceItemConfigurationElement inlineItem in configElement.InlineItems)
                    {
                        InlineDataSourceItem item = new InlineDataSourceItem()
                        {
                            Key = inlineItem.Name, Name = inlineItem.Description
                        };

                        result.Add(item);
                    }
                }
            }

            return(result);
        }
예제 #3
0
        internal static EnumTypePropertyDescription GenerateEnumTypePropertyDescription(DropdownPropertyDataSourceConfigurationElement config)
        {
            EnumTypePropertyDescription result = new EnumTypePropertyDescription();

            result.EnumTypeName = config.Name;

            DropDownList dr = new DropDownList();

            dr.DataTextField  = config.BindingText;
            dr.DataValueField = config.BindingValue;
            dr.DataSource     = GenerateDropDownListSourceByConfiguration(config);
            dr.DataBind();

            foreach (ListItem item in dr.Items)
            {
                result.Items.Add(new EnumItemPropertyDescription(item));
            }

            return(result);
        }