本文整理汇总了C#中IList.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Select方法的具体用法?C# IList.Select怎么用?C# IList.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Files
static bool Files(IList<string> unparsed)
{
if (unparsed.Count > 2)
{
Console.Error.WriteLine("Too many arguments for [files]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
Console.Error.WriteLine("Usage: vmc files <appname> <path>");
return false;
}
if (unparsed.Count < 1)
{
Console.Error.WriteLine("Not enough arguments for [files]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
Console.Error.WriteLine("Usage: vmc files <appname> <path (optional)>");
return false;
}
string appname = unparsed[0];
string path = string.Empty;
if (unparsed.Count == 2)
path = unparsed[1];
IVcapClient vc = new VcapClient();
byte[] output = vc.FilesSimple(appname, path, 0);
if (false == output.IsNullOrEmpty())
{
Stream stdout = Console.OpenStandardOutput();
stdout.Write(output, 0, output.Length);
stdout.Flush();
}
return true;
}
示例2: ToJson
/// <summary>
/// Converts a timestamp specified in seconds/nanoseconds to a string.
/// </summary>
/// <remarks>
/// If the value is a normalized duration in the range described in <c>field_mask.proto</c>,
/// <paramref name="diagnosticOnly"/> is ignored. Otherwise, if the parameter is <c>true</c>,
/// a JSON object with a warning is returned; if it is <c>false</c>, an <see cref="InvalidOperationException"/> is thrown.
/// </remarks>
/// <param name="paths">Paths in the field mask</param>
/// <param name="diagnosticOnly">Determines the handling of non-normalized values</param>
/// <exception cref="InvalidOperationException">The represented field mask is invalid, and <paramref name="diagnosticOnly"/> is <c>false</c>.</exception>
internal static string ToJson(IList<string> paths, bool diagnosticOnly)
{
var firstInvalid = paths.FirstOrDefault(p => !ValidatePath(p));
if (firstInvalid == null)
{
var writer = new StringWriter();
#if DOTNET35
var query = paths.Select(JsonFormatter.ToJsonName);
JsonFormatter.WriteString(writer, string.Join(",", query.ToArray()));
#else
JsonFormatter.WriteString(writer, string.Join(",", paths.Select(JsonFormatter.ToJsonName)));
#endif
return writer.ToString();
}
else
{
if (diagnosticOnly)
{
var writer = new StringWriter();
writer.Write("{ \"@warning\": \"Invalid FieldMask\", \"paths\": ");
JsonFormatter.Default.WriteList(writer, (IList)paths);
writer.Write(" }");
return writer.ToString();
}
else
{
throw new InvalidOperationException($"Invalid field mask to be converted to JSON: {firstInvalid}");
}
}
}
示例3: Calculate
public async Task<IssuesCollectionStatistics> Calculate(IList<JiraIssue> issues)
{
if(issues == null || issues.Any() == false)
return null;
return await Task.Factory.StartNew(() =>
{
return new IssuesCollectionStatistics
{
IssuesCount = issues.Count(),
ResolvedIssuesCount = issues.Where(i => i.Resolved.HasValue).Count(),
UnresolvedIssuesCount = issues.Where(i => i.Resolved.HasValue == false).Count(),
AverageResolutionTimeHours = issues
.Where(i => i.Resolved.HasValue)
.Select(i => (i.Resolved.Value - i.Created).TotalHours).Average(),
MaxResolutionTimeHours = issues
.Where(i => i.Resolved.HasValue)
.Select(i => (i.Resolved.Value - i.Created).TotalHours).Max(),
TotalStorypoints = issues.Sum(i => i.StoryPoints),
AverageStorypointsPerTask = issues.Average(i => i.StoryPoints),
AverageSubtasksCount = issues.Average(i => i.Subtasks),
EpicsInvolved = issues.Select(i => i.EpicLink).Distinct().Count(),
DistinctReporters = issues.Select(i => i.Reporter).Distinct().Count()
};
});
}
示例4: CopyOrMoveContentFromSelf
public OperationResult CopyOrMoveContentFromSelf(IList<FarFile> files, string destination, bool isMove)
{
OnDeviceOperation doc = null;
if (_fs.CurrentLevel == EFileSystemLevel.OnDevice)
{
var playLists = files.Select(p => (Playlist)p.Data);
if (IsSilentOperation() ||
CommonDialog.ForCopyPlayListsToPath(playLists, ref destination, isMove) == 0)
{
doc = new CopyContentFromSelfOperation(
_fs.CurrentDevice, playLists, destination, isMove);
}
}
else if (_fs.CurrentLevel == EFileSystemLevel.OnPlayList)
{
var tracks = files.Select(p => (Track)p.Data);
if (IsSilentOperation() ||
CommonDialog.ForCopyTracksToPath(tracks, ref destination, isMove) == 0)
{
doc = new CopyContentFromSelfOperation(
_fs.CurrentDevice, tracks, destination, isMove, IsInternalOperation() || IsSilentOperation());
}
}
return execOperation(doc, files);
}
示例5: CreateStyleXml
/// <summary>
/// Create a styles.xml file
/// </summary>
/// <param name="styles"></param>
/// <returns></returns>
internal static XmlFile CreateStyleXml(IList<XlsxCellStyle> styles)
{
var uniqueBorders = styles.Select(s => s.Border).Where(s => s != CellBorder.None).Distinct().ToList();
uniqueBorders.Insert(0, CellBorder.None);
var numberFormats = styles.Select(s => s.Format).Distinct().ToList();
var uniqueFonts = styles.Select(s => s.Font).Distinct().ToList();
uniqueFonts.Insert(0, new XlsxFont());
var file = new XmlFile
{
ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
Path = "xl/styles.xml"
};
var doc = new XDocument(new XElement(Namespaces.workbook + "styleSheet", new XAttribute("xmlns", Namespaces.workbook)));
StyleAddNumFmtsElement(doc, numberFormats);
StyleAddFontsElement(doc, uniqueFonts);
StyleAddFillsElement(doc);
StyleAddBordersElement(doc, uniqueBorders);
StyleAddCellStyleXfsElement(doc);
StyleAddCellXfsElement(doc, styles, uniqueBorders, numberFormats, uniqueFonts);
file.Content = doc;
return file;
}
示例6: GetBaiduStaticMap
/// <summary>
/// 获取百度地图静态图片
/// </summary>
/// <param name="lng">中心点经度</param>
/// <param name="lat">中心点维度</param>
/// <param name="scale">
/// 返回图片大小会根据此标志调整。取值范围为1或2:
/// 1表示返回的图片大小为size= width * height;
/// 2表示返回图片为(width*2)*(height *2),且zoom加1
/// 注:如果zoom为最大级别,则返回图片为(width*2)*(height*2),zoom不变。
/// </param>
/// <param name="zoom">地图级别。高清图范围[3, 18];低清图范围[3,19]</param>
/// <param name="markersList">标记列表,如果为null则不输出标记</param>
/// <param name="width">图片宽度。取值范围:(0, 1024]。</param>
/// <param name="height">图片高度。取值范围:(0, 1024]。</param>
/// <returns></returns>
public static string GetBaiduStaticMap(double lng, double lat, int scale, int zoom,
IList<BaiduMarkers> markersList, int width = 400, int height = 300)
{
var url = new StringBuilder();
url.Append("http://api.map.baidu.com/staticimage?");
url.AppendFormat("center={0},{1}", lng, lat);
url.AppendFormat("&width={0}", width);
url.AppendFormat("&height={0}", height);
url.AppendFormat("&scale={0}", scale);
url.AppendFormat("&zoom={0}", zoom);
if (markersList != null && markersList.Count > 0)
{
url.AppendFormat("&markers={0}",
string.Join("|",
markersList.Select(z => string.Format("{0},{1}", z.Longitude, z.Latitude)).ToArray()));
url.AppendFormat("&markerStyles={0}",
string.Join("|",
markersList.Select(z => string.Format("{0},{1},{2}", z.Size.ToString(), z.Label, z.Color))
.ToArray()));
}
return url.ToString();
}
示例7: 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));
}
示例8: DesignTimeCompilationException
public DesignTimeCompilationException(IList<DiagnosticMessage> compileResponseErrors)
: base(string.Join(Environment.NewLine, compileResponseErrors.Select(e => e.FormattedMessage)))
{
CompilationFailures = compileResponseErrors.GroupBy(g => g.SourceFilePath, StringComparer.OrdinalIgnoreCase)
.Select(g => new CompilationFailure(g.Key, g))
.ToArray();
}
示例9: GetLocationSelectedListItem
public static void GetLocationSelectedListItem(IList<Location> locations, out MultiSelectList allLocation, out List<SelectListItem> selectListItems)
{
var multiSelectList = new MultiSelectList(locations, "LocationId", "Province", locations);
allLocation = multiSelectList;
selectListItems =
locations.Select(o => new SelectListItem { Text = o.Province, Value = o.Province }).ToList();
}
示例10: TestConstructorArgumentsNullCombinations
public static void TestConstructorArgumentsNullCombinations(Type testedType, Type[] typeArguments, IList<Func<object>> arguments)
{
if (testedType.IsGenericType)
{
testedType = testedType.MakeGenericType(typeArguments);
}
var argumentTypes = arguments.Select(argument => argument.Method.ReturnType).ToArray();
var constructor = testedType.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, argumentTypes, null);
if (constructor == null)
{
throw new ArgumentException("Constructor could not be found");
}
for (int i = 0; i < arguments.Count; i++)
{
object[] args = arguments.Select(a => a()).ToArray();
args[i] = null;
Assert.That(() =>
{
try
{
constructor.Invoke(args);
}
catch (TargetInvocationException exception)
{
throw exception.InnerException;
}
}, Throws.TypeOf<ArgumentNullException>());
}
}
示例11: ExtractEvaluationUnitSamplesFromSpecies
/// <summary>
/// Extracts the specified number of evaluation unit samples from each navigator/maze species for subsuquent clustering
/// analysis.
/// </summary>
/// <param name="experimentId">The experiment that was executed.</param>
/// <param name="run">The run number of the given experiment.</param>
/// <param name="batch">The batch number of the given run.</param>
/// <param name="allEvaluationUnits">All evaluation during the given experiment/run/batch.</param>
/// <param name="sampleSize">The sample size to extract from each navigator/maze species.</param>
/// <returns>The specified number of evaluation unit samples from each navigator/maze species.</returns>
public static IList<MazeNavigatorEvaluationUnit> ExtractEvaluationUnitSamplesFromSpecies(int experimentId,
int run,
int batch, IList<MazeNavigatorEvaluationUnit> allEvaluationUnits, int sampleSize)
{
List<MazeNavigatorEvaluationUnit> evalUnitSamples = new List<MazeNavigatorEvaluationUnit>();
// Extract all maze and navigator genome IDs
var allMazeGenomeIds = allEvaluationUnits.Select(eu => eu.MazeId).Distinct().ToList();
var allNavigatorGenomeIds = allEvaluationUnits.Select(eu => eu.AgentId).Distinct().ToList();
// Get the species to which the mazes and navigators are assigned
var mazeSpecieGenomesGroups = ExperimentDataHandler.GetSpecieAssignmentsForMazeGenomeIds(experimentId, run,
batch, allMazeGenomeIds);
var navigatorSpecieGenomesGroups =
ExperimentDataHandler.GetSpecieAssignmentsForNavigatorGenomeIds(experimentId, run, batch,
RunPhase.Primary, allNavigatorGenomeIds);
// Extract a sample of mazes and navigators for each of their respective species
var sampleMazeIds = ExtractGenomeIdSample(mazeSpecieGenomesGroups, sampleSize);
var sampleNavigatorIds = ExtractGenomeIdSample(navigatorSpecieGenomesGroups, sampleSize);
// Collect maze and navigator samples
CollectEvaluationSamples(sampleMazeIds, allEvaluationUnits, evalUnitSamples, true);
CollectEvaluationSamples(sampleNavigatorIds, allEvaluationUnits, evalUnitSamples, true);
return evalUnitSamples;
}
示例12: TaskMessages
public TaskMessages(RemoteTask task, string taskMatchStyle, IList<TaskMessage> taskMessages)
{
this.task = task;
this.taskMatchStyle = taskMatchStyle;
messages = taskMessages.Select(tm => tm.Message).ToList();
serverActions = taskMessages.Select(tm => tm.ServerAction).ToList();
}
示例13: GetDayActivity
public IList<string> GetDayActivity(IList<string> zoo, string killer)
{
if (!zoo.Contains(killer))
{
return new List<string>();
}
var herring = new List<string>(GameResources.Herrings);
var goodTraits = new List<string>(GameResources.GoodTraits);
var badTraits = new List<string>(GameResources.BadTraits);
herring.Shuffle();
goodTraits.Shuffle();
badTraits.Shuffle();
// good and bad traits
int badIndex = 0;
int goodIndex = 0;
var clues = zoo.Select(x =>
{
double chance = x == killer ? ChanceBadKillerTrait : ChanceBadFodderTrait;
string trait = Extensions.RandomGenerator.Next(0, 999)/1000.0 < chance
? badTraits[badIndex++]
: goodTraits[goodIndex++];
return String.Format(trait, x);
}).ToList();
// herrings
int herringIndex = 0;
clues.AddRange(zoo.Select(x => String.Format(herring[herringIndex++], x)));
clues.Shuffle();
return clues;
}
示例14: Volume
public Volume(IList<Point> points)
{
var rangeX = new Range(points.Select(p => p.X));
var rangeY = new Range(points.Select(p => p.Y));
var rangeZ = new Range(points.Select(p => p.Z));
this.location = new Point(rangeX.Min, rangeY.Min, rangeZ.Min);
this.width = rangeX.Interval;
this.height = rangeY.Interval;
this.depth = rangeZ.Interval;
}
示例15: GetRoomsStates
private IList<RoomState> GetRoomsStates(IList<Room> rooms, DateTime date)
{
var roomsIds = rooms.Select(r => r.Id).ToList();
var furnitureItems = furnitureReader.Get(roomsIds, date);
return rooms.Select(room => new RoomState
{
RoomId = room.Id,
Date = room.CreateDate,
RoomName = room.Name,
FurnitureItems = furnitureItems.Where(f => f.RoomId == room.Id).ToList()
}).ToList();
}