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


C# IList.Distinct方法代码示例

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


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

示例1: ImportJournals

        public JournalsImportResult ImportJournals(IList<Journal> journals, JournalsImportMode journalsImportMode)
        {
            var distinctJournals = journals.Distinct(new JournalIssnEqualityComparer()).ToList();

            var countries = this.ImportCountries(distinctJournals);
            var languages = this.ImportLanguages(distinctJournals);
            var subjects = this.ImportSubjects(distinctJournals);
            var publishers = this.ImportPublishers(distinctJournals);

            Logger.Info("Retrieving existing journals from database...");
            var allJournals = this.journalRepository.All;

            var currentJournalIssns = this.journalRepository.AllIssns.ToList();

            var newJournals = distinctJournals.Where(j => !currentJournalIssns.Contains(j.ISSN, StringComparer.InvariantCultureIgnoreCase)).ToList();

            Logger.Info("Found {0} new journals", newJournals.Count);

            var existingJournals = distinctJournals.Where(j => currentJournalIssns.Contains(j.ISSN, StringComparer.InvariantCultureIgnoreCase)).ToList();

            Logger.Info("Found {0} existing journals", existingJournals.Count);

            if (ShouldInsertJournals(journalsImportMode))
            {
                this.InsertJournals(newJournals, countries, publishers, languages, subjects);
            }

            if (ShouldUpdateJournals(journalsImportMode))
            {
                this.UpdateJournals(existingJournals, countries, publishers, languages, subjects, allJournals);
            }

            return new JournalsImportResult { NumberOfImportedJournals = distinctJournals.Count, NumberOfNewJournals = newJournals.Count };
        }
开发者ID:marijngiesen,项目名称:qoam,代码行数:34,代码来源:JournalsImport.cs

示例2: AvailablePackagesServiceRunFinished

 private void AvailablePackagesServiceRunFinished(IList<Package> packages)
 {
     this.Invoke(() =>
         {
             IList<Package> distinct = packages.Distinct().ToList();
             _bindingsource.DataSource = distinct;
         });
 }
开发者ID:jamescurran,项目名称:chocolatey-Explorer,代码行数:8,代码来源:AvailablePackagesGrid.cs

