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


C# List.All方法代码示例

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


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

示例1: Assemble

        public AssemblerResult Assemble(AssemblerOptions options)
        {
            if (options == null)
                throw new ArgumentNullException("options");

            List<AssemblerMessage> messages = new List<AssemblerMessage>();

            try
            {
                //Get the lines
                var sourceLines = GetSourceLines(options);

                //Do the first pass
                var pass1Result = Pass1(messages, sourceLines);

                if (messages.All(m => m.ErrorLevel != ErrorLevel.Error))
                {
                    Pass2(messages, pass1Result, options.OutputFile);
                }
            }
            catch (Exception ex)
            {
                messages.Add(new AssemblerMessage(ErrorLevel.Error, ex.Message));
            }

            //We're done here
            return new AssemblerResult()
            {
                Messages = messages.ToArray(),
                Succeeded = messages.All(m => m.ErrorLevel != ErrorLevel.Error)
            };
        }
开发者ID:rquackenbush,项目名称:EVM,代码行数:32,代码来源:Assembler.cs

示例2: FindCommonPath

        public static string FindCommonPath(string separator, List<string> paths)
        {
            string CommonPath = string.Empty;
            List<string> SeparatedPath = paths
                .First(str => str.Length == paths.Max(st2 => st2.Length))
                .Split(new string[] { separator }, StringSplitOptions.RemoveEmptyEntries)
                .ToList();

            foreach (string PathSegment in SeparatedPath.AsEnumerable())
            {
                if (CommonPath.Length == 0 && paths.All(str => str.StartsWith(PathSegment)))
                {
                    CommonPath = PathSegment;
                }
                else if (paths.All(str => str.StartsWith(CommonPath + separator + PathSegment)))
                {
                    CommonPath += separator + PathSegment;
                }
                else
                {
                    break;
                }
            }

            return CommonPath;
        }
开发者ID:LordNed,项目名称:WArchive-Tools,代码行数:26,代码来源:Program.cs

示例3: IsRoyalFlush

 static bool IsRoyalFlush(List<Card> hand)
 {
     var start = 10;
     var suit = hand[0].Suit;
     return hand.All(c => c.Suit == suit) &&
         hand.All(c => c.Value == start++);
 }
开发者ID:jtg2078,项目名称:ProjectEuler,代码行数:7,代码来源:Program.cs

示例4: FindRootPath

        static string FindRootPath(List<string> paths)
        {
            var separator = Path.DirectorySeparatorChar;
            var commonPath = String.Empty;
            var separatedPath = paths
                .First(str => str.Length == paths.Max(st2 => st2.Length))
                .Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
                .ToList();

            foreach (var pathSegment in separatedPath)
            {
                if (commonPath.Length == 0 && paths.All(str => str.StartsWith(pathSegment)))
                {
                    commonPath = pathSegment;
                }
                else if (paths.All(str => str.StartsWith(commonPath + separator + pathSegment)))
                {
                    commonPath += separator + pathSegment;
                }
                else
                {
                    break;
                }
            }

            return commonPath;
        }
开发者ID:connectivedx,项目名称:SquishIt,代码行数:27,代码来源:RelativePathAdapter.cs

示例5: DetermineMissingServices

		public static List<IRequiredService> DetermineMissingServices(this IEnumerable<XmlModuleConfig> modules, List<string> bootStrappedServices)
		{
			var providedServices = new List<IProvidedService>();
			var requiredServices = new Dictionary<IRequiredService, XmlModuleConfig>();

			foreach (var module in modules)
			{
				foreach (IRequiredService requiredService in module.RequiredServices)
				{
					if (requiredServices.All(r => r.Key.ServiceName != requiredService.ServiceName))
					{
						requiredServices.Add(requiredService, module);
					}
				}

				foreach (IProvidedService providedService in module.ProvidedServices)
				{
					if (providedServices.All(r => r.ServiceName != providedService.ServiceName))
					{
						providedServices.Add(providedService);
					}
				}
			}

			var query =
				requiredServices.Where(
					requiredService =>
					providedServices.All(s => s.ServiceName != requiredService.Key.ServiceName)
					&& bootStrappedServices.All(s => s != requiredService.Key.ServiceName));

			return query.Select(s => s.Key).ToList();
		}
