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


C# IEnumerable.Skip方法代码示例

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


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

示例1: ResolveDirectory

        Directory ResolveDirectory(Directory directory, IEnumerable<string> children)
        {
            if (!children.Any())
                return directory;

            string childName = children.First();

            Directory info = directory.GetDirectories()
                .Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
                .SingleOrDefault();

            if (info != null)
            {
                return ResolveDirectory(info, children.Skip(1));
            }

            File file = directory.GetFiles()
                .Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
                .SingleOrDefault();

            if (file == null)
                throw new InvalidOperationException("Could not get directory: " + childName);

            if (Path.GetExtension(file.Name.GetName()) == ".zip")
            {
                var zipFileDirectory = new ZipFileDirectory(file.Name.Name);
                return ResolveDirectory(zipFileDirectory, children.Skip(1));
            }

            throw new InvalidOperationException("Could not resolve the rest of the path: " + childName);
        }
开发者ID:InfiniteComputingSystems,项目名称:Test,代码行数:31,代码来源:LocalFileSystemLocator.cs

示例2: FromHsb

        /// <summary>
        /// Converts from HSB.
        /// </summary>
        public static Color FromHsb(IEnumerable<byte> source)
        {
            // http://ja.wikipedia.org/wiki/HSV%E8%89%B2%E7%A9%BA%E9%96%93
            var h = Utility.ToUInt16(source.Take(2)) / 182.04;
            var s = Utility.ToUInt16(source.Skip(2).Take(2)) / 655.35;
            var b = Utility.ToUInt16(source.Skip(4).Take(2)) / 655.35;

            // Convert to RGB
            var h_i = (int)(Math.Floor(h / 60) % 6);
            var f = (h / 60) - h_i;
            var p = (int)(b * (1 - s));
            var q = (int)(b * (1 - f * s));
            var t = (int)(b * (1 - (1 - f) * s));
            switch (h_i)
            {
                case 0:
                    return Color.FromArgb((int)b, t, p);
                case 1:
                    return Color.FromArgb(q, (int)b, p);
                case 2:
                    return Color.FromArgb(p, (int)b, t);
                case 3:
                    return Color.FromArgb(p, q, (int)b);
                case 4:
                    return Color.FromArgb(t, p, (int)b);
                case 5:
                    return Color.FromArgb((int)b, p, q);
                default:
                    throw new Exception();
            }
        }
开发者ID:mayth,项目名称:AcoDraw,代码行数:34,代码来源:ColorConverter.cs

示例3: BuildPage

        public static CUFsListViewModel BuildPage(int pagenr, int itemsnr, String order,
            IEnumerable<CufRepoModel> repository, String title, String method, Boolean hasVersion)
        {
            int amountPages = ((repository.Count() + itemsnr - 1) / itemsnr);
            CUFsListModel clm = new CUFsListModel(title);

            repository = (order == "Asc") ? repository.OrderBy(cuf => cuf.Name) : repository.OrderByDescending(cuf => cuf.Name);

            foreach (var cuf in repository.Skip(pagenr * itemsnr).Take(itemsnr))
            {
                if (hasVersion)
                    clm.AddURIParams(cuf.Name + " [ V: " + cuf.Version + " ]", method, cuf.Acr, cuf.Version); //proposal-version
                else
                    clm.AddURIParams(cuf.Name, method, cuf.Acr);

            }

            CUFsListViewModel clvm = new CUFsListViewModel();
            clvm.CUFList = clm.GetCUFsListModel();
            clvm.PageNumber = pagenr;
            clvm.ItemsNumber = itemsnr;
            clvm.Order = order;
            clvm.AmountPage = amountPages;
            clvm.LastPage = false;
            clvm.ItemsPerPage = itemsPerPage;
            clvm.OrderPage = orderOptions;

            clvm.Method = hasVersion ? "PageVersion" : "Page";

            if (clvm.CUFList.Count() < itemsnr ||
                repository.Skip((pagenr + 1) * itemsnr).Take(itemsnr).Count() == 0)
                clvm.LastPage = true;

            return clvm;
        }
开发者ID:isel-31401,项目名称:ISEL-LEIC-PI-31401,代码行数:35,代码来源:Paging.cs

