当前位置: 首页>>代码示例>>C#>>正文


C# PropertyInfo.IsNonEmpty方法代码示例

本文整理汇总了C#中System.Reflection.PropertyInfo.IsNonEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.IsNonEmpty方法的具体用法?C# PropertyInfo.IsNonEmpty怎么用?C# PropertyInfo.IsNonEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.PropertyInfo的用法示例。


在下文中一共展示了PropertyInfo.IsNonEmpty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Bind

        /// <summary>
        /// Populates the specified <see cref="System.Web.UI.WebControls.DropDownList"/> with 
        /// the specified collection of values.
        /// </summary>
        /// <remarks>
        /// The supported types of items in the specified collection of values can be of type 
        /// Adf.Business.DomainObject, Adf.Core.Descriptor, System.Enum, SmartReference etc.
        /// </remarks>
        /// <param name="control">The <see cref="System.Web.UI.WebControls.DropDownList"/> 
        /// to bind to.</param>
        /// <param name="value">The collection of values to bind.</param>
        /// <param name="pi">The property used to check whether an empty item will be included in the 
        /// <see cref="System.Web.UI.WebControls.DropDownList"/>.</param>
        /// <param name="p">The parameters used for binding. Currently not being used.</param>
        public virtual void Bind(object control, object value, PropertyInfo pi, params object[] p)
        {
            if (value == null) return;

            var listBox = control as ListBox;
            if (listBox == null) return;

            listBox.Items.Clear();

            var includeEmpty = !pi.IsNonEmpty();

            foreach (var item in PropertyHelper.GetCollectionWithDefault(value, includeEmpty))
            {
                var listitem = new ListItem(item.Text, item.Value.ToString()) {Selected = item.Selected};

                listBox.Items.Add(listitem);
            }
        }
开发者ID:erwinbovendeur,项目名称:ADF,代码行数:32,代码来源:ListBoxBinder.cs

示例2: Bind

        /// <summary>
        /// Populates the specified <see cref="System.Web.UI.WebControls.RadioButtonList"/> with 
        /// the specified collection of values using the specified parameters.
        /// </summary>
        /// <remarks>
        /// The supported types of items in the specified collection of values can be of type 
        /// Adf.Business.DomainObject, Adf.Business.SmartReferences.SmartReference&lt;T&gt;, 
        /// Adf.Core.Descriptor, System.Enum etc.
        /// </remarks>
        /// <param name="control">The <see cref="System.Web.UI.WebControls.RadioButtonList"/> 
        /// to bind to.</param>
        /// <param name="value">The collection of values to bind.</param>
        /// <param name="pi">The property used to check whether an empty item will be included 
        /// in the <see cref="System.Web.UI.WebControls.RadioButtonList"/>. Currently not being 
        /// used.</param>
        /// <param name="p">The parameters used for binding. Currently not being used.</param>
        public virtual void Bind(object control, object value, PropertyInfo pi, params object[] p)
        {
            if (value == null) return;

            RadioButtonList rbl = control as RadioButtonList;

            if (rbl == null) return;

            rbl.Items.Clear();

            var includeEmpty = !pi.IsNonEmpty();

            IEnumerable<ValueItem> list = PropertyHelper.GetCollectionWithDefault(value, includeEmpty);

            foreach (ValueItem item in list)
            {
                ListItem listitem = new ListItem(item.Text, item.Value.ToString()) {Selected = item.Selected};

                rbl.Items.Add(listitem);
            }
        }
开发者ID:erwinbovendeur,项目名称:ADF,代码行数:37,代码来源:RadioButtonListBinder.cs

