本文整理汇总了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 };
}
示例2: AvailablePackagesServiceRunFinished
private void AvailablePackagesServiceRunFinished(IList<Package> packages)
{
this.Invoke(() =>
{
IList<Package> distinct = packages.Distinct().ToList();
_bindingsource.DataSource = distinct;
});
}
示例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;
}
示例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];
}
}
示例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;
}
示例6: ReplaceRequiredAttendees
/// <summary>
/// Replaces all required attendees in an event
/// </summary>
public void ReplaceRequiredAttendees(IList<CalendarEventAttendee> attendees)
{
_requiredAttendees = attendees.Distinct().ToList();
IsDirty = true;
}
示例7: ReplaceOptionalAttendees
/// <summary>
/// Replaces all optional attendees in an event
/// </summary>
public void ReplaceOptionalAttendees(IList<CalendarEventAttendee> attendees)
{
_optionalAttendees = attendees.Distinct().ToList();
IsDirty = true;
}
示例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;
}
示例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";
}
示例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;
}
示例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;
}
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}