本文整理汇总了C#中System.Collections.IDictionary.Select方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.IDictionary.Select方法的具体用法?C# System.Collections.IDictionary.Select怎么用?C# System.Collections.IDictionary.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.IDictionary
的用法示例。
在下文中一共展示了System.Collections.IDictionary.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateElementEditors
protected void UpdateElementEditors(IDictionary[] values)
{
PropertyInfo indexer = typeof(IDictionary).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.addKeyEditor.ParentEditor == null) this.AddPropertyEditor(this.addKeyEditor, 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;
// Determine which keys are currently displayed
int elemIndex = 0;
this.displayedKeys = new object[visibleElementCount];
foreach (object key in values.Where(o => o != null).First().Keys)
{
if (elemIndex >= this.offset + visibleElementCount) break;
if (elemIndex >= this.offset)
{
this.displayedKeys[elemIndex - this.offset] = key;
}
elemIndex++;
}
this.BeginUpdate();
// Add missing editors
Type dictValueType = GetIDictionaryValueType(this.EditedType);
Type reflectedDictValueType = PropertyEditor.ReflectDynamicType(dictValueType, values.Select(a => GetIDictionaryValueType(a.GetType())));
for (int i = this.internalEditors; i < visibleElementCount + this.internalEditors; i++)
{
object elementKey = this.displayedKeys[i - this.internalEditors];
Type reflectedElementValueType = PropertyEditor.ReflectDynamicType(
reflectedDictValueType,
values.Where(v => v != null).Select(v => indexer.GetValue(v, new object[] { elementKey })));
PropertyEditor elementEditor;
// Retrieve and Update existing editor
if (i < this.Children.Count())
{
elementEditor = this.Children.ElementAt(i);
if (elementEditor.EditedType != reflectedElementValueType)
{
// If the editor has the wrong type, we'll need to create a new one
PropertyEditor oldEditor = elementEditor;
elementEditor = this.ParentGrid.CreateEditor(reflectedElementValueType, this);
this.AddPropertyEditor(elementEditor, oldEditor);
this.RemovePropertyEditor(oldEditor);
oldEditor.Dispose();
this.ParentGrid.ConfigureEditor(elementEditor);
}
}
// Create a new editor
else
{
elementEditor = this.ParentGrid.CreateEditor(reflectedElementValueType, this);
this.AddPropertyEditor(elementEditor);
this.ParentGrid.ConfigureEditor(elementEditor);
if (!elementEditor.Hints.HasFlag(HintFlags.HasButton))
{
elementEditor.Hints |= HintFlags.HasButton | HintFlags.ButtonEnabled;
elementEditor.ButtonPressed += this.elementEditor_ButtonPressed;
}
}
elementEditor.Getter = this.CreateElementValueGetter(indexer, elementKey);
elementEditor.Setter = this.CreateElementValueSetter(indexer, elementKey);
elementEditor.PropertyName = "[" + elementKey.ToString() + "]";
}
// Remove overflowing editors
for (int i = this.Children.Count() - (this.internalEditors + 1); i >= visibleElementCount; i--)
{
PropertyEditor child = this.Children.Last();
this.RemovePropertyEditor(child);
child.ButtonPressed -= this.elementEditor_ButtonPressed;
}
this.EndUpdate();
}