示例3: SignatureHelpItems

        public SignatureHelpItems(
            IList<SignatureHelpItem> items,
            TextSpan applicableSpan,
            int argumentIndex,
            int argumentCount,
            string argumentName,
            int? selectedItem = null)
        {
            Contract.ThrowIfNull(items);
            Contract.ThrowIfTrue(items.IsEmpty());
            Contract.ThrowIfTrue(selectedItem.HasValue && selectedItem.Value >= items.Count);

            if (argumentIndex < 0)
            {
                throw new ArgumentException($"{nameof(argumentIndex)} < 0. {argumentIndex} < 0", nameof(argumentIndex));
            }

            if (argumentCount < argumentIndex)
            {
                throw new ArgumentException($"{nameof(argumentCount)} < {nameof(argumentIndex)}. {argumentCount} < {argumentIndex}", nameof(argumentIndex));
            }

            // Adjust the `selectedItem` index if duplicates are able to be removed.
            var distinctItems = items.Distinct().ToList();
            if (selectedItem.HasValue && items.Count != distinctItems.Count)
            {
                // `selectedItem` index has already been determined to be valid, it now needs to be adjusted to point
                // to the equivalent item in the reduced list to account for duplicates being removed
                // E.g.,
                //   items = {A, A, B, B, C, D}
                //   selectedItem = 4 (index for item C)
                // ergo
                //   distinctItems = {A, B, C, D}
                //   actualItem = C
                //   selectedItem = 2 (index for item C)
                var actualItem = items[selectedItem.Value];
                selectedItem = distinctItems.IndexOf(actualItem);
                Debug.Assert(selectedItem.Value >= 0, "actual item was not part of the final list");
            }

            this.Items = distinctItems;
            this.ApplicableSpan = applicableSpan;
            this.ArgumentIndex = argumentIndex;
            this.ArgumentCount = argumentCount;
            this.SelectedItemIndex = selectedItem;
            this.ArgumentName = argumentName;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:47,代码来源:SignatureHelpItems.cs

示例4: ServiceProxyBase

		protected ServiceProxyBase( object unavailableImpl, Type typeInterface, IList<MethodInfo> mRefs, IList<EventInfo> eRefs )
		{
            Debug.Assert( mRefs.All( r => r != null ) && mRefs.Distinct().SequenceEqual( mRefs ) );
            _typeInterface = typeInterface;
            _status = RunningStatus.Disabled;
            RawImpl = _unavailableImpl = unavailableImpl;
            _mRefs = new MEntry[mRefs.Count];
            for( int i = 0; i < mRefs.Count; i++ )
            {
                _mRefs[i].Method = mRefs[i];
            }
            _eRefs = new EEntry[eRefs.Count];
            for( int i = 0; i < eRefs.Count; i++ )
            {
                _eRefs[i].Event = eRefs[i];
            }
        }
开发者ID:Nementon,项目名称:ck-desktop,代码行数:17,代码来源:ServiceProxyBase.cs

示例5: ConvexHull

        /// <summary>
        /// Implements gift wrapping algorithm.
        /// </summary>
        /// <param name="points">Set of points.</param>
        /// <returns>Polygon representing convex hull.</returns>
        public static Polygon ConvexHull(IList<Vector> points)
        {
            Debug.Assert(points != null);
            Debug.Assert(points.Count >= 3);

            // Leave only distinct points
            points = new List<Vector>(points.Distinct());

            // Find first point
            Vector hullStart = points[0];
            for (int i = 1; i < points.Count; ++i)
            {
                Vector point = points[i];
                if (point.X < hullStart.X || (point.X == hullStart.X && point.Y < hullStart.Y))
                    hullStart = point;
            }

            Vector currentHullPoint = hullStart;
            Polygon result = new Polygon();
            bool[] usedPoints = new bool[points.Count];
            do
            {
                result.vertices.Add(currentHullPoint);
                
                int nextHullPointIndex = 0;
                for (int i = 1; i < points.Count; ++i)
                {
                    if (usedPoints[nextHullPointIndex] ||
                        points[nextHullPointIndex] == currentHullPoint ||
                        Vector.CrossProduct(points[i] - currentHullPoint, points[nextHullPointIndex] - currentHullPoint) < 0)
                    {
                        nextHullPointIndex = i;
                    }
                }
                
                currentHullPoint = points[nextHullPointIndex];
                usedPoints[nextHullPointIndex] = true;
            } while (currentHullPoint != hullStart);

            return result;
        }
开发者ID:Li-Qiang-Sun,项目名称:segmentation-with-shape-priors,代码行数:46,代码来源:Polygon.cs

示例6: ReplaceRequiredAttendees

 /// <summary>
 /// Replaces all required attendees in an event
 /// </summary>
 public void ReplaceRequiredAttendees(IList<CalendarEventAttendee> attendees)
 {
     _requiredAttendees = attendees.Distinct().ToList();
     IsDirty = true;
 }
开发者ID:rkeilty,项目名称:RK.Calendar.Sync,代码行数:8,代码来源:CalendarEvent.cs

示例7: ReplaceOptionalAttendees

 /// <summary>
 /// Replaces all optional attendees in an event
 /// </summary>
 public void ReplaceOptionalAttendees(IList<CalendarEventAttendee> attendees)
 {
     _optionalAttendees = attendees.Distinct().ToList();
     IsDirty = true;
 }
开发者ID:rkeilty,项目名称:RK.Calendar.Sync,代码行数:8,代码来源:CalendarEvent.cs

示例8: CalculateDistinct

 private double CalculateDistinct(IList<double> values)
 {
     double result = 0.0;
     values = values.OrderBy(m => m).ToList();
     result = values.Distinct().Count() - 1 ;
     return result;
 }
开发者ID:darioestupinan,项目名称:NaiveBayes,代码行数:7,代码来源:NaiveBayes.cs

示例9: GetNumberType

        private static string GetNumberType(IList<int> list)
        {
            int digits = 0;
            if (list.Count == 2)
            {
                digits = list.Distinct().Count();
                return (digits == 2) ? "Z2" : "B2";
            }

            digits = list.Distinct().Count();
            if (digits == 3) return "Z36";
            return (digits == 2) ? "Z33" : "B3";
        }
开发者ID:peterchen,项目名称:gaopincai,代码行数:13,代码来源:ImportDmDPC.cs

示例10: GetReverseFlow

        public FlowMaster GetReverseFlow(FlowMaster flow, IList<string> itemCodeList)
        {
            FlowMaster reverseFlow = new FlowMaster();
            Mapper.Map(flow, reverseFlow);
            reverseFlow.PartyFrom = flow.PartyTo;
            reverseFlow.PartyTo = flow.PartyFrom;
            reverseFlow.IsCheckPartyFromAuthority = flow.IsCheckPartyToAuthority;
            reverseFlow.IsCheckPartyToAuthority = flow.IsCheckPartyFromAuthority;
            reverseFlow.ShipFrom = flow.ShipTo;
            reverseFlow.ShipTo = flow.ShipFrom;
            reverseFlow.LocationFrom = flow.LocationTo;
            reverseFlow.LocationTo = flow.LocationFrom;
            reverseFlow.IsShipScanHu = flow.IsReceiveScanHu;
            reverseFlow.IsReceiveScanHu = flow.IsShipScanHu;
            reverseFlow.IsShipFifo = flow.IsReceiveFifo;
            reverseFlow.IsReceiveFifo = flow.IsShipFifo;
            reverseFlow.IsShipExceed = flow.IsReceiveExceed;
            reverseFlow.IsReceiveExceed = flow.IsShipExceed;
            //reverseFlow.IsShipFulfillUC = flow.IsReceiveFulfillUC;
            //reverseFlow.IsReceiveFulfillUC = flow.IsShipFulfillUC;
            reverseFlow.IsInspect = flow.IsRejectInspect;
            reverseFlow.IsRejectInspect = flow.IsInspect;
            reverseFlow.IsCreatePickList = false;
            reverseFlow.IsShipByOrder = true;
            //以后有什么字段再加

            #region 路线明细
            if (flow.FlowDetails == null || flow.FlowDetails.Count == 0)
            {
                string hql = "from FlowDetail where Flow = ?";
                IList<object> parm = new List<object>();
                parm.Add(flow.Code);
                if (itemCodeList != null && itemCodeList.Count() > 0)
                {
                    string whereHql = string.Empty;
                    foreach (string itemCode in itemCodeList.Distinct())
                    {
                        if (whereHql == string.Empty)
                        {
                            whereHql = " and Item in (?";
                        }
                        else
                        {
                            whereHql += ",?";
                        }
                        parm.Add(itemCode);
                    }
                    whereHql += ")";
                    hql += whereHql;
                }
                hql += " order by Sequence";

                flow.FlowDetails = this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray());
            }

            if (flow.FlowDetails != null && flow.FlowDetails.Count > 0)
            {
                IList<FlowDetail> reverseFlowDetailList = new List<FlowDetail>();
                foreach (FlowDetail flowDetail in flow.FlowDetails)
                {
                    FlowDetail reverseFlowDetail = new FlowDetail();
                    Mapper.Map(flowDetail, reverseFlowDetail);
                    reverseFlowDetail.LocationFrom = flowDetail.LocationTo;
                    reverseFlowDetail.LocationTo = flowDetail.LocationFrom;
                    reverseFlowDetail.IsRejectInspect = flowDetail.IsInspect;
                    reverseFlowDetail.IsInspect = flowDetail.IsRejectInspect;
                    //PartyFrom?
                    reverseFlowDetailList.Add(reverseFlowDetail);
                }
                reverseFlow.FlowDetails = reverseFlowDetailList;
            }
            #endregion

            return reverseFlow;
        }
