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


C# Collection.Except方法代码示例

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


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

示例1: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            //get the JSON string which
            //from the UI
            String jsonString = context.Request.Form[0];

            //get only the deliverable for the application
            Collection<String> appDeliverablesCol = client.GetApplication(jsonString).Deliverables;

            //all deliverables collection
            Collection<String> allDeliverablesCol = new Collection<String>();
            allDeliverablesCol.Add("WEB");
            allDeliverablesCol.Add("WS");
            allDeliverablesCol.Add("K2WS");
            allDeliverablesCol.Add("DB");
            allDeliverablesCol.Add("K2PROCESS");
            allDeliverablesCol.Add("REPORT");
            allDeliverablesCol.Add("BATCH");

            //get all deliverables that the application
            //is not conserned with
            Collection<String> notDeliverablesCol = allDeliverablesCol.Except(appDeliverablesCol).ToCollection();

            //set the response type to be JSON
            context.Response.ContentType = "application/json; charset=utf-8";

            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();

            //write the output back
            context.Response.Write(jsSerializer.Serialize(notDeliverablesCol));
        }
开发者ID:shaanino,项目名称:dmt,代码行数:31,代码来源:AppHandler.ashx.cs

示例2: UpdateIssueLabelsAsync

        private async Task UpdateIssueLabelsAsync(PortingInfo ruleToPort, Issue existingIssue)
        {
            var existingLabelNames = new Collection<string>(existingIssue.Labels.Select(label => label.Name).ToList());

            var labelNamesToAdd = new Collection<string>();
            var labelNamesToRemove = new Collection<string>();

            AddLabel(FxCopPortLabel, labelNamesToAdd, existingLabelNames);

            if (ruleToPort.Soon)
            {
                AddLabel(UrgencySoonLabel, labelNamesToAdd, existingLabelNames);
            }
            else
            {
                RemoveLabel(UrgencySoonLabel, labelNamesToRemove, existingLabelNames);
            }

            switch (ruleToPort.Disposition)
            {
                case Disposition.NeedsReview:
                    AddLabel(NeedsReviewLabel, labelNamesToAdd, existingLabelNames);
                    RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames);
                    break;

                case Disposition.Port:
                    RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames);
                    break;

                case Disposition.Cut:
                    AddLabel(CutLabel, labelNamesToAdd, existingLabelNames);
                    RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames);
                    break;

                case Disposition.Ported:
                    AddLabel(PortedLabel, labelNamesToAdd, existingLabelNames);
                    RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames);
                    break;
            }

            RemoveAreaLabels(existingLabelNames, labelNamesToRemove);
            AddAreaLabel(ruleToPort, labelNamesToAdd);

            if (_options.DryRun)
            {
                _log.Info(Resources.InfoDryRunLabelsNotUpdated);
            }
            else
            {
                if (labelNamesToAdd.Any())
                {
                    await _issuesLabelsClient.AddToIssue(
                        _options.RepoOwner,
                        _options.RepoName,
                        existingIssue.Number,
                        labelNamesToAdd.ToArray());
                }

                // Take care not to remove any labels we've just added.
                //
                // For some reason the "Remove" API doesn't take an array.
                foreach (string labelName in labelNamesToRemove.Except(labelNamesToAdd))
                {
                    await _issuesLabelsClient.RemoveFromIssue(
                        _options.RepoOwner,
                        _options.RepoName,
                        existingIssue.Number,
                        labelName);
                }
            }
        }
开发者ID:maggiemsft,项目名称:roslyn-analyzers,代码行数:76,代码来源:Program.cs

示例3: Get

        public Collection<Item> Get(Collection<int> ids)
        {
            var notInCache = ids.Except(_cache.Keys);

            // if some items don't exist in cache
            if (notInCache.Count() > 0)
            {
                _requestedIdsLock.EnterUpgradeableReadLock();
                try
                {
                    var needToGet = notInCache.Except(_requestedIds);

                    // if any items have not yet been requested by other threads
                    if (needToGet.Count() > 0)
                    {
                        _requestedIdsLock.EnterWriteLock();
                        try
                        {
                            // record the current request
                            foreach (var id in ids)
                                _requestedIds.Add(id);

                            _requestedIdsLock.ExitWriteLock();
                            _requestedIdsLock.ExitUpgradeableReadLock();

                            // get the data from the external resource
                            #region fake implementation - replace with real code
                            var data = new Collection<Item>();
                            foreach (var id in needToGet)
                            {
                                var item = _externalDataStoreProxy[id];
                                data.Add(item);
                            }
                            Thread.Sleep(10000);
                            #endregion

                            lock (_cache)
                            {
                                foreach (var item in data)
                                    _cache.Add(item.ID, item);

                                Monitor.PulseAll(_cache);
                            }
                        }
                        finally
                        {
                            // let go of any held locks
                            if (_requestedIdsLock.IsWriteLockHeld)
                                _requestedIdsLock.ExitWriteLock();
                        }
                    }

                    if (_requestedIdsLock.IsUpgradeableReadLockHeld)
                        _requestedIdsLock.ExitUpgradeableReadLock();

                    var waitingFor = notInCache.Except(needToGet);
                    // if any remaining items were already requested by other threads
                    if (waitingFor.Count() > 0)
                    {
                        lock (_cache)
                        {
                            while (waitingFor.Count() > 0)
                            {
                                Monitor.Wait(_cache);
                                waitingFor = waitingFor.Except(_cache.Keys);
                            }

                            // once we get here, _cache has all our items
                        }
                    }
                }
                finally
                {
                    // let go of any held locks
                    if (_requestedIdsLock.IsUpgradeableReadLockHeld)
                        _requestedIdsLock.ExitReadLock();
                }
            }

            return new Collection<Item>(ids.Select(id => _cache[id]).ToList());
        }
开发者ID:yetanotherchris,项目名称:crispy-succotash,代码行数:81,代码来源:DictionaryCache.cs


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