本文整理汇总了C#中IReadOnlyList.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyList.Skip方法的具体用法?C# IReadOnlyList.Skip怎么用?C# IReadOnlyList.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyList
的用法示例。
在下文中一共展示了IReadOnlyList.Skip方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOrder
public Dictionary<int, Dictionary<string, int>> GetOrder(IReadOnlyList<string> req)
{
// Create a response object
var responseDictionary = new Dictionary<int, Dictionary<string,int>>();
// Check if time of day value is good
var isMorning = req[0].IsMorningCheck();
if(isMorning == null)
{
responseDictionary = ErrorMessage.AddErrorMessage(responseDictionary);
return responseDictionary;
}
// Get our list of food items from our data source
var foodList = Dishes.GetFoodList2();
// Loop through request and add up food items
foreach (var item in req.Skip(1).Where(n => n != string.Empty))
{
int foodListItem;
int.TryParse(item, out foodListItem);
// Food Item not found return error
if (foodListItem > foodList.Count())
{
responseDictionary = ErrorMessage.AddErrorMessage(responseDictionary);
return responseDictionary;
}
// Grab our Dish
var foodItem = foodList[foodListItem];
// Get the morning or night dish
var dish = (bool) isMorning ? foodItem.MorningDish : foodItem.NightDish;
// If this dish is already in our response list then let's increment if we can have more than 1
// or return on error if not.
if (responseDictionary.ContainsKey(foodListItem))
{
// Check list of items that can have more than 1
if (dish.Equals("potato") || dish.Equals("coffee"))
responseDictionary[foodListItem][dish]++;
else // else let's error out
{
responseDictionary = ErrorMessage.AddErrorMessage(responseDictionary);
return responseDictionary;
}
}
else
{
// Else let's add a new dish item to the list
responseDictionary.Add(foodListItem, new Dictionary<string, int> { { dish, 1 } });
}
}
// Return our response
return responseDictionary;
}
示例2: LaunchCommand
static void LaunchCommand(IReadOnlyList<string> args)
{
var commandTypeSwitch = args[0];
var commandFactory = new CommandFactory(_diContainer);
var command = commandFactory.CreateCommand(commandTypeSwitch);
var commandArguments = args.Skip(1);
command.Execute(commandArguments);
}
示例3: GetStringContents
public static IReadOnlyList<string> GetStringContents(string textBeforeCollapse, string textAfterCollapse, IReadOnlyList<string> collapsedContent) {
var contents = new List<string> {
textBeforeCollapse + (collapsedContent.Any() ? collapsedContent[0] : string.Empty)
};
contents.AddRange(from text in collapsedContent.Skip(1).Take(collapsedContent.Count - 1)
select text);
contents[contents.Count - 1] += textAfterCollapse;
return contents;
}
示例4: Expand
private static IReadOnlyList<ParameterInstances> Expand(IReadOnlyList<ParameterInstances> instancesList, IReadOnlyList<ParameterDefinition> definitions)
{
if (definitions.IsNullOrEmpty())
return instancesList;
var nextDefinition = definitions.First();
var newInstancesList = new List<ParameterInstances>();
foreach (var instances in instancesList)
{
foreach (var value in nextDefinition.Values)
{
var items = new List<ParameterInstance>();
items.AddRange(instances.Items);
items.Add(new ParameterInstance(nextDefinition, value));
newInstancesList.Add(new ParameterInstances(items));
}
}
return Expand(newInstancesList, definitions.Skip(1).ToArray());
}
示例5: DetermineFilePath
string DetermineFilePath (DocumentId id, string name, string filePath, IReadOnlyList<string> docFolders, string defaultFolder, bool createDirectory = false)
{
var path = filePath;
if (string.IsNullOrEmpty (path)) {
var monoProject = GetMonoProject (id.ProjectId);
// If the first namespace name matches the name of the project, then we don't want to
// generate a folder for that. The project is implicitly a folder with that name.
IEnumerable<string> folders;
if (docFolders.FirstOrDefault () == monoProject.Name) {
folders = docFolders.Skip (1);
} else {
folders = docFolders;
}
if (folders.Any ()) {
string baseDirectory = Path.Combine (monoProject.BaseDirectory, Path.Combine (folders.ToArray ()));
try {
if (createDirectory && !Directory.Exists (baseDirectory))
Directory.CreateDirectory (baseDirectory);
} catch (Exception e) {
LoggingService.LogError ("Error while creating directory for a new file : " + baseDirectory, e);
}
path = Path.Combine (baseDirectory, name);
} else {
path = Path.Combine (defaultFolder, name);
}
}
return path;
}
示例6: CreateUnprocessedRequests
private static IReadOnlyList<WriteRequest> CreateUnprocessedRequests(IReadOnlyList<WriteRequest> requests, IReadOnlyList<BulkWriteOperationError> writeErrors, bool isOrdered)
{
if (!isOrdered || writeErrors.Count == 0)
{
return __noWriteRequests;
}
else
{
var processedCount = writeErrors.Max(e => e.Index) + 1;
return requests.Skip(processedCount).ToList();
}
}
示例7: ParseCommaSeparatedList
private static IEnumerable<Expression> ParseCommaSeparatedList(IReadOnlyList<Token> tokens, Dictionary<string, Expression> variableMap)
{
var currentElement = new List<Token>();
var tokenGroups = new List<List<Token>>();
for (var i = 0; i < tokens.Count; i++)
{
var token = tokens[i];
if (token.Type == TokenType.Comma)
{
tokenGroups.Add(currentElement.Select(e => e).ToList()); // move a copy of the list, not a reference
currentElement.Clear();
}
else if (token.Type == TokenType.OpenBrace)
{
var indexOfMatchingBrace = IndexOfMatchingBrace(tokens, i);
var tokenSubList = tokens.Skip(i + 1).Take(indexOfMatchingBrace - i - 1).ToList();
var innerList = ParseCommaSeparatedList(tokenSubList, variableMap).ToList();
var list = new ExpressionListToken(new ExpressionList(innerList));
currentElement.Add(list);
i = indexOfMatchingBrace;
}
else if (token.Type == TokenType.CloseBrace)
{
throw new SyntaxErrorException("Mismatched braces");
}
else
{
currentElement.Add(token);
}
}
tokenGroups.Add(currentElement.Select(e => e).ToList()); // move a copy of the list
currentElement.Clear();
return tokenGroups.Select(tokenGroup => ParsePostfix(CreatePostfixTokenList(tokenGroup, variableMap), variableMap));
}
示例8: OnSetParameters
protected override void OnSetParameters( int version, IReadOnlyList<string> parameters )
{
// Parameter 1: Attribute Key
AttributeKey = DataComponentSettingsHelper.GetParameterOrEmpty( parameters, 0 );
// Parameter 2+: Remaining Parameters represent settings that are specific to the filter for the selected Attribute.
AttributeFilterSettings = new List<string>();
AttributeFilterSettings.AddRange( parameters.Skip( 1 ) );
}
示例9: ProceedAddPhoneCommand
private void ProceedAddPhoneCommand(IReadOnlyList<string> commandParameters)
{
var name = commandParameters[0];
var phones = commandParameters.Skip(1).Select(FormatPhoneNumber);
var isPhoneAdded = this.repository.AddPhone(name, phones);
this.output.AppendLine(isPhoneAdded ? "Phone entry created" : "Phone entry merged");
}
示例10: Join
/// <summary>
/// Join TreeLayouts.
/// </summary>
/// <param name="treeLayouts">The TreeLayouts to join.</param>
/// <param name="sep">Horzontal sep between nodes.</param>
/// <returns>(Left, Right, TreeRowWidths, Pivots)</returns>
public static Tuple<double, double, IList<TreeRowWidth>, IReadOnlyList<double>> Join(IReadOnlyList<TreeLayout> treeLayouts, double sep)
{
double left = 0;
double right = treeLayouts.First().Width;
var rowWidths = treeLayouts.First().RowWidths.ToList();
var pivots = new List<double>() { treeLayouts.First().Pivot };
foreach (var layout in treeLayouts.Skip(1))
{
double offset = rowWidths.Zip(layout.RowWidths, (l, r) => l.Right + r.Left).Min() - sep;
pivots.Add(right + layout.Pivot - offset);
if (layout.RowWidths.Count <= rowWidths.Count)
{
double rightSpace = layout.Width - offset;
if (rightSpace < 0)
{
for (int i = 0; i < layout.RowWidths.Count; i++)
{
rowWidths[i].Right = layout.RowWidths[i].Right - rightSpace;
}
}
else
{
// Extend right.
right += rightSpace;
for (int i = 0; i < layout.RowWidths.Count; i++)
{
rowWidths[i].Right = layout.RowWidths[i].Right;
}
for (int i = layout.RowWidths.Count; i < rowWidths.Count; i++)
{
rowWidths[i].Right += rightSpace;
}
}
}
else
{
double leftSpace = right - left - offset;
if (leftSpace <= 0)
{
// Extend left.
left += leftSpace;
for (int i = 0; i < rowWidths.Count; i++)
{
rowWidths[i].Left -= leftSpace;
rowWidths[i].Right = layout.RowWidths[i].Right;
}
rowWidths.AddRange(layout.RowWidths.Skip(rowWidths.Count));
}
else
{
for (int i = 0; i < rowWidths.Count; i++)
{
rowWidths[i].Right = layout.RowWidths[i].Right;
}
rowWidths.AddRange(layout.RowWidths.Skip(rowWidths.Count).Select(r => new TreeRowWidth(r.Left + leftSpace, r.Right)));
}
// Extend right.
right += layout.Width - offset;
}
}
return Tuple.Create<double, double, IList<TreeRowWidth>, IReadOnlyList<double>>(left, right, rowWidths, pivots);
}
示例11: FindNameForMultiLayoutMode
private static string FindNameForMultiLayoutMode(IReadOnlyList<TrackObjectBase> obj) {
var baseName = obj[0].Name;
if (baseName == null) return null;
for (var i = obj.Where(x => x.Name != null).Select(x => x.Name.Length).Min(); i > 2; i--) {
var result = baseName.Substring(0, i);
if (obj.Skip(1).Any(x => x.Name?.Substring(0, i) != result)) continue;
result = result.Trim();
if (result.Length > 2 && result.EndsWith(@"-") || result.EndsWith(@"—")) {
result = result.Substring(0, result.Length - 1).Trim();
}
return result;
}
return null;
}
示例12: CombineGeometries
private static Geometry CombineGeometries(IReadOnlyList<Geometry> geometries)
{
Debug.Assert(geometries.Count > 0);
if (geometries.Count == 1) return geometries.First();
var seed = new CombinedGeometry(GeometryCombineMode.Union, geometries[0], geometries[1]);
return geometries.Skip(2).Aggregate(seed, (cg, g) => new CombinedGeometry(GeometryCombineMode.Union, cg, g));
}