本文整理汇总了C#中System.Collections.IList.Where方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.IList.Where方法的具体用法?C# System.Collections.IList.Where怎么用?C# System.Collections.IList.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.IList
的用法示例。
在下文中一共展示了System.Collections.IList.Where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateElementEditors
protected void UpdateElementEditors(IList[] values)
{
PropertyInfo indexer = typeof(IList).GetProperty("Item");
IEnumerable<IList> valuesNotNull = values.Where(v => v != null);
int visibleElementCount = valuesNotNull.Min(o => (int)o.Count);
bool showOffset = false;
if (visibleElementCount > 10)
{
this.offset = Math.Min(this.offset, visibleElementCount - 10);
this.offsetEditor.Maximum = visibleElementCount - 10;
this.offsetEditor.ValueBarMaximum = this.offsetEditor.Maximum;
visibleElementCount = 10;
showOffset = true;
}
else
{
this.offset = 0;
}
if (this.sizeEditor.ParentEditor == null) this.AddPropertyEditor(this.sizeEditor, 0);
if (showOffset && this.offsetEditor.ParentEditor == null) this.AddPropertyEditor(this.offsetEditor, 1);
else if (!showOffset && this.offsetEditor.ParentEditor != null) this.RemovePropertyEditor(this.offsetEditor);
this.internalEditors = showOffset ? 2 : 1;
this.BeginUpdate();
// Add missing editors
Type elementType = GetIListElementType(this.EditedType);
Type reflectedArrayType = PropertyEditor.ReflectDynamicType(elementType, valuesNotNull.Select(a => GetIListElementType(a.GetType())));
for (int i = this.internalEditors; i < visibleElementCount + this.internalEditors; i++)
{
int elementIndex = i - this.internalEditors + this.offset;
Type reflectedElementType = PropertyEditor.ReflectDynamicType(
reflectedArrayType,
valuesNotNull.Select(v => indexer.GetValue(v, new object[] { elementIndex })));
PropertyEditor elementEditor;
// Retrieve and Update existing editor
if (i < this.ChildEditors.Count())
{
elementEditor = this.ChildEditors.ElementAt(i);
if (elementEditor.EditedType != reflectedElementType)
{
// If the editor has the wrong type, we'll need to create a new one
PropertyEditor oldEditor = elementEditor;
elementEditor = this.ParentGrid.CreateEditor(reflectedElementType, this);
this.AddPropertyEditor(elementEditor, oldEditor);
this.RemovePropertyEditor(oldEditor);
this.ParentGrid.ConfigureEditor(elementEditor);
}
}
// Create a new editor
else
{
elementEditor = this.ParentGrid.CreateEditor(reflectedElementType, this);
this.AddPropertyEditor(elementEditor);
this.ParentGrid.ConfigureEditor(elementEditor);
}
elementEditor.Getter = this.CreateElementValueGetter(indexer, elementIndex);
elementEditor.Setter = this.CreateElementValueSetter(indexer, elementIndex);
elementEditor.PropertyName = "[" + elementIndex + "]";
}
// Remove overflowing editors
for (int i = this.ChildEditors.Count() - (this.internalEditors + 1); i >= visibleElementCount; i--)
{
PropertyEditor child = this.ChildEditors.Last();
this.RemovePropertyEditor(child);
}
this.EndUpdate();
}
示例2: UpdateElementEditors
protected void UpdateElementEditors(IList[] values, Type elementType)
{
PropertyInfo indexer = typeof(IList).GetProperty("Item");
int visibleElementCount = values.Where(o => o != null).Min(o => (int)o.Count);
bool showOffset = false;
if (visibleElementCount > 10)
{
this.offset = Math.Min(this.offset, visibleElementCount - 10);
this.offsetEditor.Maximum = visibleElementCount - 10;
visibleElementCount = 10;
showOffset = true;
}
else
{
this.offset = 0;
}
if (this.sizeEditor.ParentEditor == null) this.AddPropertyEditor(this.sizeEditor, 0);
if (showOffset && this.offsetEditor.ParentEditor == null) this.AddPropertyEditor(this.offsetEditor, 1);
else if (!showOffset && this.offsetEditor.ParentEditor != null) this.RemovePropertyEditor(this.offsetEditor);
this.internalEditors = showOffset ? 2 : 1;
this.BeginUpdate();
// Add missing editors
for (int i = this.internalEditors; i < visibleElementCount + this.internalEditors; i++)
{
PropertyEditor elementEditor;
if (i < this.Children.Count())
{
elementEditor = this.Children.ElementAt(i);
}
else
{
elementEditor = this.ParentGrid.CreateEditor(elementType, this);
//elementEditor.ButtonPressed += elementEditor_ButtonPressed;
this.AddPropertyEditor(elementEditor);
this.ParentGrid.ConfigureEditor(elementEditor);
}
elementEditor.Getter = this.CreateElementValueGetter(indexer, i - this.internalEditors + this.offset);
elementEditor.Setter = this.CreateElementValueSetter(indexer, i - this.internalEditors + this.offset);
elementEditor.PropertyName = "[" + (i - this.internalEditors + this.offset) + "]";
//elementEditor.Hints |= HintFlags.HasButton | HintFlags.ButtonEnabled;
}
// Remove overflowing editors
for (int i = this.Children.Count() - (this.internalEditors + 1); i >= visibleElementCount; i--)
{
PropertyEditor child = this.Children.Last();
//child.ButtonPressed -= elementEditor_ButtonPressed;
this.RemovePropertyEditor(child);
}
this.EndUpdate();
}