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


C# System.Collections.Generic.Any方法代码示例

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


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

示例1: should_check_if_sequence_has_more_than_zero_elements

        public void should_check_if_sequence_has_more_than_zero_elements()
        {
            var sequence = new[] { 1, 2, 3, 4, 5 };

            bool sequenceNotEmpty = sequence.Any();
            bool modThreeNotEmpty = sequence.Any(item => item % 3 == 0);

            // please update variable values of the following 2 lines to fix the test.
            const bool expectedSequenceNotEmpty = false;
            const bool expectedModThreeNotEmpty = false;

            Assert.Equal(expectedSequenceNotEmpty, sequenceNotEmpty);
            Assert.Equal(expectedModThreeNotEmpty, modThreeNotEmpty);
        }
开发者ID:chenbojian,项目名称:01_NewbieVillage,代码行数:14,代码来源:24_LinqBasics.cs

示例2: Copy_Razor_files_to_AWS_Bucket

        public void Copy_Razor_files_to_AWS_Bucket()
        {
            var fs = new FileSystemVirtualPathProvider(appHost, "~/../RazorRockstars.WebHost".MapHostAbsolutePath());

            var skipDirs = new[] { "bin", "obj" };
            var matchingFileTypes = new[] { "cshtml", "md", "css", "js", "png", "jpg" };
            var replaceHtmlTokens = new Dictionary<string, string> {
                { "title-bg.png", "title-bg-aws.png" }, //Title Background
                { "https://gist.github.com/3617557.js", "https://gist.github.com/mythz/396dbf54ce6079cc8b2d.js" }, //AppHost.cs
                { "https://gist.github.com/3616766.js", "https://gist.github.com/mythz/ca524426715191b8059d.js" }, //S3 RockstarsService.cs
                { "RazorRockstars.WebHost/RockstarsService.cs", "RazorRockstars.S3/RockstarsService.cs" },         //S3 RockstarsService.cs
                { "http://github.com/ServiceStackApps/RazorRockstars/",
                  "https://github.com/ServiceStackApps/RazorRockstars/tree/master/src/RazorRockstars.S3" }         //Link to GitHub project
            };

            foreach (var file in fs.GetAllFiles())
            {
                if (skipDirs.Any(x => file.VirtualPath.StartsWith(x))) continue;
                if (!matchingFileTypes.Contains(file.Extension)) continue;

                if (file.Extension == "cshtml")
                {
                    var html = file.ReadAllText();
                    replaceHtmlTokens.Each(x => html = html.Replace(x.Key, x.Value));
                    s3.WriteFile(file.VirtualPath, html);
                }
                else
                {
                    s3.WriteFile(file);
                }
            }
        }
开发者ID:ServiceStackApps,项目名称:RazorRockstars,代码行数:32,代码来源:ImportIntoS3Tasks.cs

示例3: GetTestSuiteFiles

 private IEnumerable<string> GetTestSuiteFiles()
 {
     const string dir = @"J:\dev\Projects\Misc\closure-library\closure\goog\";
       string[] allFiles = Directory.GetFiles(dir, "*_test.html", SearchOption.AllDirectories);
       string[] ignore = new [] {"fontsizemonitor_test.html", "icontent_test.html", "abstractdialogplugin_test.html",
     "linkdialogplugin_test.html", "crossdomainrpc_test.html", "positioning_test.html", "serializer_test.html",
     "descriptor_test.html", "message_test.html", "proto_test.html", "viewportclientposition_test.html",
     "spellcheck_test.html", "pubsub_test.html", "collectablestorage_test.html"};
       return allFiles.Where(f => !ignore.Any(i => f.IndexOf(i) >= 0)).ToArray();
 }
开发者ID:plkumar,项目名称:jish,代码行数:10,代码来源:ClosureTests.cs

示例4: HasShipNextDoor

 private static bool HasShipNextDoor(IEnumerable<Point> points, Point point)
 {
     var list = new[]
     {
         new KeyValuePair<char, int>((char)(point.X - 1), point.Y),
         new KeyValuePair<char, int>((char)(point.X + 1), point.Y),
         new KeyValuePair<char, int>((char)point.X, (byte)(point.Y - 1)),
         new KeyValuePair<char, int>((char)point.X, (byte)(point.Y + 1))
     };
     return points.Where(d => d.HasShip).Any(c => list.Any(d => d.Key == c.X && d.Value == c.Y));
 }
