本文整理汇总了C#中IList.First方法的典型用法代码示例。如果您正苦于以下问题:C# IList.First方法的具体用法?C# IList.First怎么用?C# IList.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.First方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapXmlToDomain
public Junction MapXmlToDomain(XmlJunction xmlJunction, IList<SplitTrack> subTracks)
{
SplitTrack defaultTrack = subTracks.First(subTrack => xmlJunction.BranchDefaultId.Equals(subTrack.Id));
SplitTrack altTrack = subTracks.First(subTrack => xmlJunction.BranchAlternateId.Equals(subTrack.Id));
return new Junction(xmlJunction.Id, defaultTrack, altTrack, xmlJunction.Direction);
}
示例2: UpdateManifest
//exactly same as x.browser
private static void UpdateManifest(IList<Services.Data.ExtensionManifestDataModel> found, IExtensionManifest ext)
{
if (found != null && found.Count() > 0)
{
ext.IsExtEnabled = found.First().IsExtEnabled;
ext.LaunchInDockPositions = (ExtensionInToolbarPositions)found.First().LaunchInDockPositions;
ext.FoundInToolbarPositions = (ExtensionInToolbarPositions)found.First().FoundInToolbarPositions;
}
}
示例3: CurrencyRateViewMode
public CurrencyRateViewMode(IList<CurrencyRate> rates)
{
var dollarSellingRate = rates.First(r => r.Type == TradeType.Selling && r.CurrencyName == "Dollar");
var euroSellingRate = rates.First(r => r.Type == TradeType.Selling && r.CurrencyName == "Euro");
var dollarBuyingRate = rates.First(r => r.Type == TradeType.Buying && r.CurrencyName == "Dollar");
var euroBuyingRate = rates.First(r => r.Type == TradeType.Buying && r.CurrencyName == "Euro");
SellingUsDollar = new RateKeyPair(dollarSellingRate.RateId){ExchangePrice = dollarSellingRate.ExchangePrice};
SellingEuro = new RateKeyPair(euroSellingRate.RateId) { ExchangePrice = euroSellingRate.ExchangePrice};
BuyingUsDollar = new RateKeyPair(dollarBuyingRate.RateId) {ExchangePrice = dollarBuyingRate.ExchangePrice};
BuyingEuro = new RateKeyPair(euroBuyingRate.RateId) { ExchangePrice = euroBuyingRate.ExchangePrice };
}
示例4: CreateSection
private Section CreateSection(IList<string> lines, int level)
{
string title = null;
var headingMarker = new String('#', level) + " ";
if (lines.First().StartsWith(headingMarker))
{
title = lines.First().TrimStart('#').Trim();
lines.RemoveAt(0);
}
var furtherLevelMarkers = new String('#', level + 1);
return lines.Any(x => x.StartsWith(furtherLevelMarkers))
? new Section(level, title, BreakDownSection(lines, level + 1).ToList())
: new Section(level, title, string.Join(Environment.NewLine, lines));
}
示例5: Statistics
public Statistics(IList<IVehicle> vehicles, bool removeOutliers = true)
{
if (vehicles == null || !vehicles.Any())
throw new ArgumentException("Vehicles is null or count is 0. Must be greater than 0");
_vehicles = vehicles;
_outlierVehicles = new List<OutlierVehicle>();
Make = _vehicles.First().Make;
Model = _vehicles.First().Model;
if (removeOutliers)
{
RemoveOutliers();
}
}
示例6: GetHourlyEnergyMeasure
public Measure GetHourlyEnergyMeasure(IList<Measure> sourceMeasures, string hourMeasureSource, string hourDataVariable)
{
var dataVariable = hourDataVariable;
var measurePercentage = 1;
var plant = sourceMeasures.First().Plant;
var reliability = 0;
var resolution = getHourResolution();
var source = hourMeasureSource;
var utcDate = sourceMeasures.First().UtcDate;
var utcHour = sourceMeasures.First().UtcHour;
var utcMinute = 00;
var utcSecond = 00;
var value = getValue(sourceMeasures);
return new Measure(plant, source, dataVariable, utcDate, utcHour, utcMinute, utcSecond, value, measurePercentage, reliability, resolution);
}
示例7: SortItems
/// <summary>
/// Sort the items by their priority and their index they currently exist in the collection
/// </summary>
/// <param name="files"></param>
/// <returns></returns>
public static IList<IClientDependencyFile> SortItems(IList<IClientDependencyFile> files)
{
//first check if each item's order is the same, if this is the case we'll make sure that we order them
//by the way they were defined
if (!files.Any()) return files;
var firstPriority = files.First().Priority;
if (files.Any(x => x.Priority != firstPriority))
{
var sortedOutput = new List<IClientDependencyFile>();
//ok they are not the same so we'll need to sort them by priority and by how they've been entered
var groups = files.GroupBy(x => x.Priority).OrderBy(x => x.Key);
foreach (var currentPriority in groups)
{
//for this priority group, we'll need to prioritize them by how they are found in the files array
sortedOutput.AddRange(currentPriority.OrderBy(files.IndexOf));
}
return sortedOutput;
}
//they are all the same so we can really just return the original list since it will already be in the
//order that they were added.
return files;
}
示例8: FeedResult
private FeedResult FeedResult(IList<SyndicationItem> items)
{
var settings = Settings.GetSettings<FunnelWebSettings>();
Debug.Assert(Request.GetOriginalUrl() != null, "Request.GetOriginalUrl() != null");
var baseUri = Request.GetOriginalUrl();
var feedUrl = new Uri(baseUri, Url.Action("Recent", "Wiki"));
return new FeedResult(
new Atom10FeedFormatter(
new SyndicationFeed(settings.SiteTitle, settings.SearchDescription, feedUrl, items)
{
Id = baseUri.ToString(),
Links =
{
new SyndicationLink(baseUri)
{
RelationshipType = "self"
}
},
LastUpdatedTime = items.Count() == 0 ? DateTime.Now : items.First().LastUpdatedTime
}), items.Max(i => i.LastUpdatedTime.LocalDateTime))
{
ContentType = "application/atom+xml"
};
}
示例9: Create
public static MapRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, ContextFacade contextFacade, IList<ContextFacade> contexts, Format format, RestControlFlags flags, MediaTypeHeaderValue mt) {
var memberValues = contexts.Select(c => new OptionalProperty(c.Id, GetMap(oidStrategy, req, c, flags))).ToList();
IObjectFacade target = contexts.First().Target;
MapRepresentation mapRepresentation;
if (format == Format.Full) {
var tempProperties = new List<OptionalProperty>();
if (!string.IsNullOrEmpty(contextFacade?.Reason)) {
tempProperties.Add(new OptionalProperty(JsonPropertyNames.XRoInvalidReason, contextFacade.Reason));
}
var dt = new OptionalProperty(JsonPropertyNames.DomainType, target.Specification.DomainTypeName(oidStrategy));
tempProperties.Add(dt);
var members = new OptionalProperty(JsonPropertyNames.Members, Create(memberValues.ToArray()));
tempProperties.Add(members);
mapRepresentation = Create(tempProperties.ToArray());
}
else {
mapRepresentation = Create(memberValues.ToArray());
}
mapRepresentation.SetContentType(mt);
return mapRepresentation;
}
示例10: AugmentCompletionSession
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
if (IsHtmlFile && completionSets.Any())
{
var bottomSpan = completionSets.First().ApplicableTo;
if (!JScriptEditorUtil.IsInJScriptLanguageBlock(_lbm, bottomSpan.GetStartPoint(bottomSpan.TextBuffer.CurrentSnapshot)))
{
// This is an HTML statement completion session, so do nothing
return;
}
}
// TODO: Reflect over the ShimCompletionSet to see where the Description value comes from
// as setting the property does not actually change the value.
var newCompletionSets = completionSets
.Select(cs => cs == null ? cs : new ScriptCompletionSet(
cs.Moniker,
cs.DisplayName,
cs.ApplicableTo,
cs.Completions
.Select(c => c == null ? c : new Completion(
c.DisplayText,
c.InsertionText,
DocCommentHelper.ProcessParaTags(c.Description),
c.IconSource,
c.IconAutomationText))
.ToList(),
cs.CompletionBuilders))
.ToList();
completionSets.Clear();
newCompletionSets.ForEach(cs => completionSets.Add(cs));
}
示例11: MainWindow
public MainWindow()
{
InitializeComponent();
Loaded += (sender, e) => ClearValue(SizeToContentProperty);
_allControllerViewModels =
(from type in GetType().Assembly.GetTypes()
where !type.IsInterface && typeof(IController).IsAssignableFrom(type)
let viewModel = new ControllerViewModel((IController)Activator.CreateInstance(type))
orderby viewModel.SortIndex, viewModel.Library, viewModel.Description
select viewModel).ToList();
_allControllerViewModels.First().IsChecked = true;
ControllerGroups.ItemsSource = _allControllerViewModels.GroupBy(viewModel => viewModel.Library);
_allResolutionViewModels = new[] {
new ResolutionViewModel(800, 600, 50, 42),
new ResolutionViewModel(1024, 768, 64, 54),
new ResolutionViewModel(1280, 1024, 80, 73),
new ResolutionViewModel(1440, 900, 90, 64),
};
_allResolutionViewModels.Last(
res => res.Width <= SystemParameters.PrimaryScreenWidth &&
res.Height <= SystemParameters.PrimaryScreenHeight).IsChecked = true;
Resolutions.ItemsSource = _allResolutionViewModels;
RunResults.ItemsSource = _runResults;
}
示例12: CheckFirstAndLastPoint
private void CheckFirstAndLastPoint(IList<Point> points)
{
if (this.DistanceIsTooSmall(points.Last(), points.First()))
{
points.RemoveAt(points.Count - 1);
}
}
示例13: Filter
public IList<DepthPointEx> Filter(IList<DepthPointEx> points)
{
IList<DepthPointEx> result = new List<DepthPointEx>();
if (points.Count > 0)
{
var point = new DepthPointEx(points.First());
result.Add(point);
foreach (var currentSourcePoint in points.Skip(1))
{
if (!PointsAreClose(currentSourcePoint, point))
{
point = new DepthPointEx(currentSourcePoint);
result.Add(point);
}
}
if (result.Count > 1)
{
CheckFirstAndLastPoint(result);
}
}
return result;
}
示例14: Update
public int Update(AdoAdapter adapter, string tableName, IList<IDictionary<string, object>> data, IDbTransaction transaction, IList<string> keyFields)
{
int count = 0;
if (data == null) throw new ArgumentNullException("data");
if (data.Count < 2) throw new ArgumentException("UpdateMany requires more than one record.");
if (keyFields.Count == 0) throw new NotSupportedException("Adapter does not support key-based update for this object.");
if (!AllRowsHaveSameKeys(data)) throw new SimpleDataException("Records have different structures. Bulk updates are only valid on consistent records.");
var table = adapter.GetSchema().FindTable(tableName);
var exampleRow = new Dictionary<string, object>(data.First(), HomogenizedEqualityComparer.DefaultInstance);
var commandBuilder = new UpdateHelper(adapter.GetSchema()).GetUpdateCommand(tableName, exampleRow,
ExpressionHelper.CriteriaDictionaryToExpression(
tableName, GetCriteria(keyFields, exampleRow)));
using (var connectionScope = ConnectionScope.Create(transaction, adapter.CreateConnection))
using (var command = commandBuilder.GetRepeatableCommand(connectionScope.Connection))
{
var propertyToParameterMap = CreatePropertyToParameterMap(data, table, command);
foreach (var row in data)
{
foreach (var kvp in row)
{
propertyToParameterMap[kvp.Key].Value = kvp.Value ?? DBNull.Value;
}
count += command.ExecuteNonQuery();
}
}
return count;
}
示例15: CheckFirstAndLastPoint
private void CheckFirstAndLastPoint(IList<DepthPointEx> points)
{
if (PointsAreClose(points.Last(), points.First()))
{
points.RemoveAt(points.Count - 1);
}
}