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


C# IEnumerable.Except方法代码示例

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


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

示例1: Int

 public void Int(IEnumerable<int> first, IEnumerable<int> second, IEqualityComparer<int> comparer, IEnumerable<int> expected)
 {
     if (comparer == null)
     {
         Assert.Equal(expected, first.Except(second));
     }
     Assert.Equal(expected, first.Except(second, comparer));
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:8,代码来源:ExceptTests.cs

示例2: String

 public void String(IEnumerable<string> first, IEnumerable<string> second, IEqualityComparer<string> comparer, IEnumerable<string> expected)
 {
     if (comparer == null)
     {
         Assert.Equal(expected, first.Except(second));
     }
     Assert.Equal(expected, first.Except(second, comparer));
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:8,代码来源:ExceptTests.cs

示例3: FolderContainsExclusive

            /// <summary>
            /// Determines whether the given folder contains only the given files, and no others
            /// </summary>
            /// <returns></returns>
            protected bool FolderContainsExclusive(string relFolderPath, IEnumerable<string> filenames, Anomalies anomalies = null)
            {
                var dirPath = Path.Combine(this.TargetDir, relFolderPath);
                var exists = Directory.Exists(dirPath);
                if (!exists)
                {
                    return false;
                }
                else
                {
                    var folderFiles = new DirectoryInfo(dirPath).GetFiles();

                    var filesInFolder = folderFiles.Select(f => f.Name).Except(filenames).ToList();
                    var expectedFiles = filenames.Except(folderFiles.Select(f => f.Name)).ToList();

                    if (anomalies != null)
                    {
                        anomalies.ExpectedFiles.AddRange(expectedFiles);
                        anomalies.UnexpectedFiles.AddRange(filesInFolder);
                    }

                    return !(filesInFolder.Any())
                        && !(expectedFiles.Any());
                }
            }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:29,代码来源:VsixPackagingSpec.cs

示例4: Types

        static Types()
        {
            BuiltIn = new[]
                          {
                              typeof (Boolean),
                              typeof (Byte),
                              typeof (SByte),
                              typeof (Char),
                              typeof (Single),
                              typeof (Double),
                              typeof (Decimal),
                              typeof (Int16),
                              typeof (Int32),
                              typeof (Int64),
                              typeof (UInt16),
                              typeof (UInt32),
                              typeof (UInt64),
                              typeof (String),
                              typeof (Object)
                          };

            Simple = BuiltIn.Except(new[] { typeof(String), typeof(Object) }).ToArray();
            Comparable = Simple.Except(new[] { typeof(Boolean) }).ToArray();
            Empty = Enumerable.Empty<Type>();
        }
开发者ID:khalidabuhakmeh,项目名称:Harvester,代码行数:25,代码来源:Types.cs

示例5: GetDetailedItems

        public IEnumerable<PositionResultsViewModel> GetDetailedItems(long portfolioID, IEnumerable<StockDataItem> items)
        {
            try
            {
                var results = new List<PositionResultsViewModel>();

                var positions = _portRepo.GetAllPositions(portfolioID);
                if (!positions.Any()) return new List<PositionResultsViewModel>();

                var tickers = positions.Select(p => p.Ticker).Distinct();
                var stockData = _stockRepo.GetStockQuotes(tickers);

                foreach (var position in positions)
                {
                    var ticker = position.Ticker;
                    var tickerStockData = stockData.Single(stock => stock.Ticker == ticker);
                    var stockItems = GetStockItems(items, tickerStockData);
                    var remainingItemsToGet = items.Except(stockItems.Keys);
                    stockItems.AddRange(CalculateItems(remainingItemsToGet, position, tickerStockData));

                    var positionResults = new PositionResultsViewModel(position.ID ?? -1);
                    positionResults.Items = stockItems;

                    results.Add(positionResults);
                }
                return results;
            }
            catch (Exception ex)
            {
                Log.Error("GetDetailedItems", ex.ToString());
                throw;
            }
        }
开发者ID:mgroves,项目名称:MonodroidStockPortfolio,代码行数:33,代码来源:PortfolioService.cs

示例6: UpdateEndpointSubscriptions

        public async Task UpdateEndpointSubscriptions(string endpoint, IEnumerable<Subscription> subscriptions)
        {
            // lazy initialization, ensures only one thread runs the initialize function
            await this.initializationTask.Value;

            var storedSubscriptions = await this.store.GetByEndpoint(endpoint);

            var subscriptionsToAdd = subscriptions.Except(storedSubscriptions);
            var subscriptionsToRemove = storedSubscriptions.Except(subscriptions);

            var tasks = new List<Task>();

            foreach (var subscription in subscriptionsToAdd)
            {
                tasks.Add(this.AddSubscription(subscription));
            }

            foreach (var subscription in subscriptionsToRemove)
            {
                tasks.Add(this.RemoveSubscription(subscription));
            }

            if (tasks.Count > 0)
            {
                await Task.WhenAll(tasks.ToArray());
            }
        }
开发者ID:jamesholcomb,项目名称:NDomain,代码行数:27,代码来源:SubscriptionManager.cs

示例7: Match

        public IEnumerable<Card> Match(IEnumerable<Card> cardsToMatch)
        {
            var nofAKind = new NofAKind();
            var threeOfAKind = nofAKind.Find(cardsToMatch, 3);

            if (threeOfAKind != null)
            {
                var restOfTheCards = cardsToMatch.Except(threeOfAKind);

                IEnumerable<Card> currentPair, highestPair = null;

                while ((currentPair = nofAKind.Find(restOfTheCards, 2)) != null)
                {
                    if (highestPair == null
                        || currentPair.First().Rank > highestPair.First().Rank)
                    {
                        highestPair = currentPair;
                        restOfTheCards = restOfTheCards.Except(currentPair);
                    }
                }

                return highestPair != null ? threeOfAKind.Union(highestPair) : null;
            }

            return null;
        }
开发者ID:dansweeting,项目名称:Pokr,代码行数:26,代码来源:FullHouse.cs

示例8: GetNextSteps

        private void GetNextSteps(Stack<Node> currentChain, IEnumerable<Node> greyList, Node currentNode)
        {
            currentChain.Push(currentNode);

            var newGreyList =
                greyList
                    .Except(currentNode.Antecedents())
                    .Except(currentNode.Descendents())
                    .Distinct();

            if (newGreyList.Count() == 0)
            {
                ConcurrencyChains.Add(currentChain.ToList());

                MaxConcurrency = Math.Max(MaxConcurrency, (int) currentChain.Count);
            }

            foreach (var newPossible in newGreyList)
            {
                if (_previouslySeenRoots.Contains(newPossible)) continue;

                GetNextSteps(currentChain, newGreyList, newPossible);
            }

            currentChain.Pop();
        }
开发者ID:timbarrass,项目名称:Alembic.Tools,代码行数:26,代码来源:GraphConcurrencyCharacterisation.cs

示例9: MergeWritingSystemDlg

		public MergeWritingSystemDlg(FdoCache cache, IWritingSystem ws, IEnumerable<IWritingSystem> wss, IHelpTopicProvider helpTopicProvider)
		{
			m_cache = cache;
			m_ws = ws;

			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			Icon infoIcon = SystemIcons.Information;
			m_infoPictureBox.Image = infoIcon.ToBitmap();
			m_infoPictureBox.Size = infoIcon.Size;

			foreach (IWritingSystem curWs in wss.Except(new[] { ws }))
				m_wsListBox.Items.Add(curWs);
			m_wsListBox.SelectedIndex = 0;

			m_helpTopicProvider = helpTopicProvider;

			if (m_helpTopicProvider != null) // m_helpTopicProvider could be null for testing
			{
				m_helpProvider = new HelpProvider();
				m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
				m_helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(HelpTopic));
				m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:28,代码来源:MergeWritingSystemDlg.cs

示例10: AutoMap

		public void AutoMap(IEnumerable<string> csvColumns)
		{
			this.CsvColumns = csvColumns.ToArray();

			foreach (var propertyMap in this.PropertyMaps)
			{
				var entityColumnName = propertyMap.EntityColumnName;
				var betterMatchCsvColumn = csvColumns.Select(x => new { csvColumn = x, distance = x.ComputeLevenshteinDistance(entityColumnName) })
													 .Where(x => x.distance < 2)
													 .OrderBy(x => x.distance)
													 .Select(x => x.csvColumn)
													 .FirstOrDefault();
				if (betterMatchCsvColumn != null)
				{
					propertyMap.CsvColumnName = betterMatchCsvColumn;
					propertyMap.CustomValue = null;
				}
				else
				{
					propertyMap.CsvColumnName = null;
				}

			}
			//All not mapped properties may be a product property
			this.PropertyCsvColumns = csvColumns.Except(this.PropertyMaps.Where(x => x.CsvColumnName != null).Select(x => x.CsvColumnName)).ToArray();
			//Generate ETag for identifying csv format
			this.ETag = string.Join(";", this.CsvColumns).GetMD5Hash();
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:28,代码来源:CsvProductMappingConfiguration.cs

示例11: ClassTypeTree

        /// <summary>
        /// Initializes a new instance of the <see cref="ClassTypeTree"/> class.
        /// </summary>
        /// <param name="types">The types to build the tree out of.</param>
        public ClassTypeTree(IEnumerable<Type> types)
        {
            // ReSharper disable DoNotCallOverridableMethodsInConstructor

            var childList = new List<ClassTypeTree>();

            // Remove duplicates
            types = types.Where(x => x.IsClass).Distinct();

            // Grab the lowest-level types
            var baseTypes = types.Where(x => !types.Any(y => x != y && y.IsAssignableFrom(x)));

            // Grab the possible child types
            var remainingTypes = types.Except(baseTypes);
            foreach (var bt in baseTypes)
            {
                // Recursively build the tree
                childList.Add(CreateNode(this, bt, remainingTypes));
            }

            // Add the wildcard for the base level
            childList.Add(CreateNode(this, null, null));

            // Store the children
            _children = FinalizeChildren(childList);

            // ReSharper restore DoNotCallOverridableMethodsInConstructor
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:32,代码来源:ClassTypeTree.cs

示例12: GetAppsToDelete

        /// <summary>
        /// Obtain the set between two lists
        /// </summary>
        /// <param name="before"></param>
        /// <param name="after"></param>
        /// <returns>List of Unique Application Names</returns>
        public static List<string> GetAppsToDelete(IEnumerable<string> before, IEnumerable<string> after)
        {
            var applicationNames = before.Except(after);

            var enumerable = applicationNames as IList<string> ?? applicationNames.ToList();
            return enumerable.Any() ? enumerable.ToList() : null;
        }
开发者ID:cengonurozkan,项目名称:vFenseAgent-win,代码行数:13,代码来源:RegistryReader.cs

示例13: UpdateSession

        public void UpdateSession(IEnumerable<EventSourceSettings> updatedEventSources)
        {
            Guard.ArgumentNotNull(updatedEventSources, "updatedEventSources");

            var eventSourceComparer = new EventSourceSettingsEqualityComparer(nameOnly: true);

            // updated sources
            foreach (var currentSource in this.eventSources.Intersect(updatedEventSources, eventSourceComparer).ToArray())
            {
                var updatedSource = updatedEventSources.Single(s => s.Name == currentSource.Name);
                if (updatedSource.Level != currentSource.Level ||
                    updatedSource.MatchAnyKeyword != currentSource.MatchAnyKeyword)
                {
                    TraceEventUtil.EnableProvider(this.session, updatedSource.EventSourceId, updatedSource.Level, updatedSource.MatchAnyKeyword, sendManifest: false);
                    currentSource.Level = updatedSource.Level;
                    currentSource.MatchAnyKeyword = updatedSource.MatchAnyKeyword;
                }
            }

            // new sources
            foreach (var newSource in updatedEventSources.Except(this.eventSources, eventSourceComparer).ToArray())
            {
                TraceEventUtil.EnableProvider(this.session, newSource.EventSourceId, newSource.Level, newSource.MatchAnyKeyword, sendManifest: true);
                this.eventSources.Add(newSource);
            }

            // removed sources
            foreach (var removedSource in this.eventSources.Except(updatedEventSources, eventSourceComparer).ToArray())
            {
                this.session.DisableProvider(removedSource.EventSourceId);
                this.eventSources.Remove(removedSource);
            }
        }
开发者ID:Brar,项目名称:entlib,代码行数:33,代码来源:TraceEventServiceWorker.cs

示例14: GatherBucklingLengthsCollection

        private static string GatherBucklingLengthsCollection(IEnumerable<BucklingLength> BucklingLengths)
        {
            StringBuilder output = new StringBuilder();
            IEnumerable<BucklingLength> verticalMembers;
            IEnumerable<BucklingLength> horizontalMembers;

            verticalMembers = BucklingLengths.Where(bl => bl.Member.Type == MEMBERTYPE.COLUMN || bl.Member.Type == MEMBERTYPE.POST).OrderBy(bl => bl.Member.StartNode.z).ThenBy(bl => bl.Member.StartNode.x).ThenBy(bl => bl.Member.StartNode.y);
            horizontalMembers = BucklingLengths.Except(verticalMembers).OrderBy(bl => bl.Member.StartNode.y).ThenBy(bl => bl.Member.StartNode.z).ThenBy(bl => bl.Member.StartNode.x);

            // Output Columns
            output.AppendLine("***");
            output.AppendLine("*** COLUMNS & POSTS");
            output.AppendLine("***");
            foreach (BucklingLength bl in verticalMembers)
                output.AppendLine(bl.ToSTAADString());
            // Output beams
            output.AppendLine("***");
            output.AppendLine("*** BEAMS & OTHERS");
            output.AppendLine("***");
            foreach (IGrouping<double, BucklingLength> bucklingLengthGroup in horizontalMembers.GroupBy(bl => bl.Member.StartNode.y))
            {
                output.AppendLine("***");
                output.AppendLine(string.Format("*** EL+{0:0.000}", bucklingLengthGroup.Key));
                output.AppendLine("***");
                foreach (BucklingLength bl in bucklingLengthGroup)
                    output.AppendLine(bl.ToSTAADString());
            }

            return output.ToString();
        }
开发者ID:yuominae,项目名称:STAADModel,代码行数:30,代码来源:Program.cs

示例15: GetFilenamesNotInCache

        public string[] GetFilenamesNotInCache(IEnumerable<string> filenamesToCheck)
        {
            var filenamesInCache = ListFiles().Select(fi => fi.Name);
            var filenamesNotInCache = filenamesToCheck.Except(filenamesInCache);

            return filenamesNotInCache.ToArray();
        }
开发者ID:srosenthal,项目名称:git-bin,代码行数:7,代码来源:CacheManager.cs


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