示例4: IsEnabled

        /// <summary>
        /// Gets whether a feature path is valid for the features in the feature set
        /// </summary>
        /// <param name="features">Top-level features</param>
        /// <param name="featurePath">Feature path to the highest-level feature</param>
        /// <returns>Value indicating whether the feature path is valid for a feature in <paramref name="features"/></returns>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="features"/> or <paramref name="featurePath"/> is null</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when <paramref name="featurePath"/> is empty</exception>
        public static bool IsEnabled(IEnumerable<IFeature> features, IEnumerable<string> featurePath)
        {
            Ensure.Argument.NotNull(features, "features");
            Ensure.Argument.NotNull(featurePath, "featurePath");
            Ensure.That<InvalidOperationException>(featurePath.Any(), "Feature Path must contain at least one top-level feature");

            // feature names are case insensitive
            IFeature current = FindFeature(features, featurePath.First());

            // skip the first value
            featurePath = featurePath.Skip(1);

            // loop through the entire path
            while (featurePath.Any())
            {
                // path was not found
                if (current == null)
                    return false;

                // see if the feature has subfeatures (Complex)
                var asComplex = current as IComplexFeature;
                if (asComplex == null) // feature doesn't have subfeatures, it passes
                    return true;

                current = FindFeature(asComplex.SubFeatures, featurePath.First());

                featurePath = featurePath.Skip(1);
            }

            return current != null;
        }
开发者ID:shibbard,项目名称:Multi-tenancy-Sample,代码行数:39,代码来源:Features.cs

示例5: Context

 public Context(IEnumerable<string> line)
 {
     Key = line.Skip(1).Concatenate();
     Namespace = line.Skip(1).PascalCase();
     MemberName = Namespace +"Context";
     Scenarios = new List<Scenario>();
 }
开发者ID:bm2yogi,项目名称:Snipe,代码行数:7,代码来源:SpecParts.cs

示例6: SumsToMoreThan9

        static bool SumsToMoreThan9(IEnumerable<int> p)
        {
            for (int i = 0; i < p.Count() - 2; i++)
                if (p.First() + p.Skip(1).First() + p.Skip(2).First() > 9)
                    return true;

            return false;
        }
开发者ID:Saragis,项目名称:ProjectEuler,代码行数:8,代码来源:Problem164.cs

示例7: Scenario

 public Scenario(IEnumerable<string> line)
 {
     Key = line.Skip(1).Concatenate();
     MemberName = line.Skip(1).ConcatenateWithUnderscores().InitialCap();
     Givens = new List<SpecPart>();
     Whens = new List<SpecPart>();
     Thens = new List<SpecPart>();
 }
开发者ID:bm2yogi,项目名称:Snipe,代码行数:8,代码来源:SpecParts.cs

示例8: FromCmyk

        /// <summary>
        /// Converts from CMYK.
        /// </summary>
        public static Color FromCmyk(IEnumerable<byte> source)
        {
            var c = 1 - (Utility.ToUInt16(source.Take(2)) / 65535.0);
            var m = 1 - (Utility.ToUInt16(source.Skip(2).Take(2)) / 65535.0);
            var y = 1 - (Utility.ToUInt16(source.Skip(4).Take(2)) / 65535.0);
            var k = 1 - (Utility.ToUInt16(source.Skip(6).Take(2)) / 65535.0);

            return FromCmyk(c, m, y, k);
        }
开发者ID:mayth,项目名称:AcoDraw,代码行数:12,代码来源:ColorConverter.cs

示例9: Sort

        public IEnumerable<int> Sort(IEnumerable<int> unsorted)
        {
            if(!unsorted.Any()) return unsorted;

            var pivot = unsorted.First();
            var lesser = unsorted.Skip(1).Where(x => x <= pivot);
            var greater = unsorted.Skip(1).Where(x => x > pivot);

            return Sort(lesser).Union(new[]{pivot}).Union(Sort(greater));
        }
开发者ID:mazur,项目名称:wystts,代码行数:10,代码来源:quicksort.cs

示例10: InitializePagePosts

 internal static IEnumerable<Post> InitializePagePosts(IEnumerable<string> paths, string sha, int page, int pageSize)
 {
     List<Post> posts = new List<Post>();
     //todo: should be refactored (find a more clear and right way)
     //a hack, so that to pass a partially initialized list to PagedList in the controller
     var itemsBefore = paths.Take((page - 1)*pageSize);
     var itemsToInitialize =  paths.Skip((page - 1)*pageSize).Take(pageSize);
     var itemsAfter = paths.Skip((page - 1)*pageSize + pageSize);
     posts.AddRange(itemsBefore.Select(path => new Post( ){Path = path}));
     posts.AddRange(Initialize(itemsToInitialize, sha));
     posts.AddRange(itemsAfter.Select(path=> new Post( ){Path = path}));
     return posts;
 }