开发者ID:tpaananen,项目名称:AkkaBattleShip,代码行数:11,代码来源:ShipValidator.cs

示例5: GetId

        /// <summary>
        /// Ermittelt die ID-Information aus der Informationssammlung
        /// </summary>
        /// <param name="information">Informationssammlung</param>
        /// <returns>ID-Information</returns>
        public static string GetId(this Dictionary<string, IEnumerable<string>> information)
        {
            var id = default(string);

            var idexpressions = new[] { ".id", "id" };
            var ids =
                information != null ?
                information?.FirstOrDefault(entry => idexpressions.Any(expression => entry.Key.ToLower().EndsWith(expression))) :
                default(KeyValuePair<string, IEnumerable<string>>)
            ;
            id = ids?.Value?.FirstOrDefault() ?? string.Empty;

            return id;
        }
开发者ID:LegendOfGIT,项目名称:ButlerFramework,代码行数:19,代码来源:DataWarehouseExtensions.cs

示例6: CreateTreeNodeCore

		TreeNode CreateTreeNodeCore()
		{
			var node = new TreeNode();

			using (var stream = item.OpenStream())
			{
				var rawEMsg = PeekUInt(stream);

				node.Nodes.Add(BuildInfoNode(rawEMsg));

				var header = ReadHeader(rawEMsg, stream);
				node.Nodes.Add(new TreeNodeObjectExplorer("Header", header).TreeNode);

				var body = ReadBody(rawEMsg, stream, header);
				var bodyNode = new TreeNodeObjectExplorer("Body", body).TreeNode;
				node.Nodes.Add(bodyNode);

				var payload = ReadPayload(stream);
				if (payload != null && payload.Length > 0)
				{
					node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload).TreeNode);
				}

				if (Specializations != null)
				{
					var objectsToSpecialize = new[] { body };
					while (objectsToSpecialize.Any())
					{
						var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o)));

						if (!specializations.Any())
						{
							break;
						}

						bodyNode.Collapse(ignoreChildren: true);

						var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value).TreeNode).ToArray();
						node.Nodes.AddRange(extraNodes);

						// Let the specializers examine any new message objects.
						objectsToSpecialize = specializations.Select(x => x.Value).ToArray();
					}
				}
			}

			return node;
		}
开发者ID:Zaharkov,项目名称:SteamKit,代码行数:48,代码来源:NetHookItemTreeBuilder.cs

示例7: TriggerCondition

        protected override bool TriggerCondition()
        {
            var theron = CurrentTile.SubItems.FirstOrDefault(x => x is Theron) as Theron;
            if (theron != null)
            {
                var items = new[] { theron.Hand }
                    .Concat(theron.PartyGroup.SelectMany(x => x.Body.Storages.SelectMany(s => s.Storage)))
                    .Concat(CurrentTile.SubItems.OfType<GrabableItem>());

                return items.Any(Constrain.IsAcceptable);
            }
            else
            {
                return false;
            }
        }
开发者ID:ggrrin,项目名称:DungeonMaster,代码行数:16,代码来源:PartyPossesionActuator.cs

示例8: FindAll

        public IEnumerable<RouteInfo> FindAll(params Assembly[] assemblies)
        {
            var routes = new List<RouteInfo>();

            foreach (var assembly in assemblies)
            {
                var types = assembly.GetTypes();

                var allowedMethodNames = new[] { HttpMethods.Any, HttpMethods.Post, HttpMethods.Get, HttpMethods.Put, HttpMethods.Delete };

                foreach (var type in types)
                {
                    foreach (var serviceMethod in type.GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(m => m.ReturnType != typeof(void)))
                    {
                        if (allowedMethodNames.Any(m => string.Compare(m, serviceMethod.Name, true) == 0))
                        {
                            var parameters = serviceMethod.GetParameters();

                            if (parameters.Length == 1)
                            {
                                var parameterType = parameters[0].ParameterType;

                                var attributes = parameterType.GetCustomAttributes(typeof(RouteAttribute), true) as RouteAttribute[];

                                foreach (var attribute in attributes)
                                {
                                    routes.Add(new RouteInfo(attribute.Route, serviceMethod));
                                }
                            }
                        }
                    }
                }
            }

            return new ReadOnlyCollection<RouteInfo>(routes);
        }