开发者ID:mmahulea,项目名称:FactonExtensionPackage,代码行数:32,代码来源:ModuleConfigEnumerableExtensions.cs

示例6: For

 private void For(int length, List<int[,]> maps, List<int> dileiPosition, List<int> notDileiPosition)
 {
     for (int i = 0; i < length; i++)
     {
         if (maps.All(map => map[0, i] > Safe)) dileiPosition.Add(i + 1);
         else if (maps.All(map => map[0, i] == Safe)) notDileiPosition.Add(i + 1);
     }
 }
开发者ID:g4idrijs,项目名称:Algorithms,代码行数:8,代码来源:SaoLeiLevel1.cs

示例7: Launch

        public bool Launch()
        {
            var workers = new List<ChiefWorkerProcess>();
            try
            {
                _log.Debug("Loading settings...");
                var configuration = ConfigurationHelper.Load(_options.Configuration);
                _log.Debug("Starting machinery...");
                try
                {
                    foreach (var workerSettings in configuration)
                    {
                        var workerProcess = new ChiefWorkerProcess(_log, workerSettings);
                        workers.Add(workerProcess);
                        workerProcess.LaunchAsync();
                    }

                    while (workers.All(worker => worker.IsAlive && !worker.ReadyToAcceptClients))
                    {
                        Thread.Sleep(1000);
                    }

                    _log.Debug("Server(s) started...");
                    ReadyToAcceptClients();

                    while (!IsExitOnDemand() && workers.All(worker => worker.IsAlive))
                    {
                        Thread.Sleep(3000);
                    }

                    if (!workers.All(worker => worker.IsAlive))
                    {
                        var error = string.Format("The following sources does not work: {0}",
                            string.Join(
                                ", ",
                                workers
                                    .Where(worker => !worker.IsAlive)
                                    .Select(worker => worker.Name)
                                    .ToArray()));
                        _log.Error(error);
                        ErrorOccured(error);
                        return false;
                    }
                }
                finally
                {
                    workers.ForEach(item => item.Dispose());
                }
                return true;
            }
            catch (Exception unhandledException)
            {
                _log.Error(unhandledException);
                return false;
            }
        }
开发者ID:WildGenie,项目名称:ipcamemu,代码行数:56,代码来源:Chief.cs

示例8: PlaceShips

        public List<Ship> PlaceShips(List<int> sizes, int boardHeight, int boardWidth)
        {
            Height = boardHeight;
            Width = boardWidth;

            //var ship = new Ship
            //{
            //    Direction = Direction.Vertical,
            //    Length = 3,
            //    Location = new Point(0, 0)
            //};

            //var newShip = new Ship
            //{
            //    Direction = Direction.Vertical,
            //    Length = 3,
            //    Location = new Point(0, 3)
            //};

            //Console.WriteLine(ship.Neighbour(newShip));

            var ships = new List<Ship>();

            for (int i = 0; i < sizes.Count; i++)
            {
                var size = sizes[i];

                // Create new ship
                var newShip = new Ship
                {
                    Direction = Helpers.Random.Next(0, 1 + 1) == 0 ? Direction.Horizontal : Direction.Vertical,
                    Length = size,
                    Location = Helpers.RandomPoint(boardHeight, boardWidth)
                };

                // Check that it doesn't overlap with any other
                bool ok = ships.All(ship => !ship.Overlaps(newShip));
                ok = ok && ships.All(ship => !ship.Neighbour(newShip));

                // Do not advance to next ship,
                // repeat the same one next iteration
                if (!ok ||
                    newShip.EndPoint.X > boardWidth ||
                    newShip.EndPoint.Y >= boardHeight)
                    i--;
                else
                    ships.Add(newShip);
            }

            return ships;
        }