开发者ID:alexbeletsky,项目名称:beerncode,代码行数:13,代码来源:PostInitializer.cs

示例11: Execute

        public override ICommandResult Execute(ExecutionInformation info, IEnumerable<ICommand> arguments, IEnumerable<CommandResultType> returnTypes)
        {
            if (!arguments.Any())
                return base.Execute(info, arguments, returnTypes);

            var result = arguments.First().Execute(info, Enumerable.Empty<ICommand>(), new CommandResultType[] { CommandResultType.Command, CommandResultType.String });
            if (result.ResultType == CommandResultType.String)
                // Use cached result so we don't execute the first argument twice
                return base.Execute(info, new ICommand[] { new StringCommand(((StringCommandResult)result).Content) }
                                    .Concat(arguments.Skip(1)), returnTypes);

            return ((CommandCommandResult)result).Command.Execute(info, arguments.Skip(1), returnTypes);
        }
开发者ID:CodeDevLab,项目名称:TS3AudioBot,代码行数:13,代码来源:RootCommand.cs

示例12: Score

        private static int Score(IEnumerable<int> pins, int frame)
        {
            if (0 <= frame && frame < 10) {
                if (pins.Any()) {
                    if (pins.Take(1).Sum() == 10) return pins.Take(3).Sum() + Score(pins.Skip(1), frame + 1);
                    if (pins.Take(2).Sum() == 10) return pins.Take(3).Sum() + Score(pins.Skip(2), frame + 1);
                    if (pins.Take(2).Sum()  < 10) return pins.Take(2).Sum() + Score(pins.Skip(2), frame + 1);

                    throw new Exception("Too many pins");
                }
            }
            return 0;
        }
开发者ID:saktanorovich,项目名称:interview,代码行数:13,代码来源:Game.cs

示例13: CreateFromIndexLine

    public static Recording CreateFromIndexLine(IEnumerable<string> i)
    {
      var alias = i.Count() > 4 ? i.Skip(4).First() : "";
      var oldalias = i.Count() > 5 ? i.Skip(5).First() : "";

      return new Recording()
      {
        Date = Recording.ParseDate(i.Skip(3).First()),
        Title = i.Skip(1).First(),
        Url = i.Skip(2).First().Trim(),
        Alias = alias,
        OldAlias = oldalias,
        Category = i.First()
      };
    }
开发者ID:overeemm,项目名称:dereddingsark.nl,代码行数:15,代码来源:Recording.cs

示例14: ContainsFinishCase

        public bool ContainsFinishCase(IEnumerable<IndexDataSource> route)
        {
            bool result = false;
            foreach (var itemRoute in route.Skip(1))
            {
                foreach (var finishCase in boardManager.firstIndex)
                {
                    if (finishCase.Equals(itemRoute))
                    {
                        result = true;
                        break;
                    }
                }
                if (result)
                {
                    break;
                }
            }

            if (!result)
            {
                var firstIndex = route.First();
                var firstCase = boardManager.FindCaseManager(firstIndex);
                if (firstCase.standDataSource != null)
                {
                    var lastIndex = route.Last();
                    var lastCase = boardManager.FindCaseManager(lastIndex);
                    if (lastCase.standDataSource == null)
                    {
                        result = true;
                    }
                }
            }
            return result;
        }
开发者ID:PotRemus,项目名称:FormulaD,代码行数:35,代码来源:BoardEngine.cs

示例15: ParseDataGroup

 /// <summary>
 /// Takes the fields pulled from one csv line and creates a DataGroup object representation
 /// Parses the string values to doubles where appropriate
 /// </summary>
 /// <param name="fields">The fields pulled from a csv line</param>
 /// <returns>A DataGroup object with the values from fields</returns>
 private DataGroup ParseDataGroup(IEnumerable<string> fields)
 {
     DataGroup group = new DataGroup();
     group.Name = fields.First();
     group.Entries = fields.Skip(1).Select(double.Parse);
     return group;
 }
开发者ID:Mouaijin,项目名称:Anova,代码行数:13,代码来源:CsvParser.cs


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