开发者ID:BeauCrawford,项目名称:SimpleStack,代码行数:36,代码来源:RouteLocator.cs

示例9: LoadConfigSettings

		internal void LoadConfigSettings()
		{
			if(Config.Instance.TrackerWindowTop.HasValue)
				Top = Config.Instance.TrackerWindowTop.Value;
			if(Config.Instance.TrackerWindowLeft.HasValue)
				Left = Config.Instance.TrackerWindowLeft.Value;

			if(Config.Instance.WindowHeight < 0)
				Config.Instance.Reset("WindowHeight");
			Height = Config.Instance.WindowHeight;
			if(Config.Instance.WindowWidth < 0)
				Config.Instance.Reset("WindowWidth");
			Width = Config.Instance.WindowWidth;
			var titleBarCorners = new[]
			{
				new Point((int)Left + 5, (int)Top + 5),
				new Point((int)(Left + Width) - 5, (int)Top + 5),
				new Point((int)Left + 5, (int)(Top + TitlebarHeight) - 5),
				new Point((int)(Left + Width) - 5, (int)(Top + TitlebarHeight) - 5)
			};
			if(!Screen.AllScreens.Any(s => titleBarCorners.Any(c => s.WorkingArea.Contains(c))))
			{
				Top = 100;
				Left = 100;
			}

			if(Config.Instance.StartMinimized)
			{
				WindowState = WindowState.Minimized;
				if(Config.Instance.MinimizeToTray)
					MinimizeToTray();
			}

			Options.Load(Core.Game);
			Help.TxtblockVersion.Text = "v" + Helper.GetCurrentVersion().ToVersionString();

			Core.TrayIcon.SetContextMenuProperty("autoSelectDeck", "Checked", Config.Instance.AutoDeckDetection);

			// Don't select the 'archived' class on load
			var selectedClasses = Config.Instance.SelectedDeckPickerClasses.Where(c => c.ToString() != "Archived").ToList();
			if(selectedClasses.Count == 0)
				selectedClasses.Add(HeroClassAll.All);

			DeckPickerList.SelectClasses(selectedClasses);
			DeckPickerList.SelectDeckType(Config.Instance.SelectedDeckType, true);
			DeckPickerList.UpdateAutoSelectToggleButton();

			SortFilterDecksFlyout.LoadTags(DeckList.Instance.AllTags);

			SortFilterDecksFlyout.SetSelectedTags(Config.Instance.SelectedTags);

			TagControlEdit.LoadTags(DeckList.Instance.AllTags.Where(tag => tag != "All" && tag != "None").ToList());
			SortFilterDecksFlyout.OperationSwitch.IsChecked = Config.Instance.TagOperation == TagFilerOperation.And;

			SortFilterDecksFlyout.ComboboxDeckSorting.SelectedItem = Config.Instance.SelectedDeckSorting;
			SortFilterDecksFlyout.CheckBoxSortByClass.IsChecked = Config.Instance.SortDecksByClass;
			SortFilterDecksFlyout.ComboboxDeckSortingArena.SelectedItem = Config.Instance.SelectedDeckSortingArena;
			SortFilterDecksFlyout.CheckBoxSortByClassArena.IsChecked = Config.Instance.SortDecksByClassArena;

			if(!Helper.EventKeys.Contains(Config.Instance.KeyPressOnGameStart))
				Config.Instance.KeyPressOnGameStart = "None";

			if(!Helper.EventKeys.Contains(Config.Instance.KeyPressOnGameEnd))
				Config.Instance.KeyPressOnGameEnd = "None";

			ManaCurveMyDecks.Visibility = Config.Instance.ManaCurveMyDecks ? Visibility.Visible : Visibility.Collapsed;

			Core.TrayIcon.SetContextMenuProperty("classCardsFirst", "Checked", Config.Instance.CardSortingClassFirst);
			Core.TrayIcon.SetContextMenuProperty("useNoDeck", "Checked", DeckList.Instance.ActiveDeck == null);


			DeckStatsFlyout.LoadConfig();
			GameDetailsFlyout.LoadConfig();
			Core.Windows.StatsWindow.StatsControl.LoadConfig();
			Core.Windows.StatsWindow.GameDetailsFlyout.LoadConfig();

			MenuItemCheckBoxSyncOnStart.IsChecked = Config.Instance.HearthStatsSyncOnStart;
			MenuItemCheckBoxAutoUploadDecks.IsChecked = Config.Instance.HearthStatsAutoUploadNewDecks;
			MenuItemCheckBoxAutoUploadGames.IsChecked = Config.Instance.HearthStatsAutoUploadNewGames;
			MenuItemCheckBoxAutoSyncBackground.IsChecked = Config.Instance.HearthStatsAutoSyncInBackground;
			MenuItemCheckBoxAutoDeleteDecks.IsChecked = Config.Instance.HearthStatsAutoDeleteDecks;
			MenuItemCheckBoxAutoDeleteGames.IsChecked = Config.Instance.HearthStatsAutoDeleteMatches;
		}