开发者ID:zhsh1241,项目名称:Sconit5_Shenya,代码行数:75,代码来源:FlowMgrImpl.cs

示例11: TryLoadFlowDetails

        private IList<FlowDetail> TryLoadFlowDetails(FlowMaster flowMaster, IList<string> itemCodeList)
        {
            if (!string.IsNullOrWhiteSpace(flowMaster.Code))
            {
                if (flowMaster.FlowDetails == null)
                {
                    string hql = "from FlowDetail where Flow = ?";
                    IList<object> parm = new List<object>();
                    parm.Add(flowMaster.Code);

                    if (itemCodeList != null && itemCodeList.Count > 0 && itemCodeList.Count < 2000)
                    {
                        string whereHql = string.Empty;
                        foreach (string itemCode in itemCodeList.Distinct())
                        {
                            if (whereHql == string.Empty)
                            {
                                whereHql = " and Item in (?";
                            }
                            else
                            {
                                whereHql += ",?";
                            }
                            parm.Add(itemCode);
                        }
                        whereHql += ")";
                        hql += whereHql;
                    }

                    hql += " order by Sequence";

                    flowMaster.FlowDetails = this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray());
                    if (itemCodeList != null && itemCodeList.Count >= 2000)
                    {
                        flowMaster.FlowDetails = flowMaster.FlowDetails.Where(f => itemCodeList.Contains(f.Item)).ToList();
                    }
                }

                return flowMaster.FlowDetails;
            }
            else
            {
                return null;
            }
        }
