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


C# IEnumerable.Cast方法代码示例

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


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

示例1: PropertyExpression

        protected PropertyExpression(object obj, IEnumerable<PropertyExpressionPart> parts)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");
            if (parts == null)
                throw new ArgumentNullException("parts");
            /*foreach (object item in parts)
            {
                if (item == null)
                {
                    throw new ArgumentException("An item inside the enumeration was null.", "parts");
                }
            }*/
            if (parts.Cast<object>().Any(item => item == null))
            {
                throw new ArgumentException(Resources.AnItemWasNull, "parts");
            }

            _parts = new List<PropertyExpressionPart>(parts);

            if (_parts.Count == 0)
                throw new ArgumentException(Resources.OnePartRequired, "parts");

            _finalPart = _parts.Last();
            //whenever the final part's value changes, that means the value of the expression as a whole has changed
            _finalPart.ValueChanged += delegate
                {
                    OnValueChanged();
                };

            //assign the initial object in the potential chain of objects resolved by the expression parts
            _parts[0].Object = obj;
        }
开发者ID:tfreitasleal,项目名称:MvvmFx,代码行数:33,代码来源:PropertyExpression.cs

示例2: CollectionView

        public CollectionView(IEnumerable collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            this.sourceCollection = collection;

            if (collection.Cast<object>().Any())
            {
                this.currentItem = collection.Cast<object>().First();
                this.currentPosition = 0;
            }
            else
            {
                this.currentPosition = -1;
                this.IsCurrentAfterLast = this.IsCurrentBeforeFirst = true;
            }
            
            INotifyCollectionChanged incc = collection as INotifyCollectionChanged;

            if (incc != null)
            {
                incc.CollectionChanged += this.OnCollectionChanged;
            }
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:27,代码来源:CollectionView.cs

示例3: Convert

        public IDbCommandResult Convert(IEnumerable values)
        {
            if (values.IsEmpty())
            {
                return new QueryResult();
            }
            var type = values.GetTypeOfValues();

            if (type.IsValueType || type == typeof(string))
            {
                return QueryResultOfValues(values, type);
            }
            if (type == typeof(DynamicRecord))
            {
                return QueryResultOfDynamicRecord(values.Cast<DynamicRecord>());
            }
            if (type == typeof(DynamicDataRow))
            {
                return QueryResultOfDynamicDataRow(values.Cast<DynamicDataRow>());
            }
            if (type.IsAssignableFrom(typeof(IDictionary)))
            {
                return QueryResultOfDictionary((IEnumerable<IDictionary>)values);
            }

            return QueryResultOfType(values, type);
        }
开发者ID:pedershk,项目名称:dotnetprograms,代码行数:27,代码来源:CollectionConverter.cs

示例4: SelectIndividualGlyphsOrPassBoxComposition

		private static IList SelectIndividualGlyphsOrPassBoxComposition(IEnumerable boxElements)
		{
			if (boxElements == null)
				return null;

			Contract.RequiresForAll(boxElements.Cast<object>(), element => element is IBoxElement);

			return boxElements.Cast<object>().VirtualSelectMany<object, BoxCompositionViewModel, GlyphRunViewModel, object>(bc => bc.ToSingleton(), glyphRun => glyphRun).ToList();
		}
开发者ID:JeroenBos,项目名称:ASDE,代码行数:9,代码来源:NotifyBoxElementsChangedEvent.cs

示例5: CreateColumn

 public static IColumn CreateColumn(Type dataType, IEnumerable<object> data)
 {
     if (new[]{typeof(Int64), typeof(Int32), typeof(Int16), typeof(UInt16), typeof(UInt32), typeof(UInt64), typeof(int)}.Contains(dataType))
         return new Column<Int64>( data.Cast<Int64>() );
     if (dataType == typeof (DateTime))
         return new Column<DateTime>(data.Cast<DateTime>());
     if (dataType == typeof (Double))
         return new Column<Double>(data.Cast<Double>());
     return new Column<String>(data.Cast<String>());
 }
开发者ID:VennoFang,项目名称:dblp2csv,代码行数:10,代码来源:TableFactory.cs

示例6: Perform

        public override IEnumerable<Item> Perform(IEnumerable<Item> items, IEnumerable<Item> modItems)
        {
            IEnumerable<Wnck.Window> windows = null;
            if (items.First () is IWindowItem)
                windows = items.Cast<IWindowItem> ().SelectMany (wi => wi.Windows);
            else if (items.First () is IApplicationItem)
                windows = items.Cast<IApplicationItem> ().SelectMany (a => WindowUtils.WindowListForCmd (a.Exec));

            if (windows != null)
                Action (windows);
            return null;
        }
开发者ID:jrudolph,项目名称:do-plugins,代码行数:12,代码来源:WindowActionAction.cs

示例7: AddIrtCalculatorDlg

        public AddIrtCalculatorDlg(IEnumerable<RCalcIrt> calculators)
        {
            InitializeComponent();

            comboLibrary.Items.AddRange(calculators.Cast<object>().ToArray());
            ComboHelper.AutoSizeDropDown(comboLibrary);
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:7,代码来源:AddIrtCalculatorDlg.cs

示例8: BulkDeleteOperationArgs

 // constructors
 public BulkDeleteOperationArgs(
     string collectionName,
     string databaseName,
     int maxBatchCount,
     int maxBatchLength,
     int maxDocumentSize,
     int maxWireDocumentSize,
     bool isOrdered,
     BsonBinaryReaderSettings readerSettings,
     IEnumerable<DeleteRequest> requests,
     WriteConcern writeConcern,
     BsonBinaryWriterSettings writerSettings)
     : base(
         collectionName,
         databaseName,
         maxBatchCount,
         maxBatchLength,
         maxDocumentSize,
         maxWireDocumentSize,
         isOrdered,
         readerSettings,
         requests.Cast<WriteRequest>(),
         writeConcern,
         writerSettings)
 {
 }
开发者ID:ExM,项目名称:mongo-csharp-driver,代码行数:27,代码来源:BulkDeleteOperationArgs.cs

示例9: Perform

        public override IEnumerable<Item> Perform(IEnumerable<Item> items, IEnumerable<Item> modifierItems)
        {
            string search_text;

            search_text = (items.First () as ITextItem).Text;
            return GCal.SearchEvents (modifierItems.Cast<GCalendarItem> (), search_text).Cast<Item> ();
        }
开发者ID:jrudolph,项目名称:do-plugins,代码行数:7,代码来源:GCalendarSearchEvents.cs

示例10: HasSameItemsRegardlessOfSortOrder

        public static bool HasSameItemsRegardlessOfSortOrder(this IEnumerable left, IEnumerable right)
        {
            var leftCollection = left.Cast<object>().ToList();
            var rightCollection = right.Cast<object>().ToList();

            return leftCollection.Except(rightCollection).Count() == 0;
        }
开发者ID:p69,项目名称:magellan-framework,代码行数:7,代码来源:EnumerableExtensions.cs

示例11: Shuffle

 public List<int> Shuffle(IEnumerable<int> cards)
 {
     int[] castedArray = cards.Cast<int>().ToArray();
     int[] arr = ShuffleMethod(castedArray);
     var list = new List<int>(arr);
     return (list);
 }
开发者ID:kellyelton,项目名称:ShuffleValidator,代码行数:7,代码来源:SoulShuffle.cs

示例12: CreateMultiResolutionImage

		public override object CreateMultiResolutionImage (IEnumerable<object> images)
		{
			var refImg = (GtkImage) images.First ();
			var f = refImg.Frames [0];
			var frames = images.Cast<GtkImage> ().Select (img => new GtkImage.ImageFrame (img.Frames[0].Pixbuf, f.Width, f.Height, true));
			return new GtkImage (frames);
		}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:7,代码来源:ImageHandler.cs

示例13: Assembly

 public Assembly(string name, IEnumerable<Concern> concerns) : base(concerns.Cast<SpecificationContainer>())
 {
   _name = name;
   _concerns = concerns.OrderBy(x => x.Name).ToList();
   _totalConerns = concerns.Count();
   _totalContexts = concerns.Sum(x => x.TotalContexts);
 }
开发者ID:benlovell,项目名称:machine.specifications,代码行数:7,代码来源:Assembly.cs

示例14: BulkInsertOperationArgs

 // constructors
 public BulkInsertOperationArgs(
     Action<InsertRequest> assignId,
     bool checkElementNames,
     string collectionName,
     string databaseName,
     int maxBatchCount,
     int maxBatchLength,
     int maxDocumentSize,
     int maxWireDocumentSize,
     bool isOrdered,
     BsonBinaryReaderSettings readerSettings,
     IEnumerable<InsertRequest> requests,
     WriteConcern writeConcern,
     BsonBinaryWriterSettings writerSettings)
     : base(
         collectionName,
         databaseName,
         maxBatchCount,
         maxBatchLength,
         maxDocumentSize,
         maxWireDocumentSize,
         isOrdered,
         readerSettings,
         requests.Cast<WriteRequest>(),
         writeConcern,
         writerSettings)
 {
     _assignId = assignId;
     _checkElementNames = checkElementNames;
 }
开发者ID:nsavga,项目名称:mongo-csharp-driver,代码行数:31,代码来源:BulkInsertOperationArgs.cs

示例15: createReferenceMembers

 void createReferenceMembers(IEnumerable<IExtendedMemberInfo> xpCollection){
     XPDictionary xpDictionary = XafTypesInfo.XpoTypeInfoSource.XPDictionary;
     foreach (var info in xpCollection.Cast<IExtendedReferenceMemberInfo>()){
         XPCustomMemberInfo member = xpDictionary.GetClassInfo(info.Owner).CreateMember(info.Name, info.ReferenceType);
         createAttributes(info, member);
     }
 }
开发者ID:corzar,项目名称:eXpand,代码行数:7,代码来源:ExistentTypesMemberCreator.cs


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