开发者ID:JDurman,项目名称:Hearthstone-Deck-Tracker,代码行数:83,代码来源:MainWindow.Load.cs

示例10: Qualifies

 public static bool Qualifies(Transaction t)
 {
     var validTypes = new[] { 600, 646, 636, 650, 700 };
     return validTypes.Any(v => v == t.TransactionTypeId);
 }
开发者ID:stevebering,项目名称:LedgerBalance,代码行数:5,代码来源:AdjustmentTransaction.cs

示例11: Generate35

		private static void Generate35(string srcPath, string destFile, params string[] references)
		{
			var database = XDocument.Load(srcPath);
			foreach (var element in database.Root.Descendants(xmlns + "DefineConstants").ToArray())
			{
				if (element.Value.EndsWith(";") == false)
					element.Value += ";";
				element.Value += "NET35";
			}

			foreach (var element in database.Root.Descendants(xmlns + "ProjectReference").ToArray())
			{
				if (references.Contains(element.Element(xmlns + "Name").Value) == false)
					continue;
				element.Attribute("Include").Value = element.Attribute("Include").Value.Replace(".csproj", ".g.3.5.csproj");
				{
					element.Element(xmlns + "Project").Value = "{4C18FC25-0B1E-42E3-A423-3A99F1AC57EE}";
					element.Element(xmlns + "Name").Value += "-3.5";
				}
			}

			foreach (var element in database.Root.Descendants(xmlns + "Reference").ToArray())
			{
				if (element.Attribute("Include").Value == "Microsoft.CSharp")
					element.Remove();
				if (element.Attribute("Include").Value == "AsyncCtpLibrary")
					element.Remove();
				if (element.Attribute("Include").Value == "System.ComponentModel.Composition")
					element.Remove();

				var nugetPakcages = new[] {"Newtonsoft.Json", "NLog"};
				if (nugetPakcages.Any(x => element.Attribute("Include").Value.StartsWith(x)))
				{
					element.Element(xmlns + "HintPath").Value = element.Element(xmlns + "HintPath").Value.Replace("net40", "net35");
				}
			}

			foreach (var element in database.Root.Descendants(xmlns + "DocumentationFile").ToArray())
			{
				element.Value = element.Value.Replace(".XML", "-3.5.XML");
			}
			foreach (var element in database.Root.Descendants(xmlns + "TargetFrameworkVersion"))
			{
				element.Value = "v3.5";
			}
			foreach (var element in database.Root.Descendants(xmlns + "TargetFrameworkProfile"))
			{
				element.Value = "Client";
			}
			foreach (var element in database.Root.Descendants(xmlns + "AssemblyName"))
			{
				element.Value += "-3.5";
			}
			using (var xmlWriter = XmlWriter.Create(destFile,
													new XmlWriterSettings
													{
														Indent = true
													}))
			{
				database.WriteTo(xmlWriter);
				xmlWriter.Flush();
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:63,代码来源:Program.cs

示例12: Qualifies

 public static bool Qualifies(Transaction t)
 {
     var validTypes = new[] { 601, 602, 603 };
     return validTypes.Any(v => v == t.TransactionTypeId);
 }
开发者ID:stevebering,项目名称:LedgerBalance,代码行数:5,代码来源:PaymentTransaction.cs

示例13: BeginAndEndAreEqual

 public bool BeginAndEndAreEqual() {
     if (HasRange) {
         var bytes = new[] { "byte[]", "rowversion" };
         if (bytes.Any(t => t == Version.SimpleType)) {
             var beginBytes = (byte[])Begin;
             var endBytes = (byte[])End;
             return Common.AreEqual(beginBytes, endBytes);
         }
         return Begin.Equals(End);
     }
     return false;
 }
开发者ID:mindis,项目名称:Transformalize,代码行数:12,代码来源:Entity.cs

示例14: WriteInsetLine

        //指定されたファイルのパスを受け取って、指定名のバックアップファイルを作成して挿入
        private static void WriteInsetLine(string defaultFileFullName, Encoding encoding) {
            //挿入するべき最後尾の文字
            var delm = new[]{ ";", "{", "}", ")"};
            var fileInfo = new FileInfo(defaultFileFullName);
            const string appendExtension = OccfNames.LineBackUpSuffix;

            var backUpFileFullName = defaultFileFullName + appendExtension;
            File.Copy(defaultFileFullName, backUpFileFullName, true);

            using (var reader = new StreamReader(backUpFileFullName, encoding)) {
                using (var writer = new StreamWriter(fileInfo.FullName, false, encoding)) {
                    string line;
                    var lineNum = 1;
                    
                    while ((line = reader.ReadLine()) != null) {
                        if (delm.Any(s => line.TrimEnd(' ', '\t').EndsWith(s))) {
                            writer.WriteLine(line);
                            writer.WriteLine("#line " + lineNum);
                        } else {
                            writer.WriteLine(line);
                        }
                        lineNum++;
                    }
                    reader.Close();
                    writer.Close();
                }
            }

            Console.WriteLine("wrote:" + fileInfo.FullName);
        }
开发者ID:audioglider,项目名称:OpenCodeCoverageFramework,代码行数:31,代码来源:LineInserter.cs

示例15: ComposeFilterColor

        private static MiningFilter ComposeFilterColor(string question)
        {
            var filter = default(MiningFilter);

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Data.Mining.colors.json"))
            { 
                using (var reader = new StreamReader(stream))
                {
                    var colorfilters = Enumerable.Empty<MiningFilter>();

                    var jsoncolors = JsonConvert.DeserializeObject(reader.ReadToEnd()) as JObject;
                    var jcolors = jsoncolors.SelectTokens("$.colors[?(@.description != '')]");
                    foreach(var jcolor in jcolors)
                    {
                        var color = jcolor.SelectToken("description").ToString();
                        var subcolorids = jcolor.SelectToken("subcolors") as JArray;
                        var synonyms = new[] { color, $"{color}e" };

                        if(synonyms.Any(
                            synonym => 
                                question.ToLower().StartsWith(synonym) ||
                                Regex.IsMatch(question.ToLower(), $"( |,){synonym}( |,)")
                        ))
                        {
                            colorfilters = colorfilters.Concat(new[] { new MiningFilter {
                                Target = "color",
                                Value = $".*?{color}.*?"
                            } });

                            //  Farbalternativen durch Subfarben
                            if (subcolorids != null && subcolorids.Any())
                            {
                                subcolorids.AsParallel().ForAll(colorid =>
                                {
                                    var jsubcolor = jsoncolors.SelectToken($"$.colors[?(@.id == {colorid})]");
                                    var subcolor = jsubcolor?.SelectToken("description").ToString();

                                    colorfilters = colorfilters.Concat(new[] { new MiningFilter {
                                        Target = "color",
                                        Value = $".*?{subcolor}.*?"
                                    } });
                                });
                            }
                        }
                    }

                    if(colorfilters.Any())
                    {
                        filter = new MiningFilter
                        {
                            Or = colorfilters
                        };
                    }
                }
            }

            return filter;
        }
开发者ID:LegendOfGIT,项目名称:data.mining,代码行数:58,代码来源:MiningCompiler.cs


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