开发者ID:jakakonda,项目名称:BattleShips,代码行数:51,代码来源:BattleShipPlayerBase.cs

示例9: AutofacWillDisposeAllItemsInLifetime

        public void AutofacWillDisposeAllItemsInLifetime()
        {
            List<DisposableObject> list = new List<DisposableObject>();
            using(var scope = TestSetup.Container.BeginLifetimeScope())
            {
                for (int i = 0; i < 100; i++)
                {
                    list.Add(scope.Resolve<DisposableObject>());
                }
                Assert.True(list.All(item => !item.IsDisposed));
            }

            Assert.True(list.All(item => item.IsDisposed));
        }
开发者ID:ScottWeinstein,项目名称:IoC-Demos,代码行数:14,代码来源:AutofacLifetimeFacts.cs

示例10: LoadParentMaps

        public void LoadParentMaps(List<INode> maps, Guid mapId)
        {
            var viewModelMaps = new List<SuperGraph.ViewModel.Node>();

            foreach (var map in maps)
            {
                if (viewModelMaps.All(q => q.Proxy.Id != map.Id))
                {
                    var viewModelNode = new SuperGraph.ViewModel.Node(MapManager);
                    viewModelNode.LoadNode(null, map);

                    viewModelMaps.Add(viewModelNode);
                }
            }

            if (viewModelMaps.Count > 1)
            {
                var breadcrumb = new MultiBreadcrumbItem(viewModelMaps);
                if (mapId != Guid.Empty)
                {
                    var currentMap = breadcrumb.Items.FirstOrDefault(q => q.Node.Proxy.Id == mapId);
                    if (currentMap != null)
                    {
                        breadcrumb.SelectedBreadcrumb = currentMap;
                    }
                }
                Breadcrumbs.BreadcrumbTrail.Insert(breadcrumb, _parentIndex);
            }
            else if (viewModelMaps.Count == 1)
            {
                var breadcrumb = new BreadcrumbItem(viewModelMaps[0]);
                Breadcrumbs.BreadcrumbTrail.Insert(breadcrumb, _parentIndex);
            }
        }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:34,代码来源:BreadcrumbLoader.cs

示例11: Main

    static void Main()
    {
        string input = Console.ReadLine();
        int[] nums = input.Split(' ').Select(int.Parse).ToArray();

        var values = new List<int>();
        var diffs = new List<int>();
        for (int i = 0; i < nums.Length; i += 2)
        {
            values.Add(nums[i] + nums[i + 1]);
        }

        for (int i = 1; i < values.Count; i++)
        {
            diffs.Add(Math.Abs(values[i] - values[i - 1]));
        }

        if (values.All(o => o == values[0]))
        {
            Console.WriteLine("Yes, value={0}", values[0]);
        }
        else
        {
            Console.WriteLine("No, maxdiff={0}", diffs.Max());
        }
    }
开发者ID:VictorGeorgiev,项目名称:Telerik-Software-Academy,代码行数:26,代码来源:Pairs.cs

示例12: BruteForce

        static int BruteForce()
        {
            var chrs = cipher.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            for (int i = 97; i <= 122; i++)
            {
                for (int j = 97; j <= 122; j++)
                {
                    for (int k = 97; k <= 122; k++)
                    {
                        var list = new List<int>();
                        for (int l = 0; l < chrs.Count; l = l + 3)
                        {
                            var item = i ^ chrs[l];
                            list.Add(item);   
                          if(l < chrs.Count -1)
                              list.Add(j ^ chrs[l + 1]);
                          if (l < chrs.Count - 1)
                            list.Add(k ^ chrs[l + 2]);   
                        }

                        if (list.All(IsChar))
                        {
                            Console.Out.WriteLine(string.Format("Get {0}{1}{2}", Convert.ToChar(i), Convert.ToChar(j), Convert.ToChar(k)));
                            return list.Sum();
                        }
                    }
                }
                
            }

            return 0;

        }
开发者ID:david--liu,项目名称:code_kata,代码行数:33,代码来源:Problem59.cs

