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


C# System.Collections.IList.Select方法代码示例

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


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

示例1: UpdateElementEditors

        protected void UpdateElementEditors(IList[] values)
        {
            PropertyInfo indexer = typeof(IList).GetProperty("Item");
            int visibleElementCount = values.Where(o => o != null).Min(o => (int)o.Count);
            bool showOffset = false;
            if (visibleElementCount > VisibleElementCountBeforeOffsetRequired)
            {
                this.offset = Math.Min(this.offset, visibleElementCount - VisibleElementCountBeforeOffsetRequired);
                this.offsetEditor.Maximum = visibleElementCount - VisibleElementCountBeforeOffsetRequired;
                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, values.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,
                    values.Where(v => v != null).Select(v => indexer.GetValue(v, new object[] { elementIndex })));
                PropertyEditor elementEditor;

                // Retrieve and Update existing editor
                if (i < this.Children.Count())
                {
                    elementEditor = this.Children.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);
                        oldEditor.Dispose();

                        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.Children.Count() - (this.internalEditors + 1); i >= visibleElementCount; i--)
            {
                PropertyEditor child = this.Children.Last();
                this.RemovePropertyEditor(child);
            }
            this.EndUpdate();
        }
开发者ID:BraveSirAndrew,项目名称:winforms,代码行数:73,代码来源:IListPropertyEditor.cs


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