示例3: Bind

        /// <summary>
        /// Populates the specified <see cref="System.Web.UI.WebControls.DropDownList"/> with 
        /// the specified collection of values.
        /// </summary>
        /// <remarks>
        /// The supported types of items in the specified collection of values can be of type 
        /// Adf.Business.DomainObject, Adf.Core.Descriptor, System.Enum, SmartReference etc.
        /// </remarks>
        /// <param name="control">The <see cref="System.Web.UI.WebControls.DropDownList"/> 
        /// to bind to.</param>
        /// <param name="value">The collection of values to bind.</param>
        /// <param name="pi">The property used to check whether an empty item will be included in the 
        /// <see cref="System.Web.UI.WebControls.DropDownList"/>.</param>
        /// <param name="p">The parameters used for binding. Currently not being used.</param>
        public virtual void Bind(object control, object value, PropertyInfo pi, params object[] p)
        {
            if (value == null) return;

            var ddl = control as DropDownList;
            if (ddl == null) return;

            ddl.Items.Clear();

            var items = BindManager.GetListFor(pi);

            if (p != null && p.Length > 0)
            {
                var typeResolver = p[0] as ObjectResolver;

                if (typeResolver != null)
                {
                    Func<IEnumerable> func;
                    if (typeResolver.TryGetValue(ddl.ID, out func))
                    {
                        items = func.Invoke();
                    }
                    else if (typeResolver.TryGetValue(value.GetType(), out func))
                    {
                        items = func.Invoke();
                    }
                }
            }

            var includeEmpty = !pi.IsNonEmpty();

            foreach (var item in PropertyHelper.GetCollectionWithDefault(pi.PropertyType, value, includeEmpty, items))
            {
                ddl.Items.Add(new ListItem(item.Text, item.Value.ToString()) {Selected = item.Selected});
            }

            if (ddl.SelectedValue.IsNullOrEmpty() && !PropertyHelper.IsEmpty(value)) ddl.Items.Insert(0, new ListItem("<invalid value>") { Selected = true });
        }
开发者ID:NLADP,项目名称:ADF,代码行数:52,代码来源:DropDownListBinder.cs

示例4: Bind

        /// <summary>
        /// Populates the specified <see cref="System.Web.UI.WebControls.RadioButtonList"/> with 
        /// the specified collection of values using the specified parameters.
        /// </summary>
        /// <remarks>
        /// The supported types of items in the specified collection of values can be of type 
        /// Adf.Business.DomainObject, Adf.Business.SmartReferences.SmartReference&lt;T&gt;, 
        /// Adf.Core.Descriptor, System.Enum etc.
        /// </remarks>
        /// <param name="control">The <see cref="System.Web.UI.WebControls.RadioButtonList"/> 
        /// to bind to.</param>
        /// <param name="value">The collection of values to bind.</param>
        /// <param name="pi">The property used to check whether an empty item will be included 
        /// in the <see cref="System.Web.UI.WebControls.RadioButtonList"/>. Currently not being 
        /// used.</param>
        /// <param name="p">The parameters used for binding. Currently not being used.</param>
        public virtual void Bind(object control, object value, PropertyInfo pi, params object[] p)
        {
            if (value == null) return;

            var rbl = control as RadioButtonList;

            if (rbl == null) return;

            rbl.Items.Clear();

            var items = BindManager.GetListFor(pi);

            if (p != null && p.Length > 0)
            {
                var typeResolver = p[0] as ObjectResolver;

                if (typeResolver != null)
                {
                    Func<IEnumerable> func;
                    if (typeResolver.TryGetValue(rbl.ID, out func))
                    {
                        items = func.Invoke();
                    }
                    else if (typeResolver.TryGetValue(value.GetType(), out func))
                    {
                        items = func.Invoke();
                    }
                }
            }

            var includeEmpty = !pi.IsNonEmpty();

            var list = PropertyHelper.GetCollectionWithDefault(pi.PropertyType, value, includeEmpty);

            foreach (var item in list)
            {
                var listitem = new ListItem(item.Text, item.Value.ToString()) {Selected = item.Selected};

                rbl.Items.Add(listitem);
            }
        }
开发者ID:NLADP,项目名称:ADF,代码行数:57,代码来源:RadioButtonListBinder.cs


注:本文中的System.Reflection.PropertyInfo.IsNonEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。