开发者ID:druidwang,项目名称:Les_parts,代码行数:45,代码来源:OrderMgrImpl.cs

示例12: GetFilteredLinksToVisit

        public IList<string> GetFilteredLinksToVisit(IList<string> linksToFilter, IList<string> visitedLinks, bool onlyRootLinks = true)
        {
            foreach (string visitedLink in visitedLinks) {
                linksToFilter.Remove(visitedLink);
            }

            //var rootUriWithoutHttpPrefix = rootUri.Replace("http://www", "");
            //rootUriWithoutHttpPrefix = rootUriWithoutHttpPrefix.Replace("https://www", "");

            IList<string> listToRemove = new List<string>();
            foreach (string link in linksToFilter) {
                if (onlyRootLinks) {
                    if (!link.Contains("devart.com")) {
                        listToRemove.Add(link);
                    }
                }

                foreach (string ignoreMask in LinkTypesToIgnoreForVisit) {
                    if (!listToRemove.Contains(link) &&
                        link.EndsWith(ignoreMask)) {
                        listToRemove.Add(link);
                    }
                }
            }

            foreach (string s in listToRemove) {
                linksToFilter.Remove(s);
            }

            return linksToFilter.Distinct().ToList();
        }
开发者ID:vgoetz,项目名称:DinoCrawlerWebClient,代码行数:31,代码来源:LinkFinder.cs

示例13: WhenAllContinuation

		public WhenAllContinuation (TaskCompletionSource<object> owner, IList<Task> tasks)
		{
			this.owner = owner;
            
            tasks = tasks.Distinct().ToList();
			counter = tasks.Count;
			
            foreach (var t in tasks)
                t.ContinueWith(this);
		}
开发者ID:sebastianhaba,项目名称:api,代码行数:10,代码来源:TaskContinuation.cs

示例14: GetFlowDetails

        public IList<FlowDetail> GetFlowDetails(IList<Int32> flowDetailIdList)
        {
            if (flowDetailIdList != null && flowDetailIdList.Count > 0)
            {
                IList<FlowDetail> flowDetailList = new List<FlowDetail>();

                string hql = string.Empty;
                IList<object> parm = new List<object>();

                foreach (int flowDetailId in flowDetailIdList.Distinct())
                {
                    if (hql == string.Empty)
                    {
                        hql = "from FlowDetail where Id in (?";
                    }
                    else
                    {
                        hql += ", ?";
                    }
                    parm.Add(flowDetailId);

                    if (parm.Count() >= 2000)
                    {
                        hql += ")";
                        ((List<FlowDetail>)flowDetailList).AddRange(this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray()));
                        hql = string.Empty;
                        parm = new List<object>();
                    }
                }

                hql += ")";
                if (parm.Count() > 0)
                {
                    ((List<FlowDetail>)flowDetailList).AddRange(this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray()));
                }

                return flowDetailList;
            }

            return null;
        }
开发者ID:Novthirteen,项目名称:sih-les,代码行数:41,代码来源:FlowMgrImpl.cs

示例15: EditPostAsync

		public async Task<bool> EditPostAsync(string postid, string title, string description, IList<string> categories, bool publish)
		{
			XmlRPC.Array array = new XmlRPC.Array((categories == null) ? 0 : categories.Count);
			if (categories != null)
			{
				List<string> list = categories.Distinct<string>().ToList<string>();
				list.Sort();
				List<Value> ss = new List<Value>();
				(
					from c in list
					select new StringValue(c)).ToList<StringValue>().ForEach(delegate(StringValue i)
				{
					ss.Add(i);
				});
				array.AddRange(ss);
			}
			Service service = new Service(this.BlogConnectionInfo.MetaWeblogURL);
			Struct @struct = new Struct();
			@struct["title"] = new StringValue(title);
			@struct["description"] = new StringValue(description);
			@struct["categories"] = array;
			MethodCall methodCall = new MethodCall("metaWeblog.editPost");
			methodCall.Parameters.Add(postid);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Username);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Password);
			methodCall.Parameters.Add(@struct);
			methodCall.Parameters.Add(publish);
			service.Cookies = this.BlogConnectionInfo.Cookies;
			MethodResponse methodResponse = await service.ExecuteAsync(methodCall);
			Value value = methodResponse.Parameters[0];
			BooleanValue booleanValue = (BooleanValue)value;
			return booleanValue.Boolean;
		}
开发者ID:WhitePoplar022,项目名称:CloudNotes,代码行数:33,代码来源:Client.cs


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