本文整理汇总了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);
}
}
示例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<T>,
/// 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);
}
}
示例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 });
}
示例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<T>,
/// 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);
}
}