示例13: GetPnRegsByItem

        /// <summary>
        /// 获取某个项下所带的附件集合(去重)
        /// </summary>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public List<PnRegDTO> GetPnRegsByItem(int itemId)
        {
            var result = new List<PnRegDTO>();
            var installControllers = _unitOfWork.CreateSet<InstallController>().Where(p => p.ItemId == itemId).ToList();
            var pnRegs = _unitOfWork.CreateSet<PnReg>().ToList();
            installControllers.ForEach(p =>
            {
                if (result.All(l => l.Id != p.PnRegId))
                {
                    var pnReg = pnRegs.FirstOrDefault(l => l.Id == p.PnRegId);
                    if (pnReg != null)
                    {
                        var dbItem = _unitOfWork.CreateSet<Item>().ToList().FirstOrDefault(l => l.Id == pnReg.ItemId);

                        var pn = new PnRegDTO
                        {
                            Id = pnReg.Id,
                            Description = pnReg.Description,
                            IsLife = pnReg.IsLife,
                            Pn = pnReg.Pn,
                            ItemId = pnReg.ItemId,
                        };
                        if (dbItem != null) pn.ItemNo = dbItem.ItemNo;
                        result.Add(pn);
                    }
                }
            });
            return result;
        }
开发者ID:unicloud,项目名称:FRP,代码行数:34,代码来源:PnRegQuery.cs

示例14: GetAllMatches

        /// <summary>
        /// Returns collection of Matches for every possible match with the cards in this deck
        /// and the card argument.
        /// Note that a single card may be a part of multiple potential matches,
        /// in which case it will appear in multiple Matches in the returned List.
        /// </summary>
        /// <param name="card">Card to be compared to other cards in this deck for matches.</param>
        public List<Match> GetAllMatches(Card card)
        {
            var matches = new List<Match>();

            for (var i = 0; i < Cards.Count; i++)
            {
                for (var j = i + 1; j < Cards.Count; j++)
                {
                    var firstCard = Cards[i];
                    var secondCard = Cards[j];

                    if (firstCard == secondCard || firstCard == card || secondCard == card)
                        continue;

                    if (!Card.IsMatch(firstCard, secondCard, card))
                        continue;

                    var match = new Match();
                    match.Cards[0] = firstCard;
                    match.Cards[1] = secondCard;
                    match.Cards[2] = card;

                    if (matches.All(x => x.Cards != match.Cards))
                        matches.Add(match);
                }
            }

            return matches;
        }
开发者ID:GennrichJ,项目名称:Set,代码行数:36,代码来源:Deck.cs

示例15: SqlServerEndpoint

        public SqlServerEndpoint(string name, string connectionString, bool includeSystemDatabases, IEnumerable<Database> includedDatabases, IEnumerable<string> excludedDatabaseNames)
            : base(name, connectionString)
        {
            var excludedDbs = new List<string>();
            var includedDbs = new List<Database>();

            if (excludedDatabaseNames != null)
            {
                excludedDbs.AddRange(excludedDatabaseNames);
            }

            if (includedDatabases != null)
            {
                includedDbs.AddRange(includedDatabases);
            }

            if (includeSystemDatabases && includedDbs.Any())
            {
                IEnumerable<Database> systemDbsToAdd = Constants.SystemDatabases
                                                                .Where(dbName => includedDbs.All(db => db.Name != dbName))
                                                                .Select(dbName => new Database {Name = dbName});
                includedDbs.AddRange(systemDbsToAdd);
            }
            else if (!includeSystemDatabases)
            {
                IEnumerable<string> systemDbsToAdd = Constants.SystemDatabases
                                                              .Where(dbName => excludedDbs.All(db => db != dbName));
                excludedDbs.AddRange(systemDbsToAdd);
            }

            IncludedDatabases = includedDbs.ToArray();
            ExcludedDatabaseNames = excludedDbs.ToArray();
        }
开发者ID:AlphaGit,项目名称:newrelic_microsoft_sqlserver_plugin,代码行数:33,代码来源:SqlServerEndpoint.cs


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