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


C# System.Linq.Contains方法代码示例

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


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

示例1: WhereHasArtistParticipationStatus

		public static IQueryable<ArtistForAlbum> WhereHasArtistParticipationStatus(this IQueryable<ArtistForAlbum> query, Artist artist, ArtistAlbumParticipationStatus participation) {

			if (participation == ArtistAlbumParticipationStatus.Everything || artist == null)
				return query;

			var musicProducerTypes = new[] {ArtistType.Producer, ArtistType.Circle, ArtistType.OtherGroup};

			if (musicProducerTypes.Contains(artist.ArtistType)) {

				var producerRoles = ArtistRoles.Composer | ArtistRoles.Arranger;

				switch (participation) {
					case ArtistAlbumParticipationStatus.OnlyMainAlbums:
						return query.Where(a => !a.IsSupport && ((a.Roles == ArtistRoles.Default) || ((a.Roles & producerRoles) != ArtistRoles.Default)) && a.Album.ArtistString.Default != ArtistHelper.VariousArtists);
					case ArtistAlbumParticipationStatus.OnlyCollaborations:
						return query.Where(a => a.IsSupport || ((a.Roles != ArtistRoles.Default) && ((a.Roles & producerRoles) == ArtistRoles.Default)) || a.Album.ArtistString.Default == ArtistHelper.VariousArtists);
					default:
						return query;
				}

			} else {

				switch (participation) {
					case ArtistAlbumParticipationStatus.OnlyMainAlbums:
						return query.Where(a => !a.IsSupport);
					case ArtistAlbumParticipationStatus.OnlyCollaborations:
						return query.Where(a => a.IsSupport);
					default:
						return query;
				}
				
			}

		}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:34,代码来源:ArtistForAlbumQueryableExtender.cs

示例2: OperandTypes

        public void OperandTypes()
        {
            var OneByteOperandTypes = new byte[0xff];
            var TwoByteOperandTypes = new byte[0x1f];

            var typeOfOpCode = typeof(OpCode);
            var reserved = new[] { "Prefix1", "Prefix2", "Prefix3", "Prefix4", "Prefix5", "Prefix6", "Prefix7", "Prefixref" };

            foreach (FieldInfo fi in typeof(OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static).Where(f => !reserved.Contains(f.Name)))
            {
                if (fi.FieldType != typeOfOpCode)
                {
                    continue;
                }

                OpCode opCode = (OpCode)fi.GetValue(null);
                var value = unchecked((ushort)opCode.Value);
                if (value < 0x100)
                {
                    OneByteOperandTypes[value] = (byte)opCode.OperandType;
                }
                else if ((value & 0xff00) == 0xfe00)
                {
                    TwoByteOperandTypes[value & 0xff] = (byte)opCode.OperandType;
                }
            }

            AssertEx.Equal(OneByteOperandTypes, InstructionOperandTypes.OneByte);
            AssertEx.Equal(TwoByteOperandTypes, InstructionOperandTypes.TwoByte);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:InstructionOperandTypesTests.cs

示例3: EatOptionValue

 private void EatOptionValue(ISnapshot snapshot, ExpressionKind kind, ICSharpExpression optionValue)
 {
     var addableKinds = new[] { ExpressionKind.Target, ExpressionKind.Stub, ExpressionKind.Mock };
     if (addableKinds.Contains(kind))
     {
         snapshot.Add(kind, optionValue);
     }
 }
开发者ID:KozhevnikovDmitry,项目名称:MockMetrics,代码行数:8,代码来源:MoqStubOptionsEater.cs

示例4: Init_Should_Apply_Entity_Channels_To_Aspect

 public void Init_Should_Apply_Entity_Channels_To_Aspect()
 {
     var expected = new[] {"one", "two", "three"};
     var e = new DefaultEntity("Test", expected).CreateLabelAspect("Label", 0, 0);
     var aspect = new LabelAspect();
     aspect.Init(e);
     Assert.True(aspect.Channels.All(s => expected.Contains(s)));
 }
开发者ID:PhoenixSystem,项目名称:PhoenixSystem,代码行数:8,代码来源:AspectTests.cs

示例5: GetNextAttributeToken

 private static string GetNextAttributeToken(string attributeCollection, char closingBracketChar, ref int index)
 {
     var terminatingChars = new[] { ',', ' ', '\t', closingBracketChar };
     string nameValuePair = HtmlStringHelper.ExtractTokenFromTagString(attributeCollection, ref index,
         terminatingChars);
     if (terminatingChars.Contains(nameValuePair[nameValuePair.Length - 1]))
         nameValuePair = nameValuePair.Substring(0, nameValuePair.Length - 1);
     return nameValuePair;
 }
开发者ID:RussPAll,项目名称:NHaml,代码行数:9,代码来源:HamlNodeHtmlAttributeCollection.cs

示例6: CanSelectManyWithAssociationInWhereClause

        public void CanSelectManyWithAssociationInWhereClause()
        {
            int[] typeCodes = new[] { 5, 15, 100 };

            var query = session.Linq<Patient>().SelectMany(p => p.PatientRecords, (p, r) => r)
                .Where(r => r.Gender == Gender.Male && typeCodes.Contains(r.Type.TypeCode)).ToArray();

            Assert.AreEqual(2, query.Length);
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:9,代码来源:SelectManyTests.cs

示例7: ValidEmailValidationTest

        public void ValidEmailValidationTest()
        {
            var errorFieldNames = new[] { "EmailWithoutTld", "EmptyString", "SimpleText", "EmailWithPlusChar" }.ToList();
            var errors = ModelValidator.ValidateObject(new ExampleModel1()).Errors;
            Assert.That(errors.Count, Is.EqualTo(errorFieldNames.Count));

            Assert.That(errors.ToList().All(x => x.ErrorCode == ErrorCodes.EmailAddressIsNotValid.ToString()));
            Assert.That(errors.ToList().All(x => errorFieldNames.Contains(x.FieldName)));
        }
开发者ID:EvgeniyProtas,项目名称:servicestack,代码行数:9,代码来源:ValidEmailValidationTests.cs

示例8: NullAndEmptyStringFailsRequiredTextValidationTest

		public void NullAndEmptyStringFailsRequiredTextValidationTest()
		{
			var errorFieldNames = new[] { "EmptyString", "NullString" }.ToList();
			var errors = ModelValidator.ValidateObject(new ExampleModel1()).Errors;
			Assert.That(errors.Count, Is.EqualTo(errorFieldNames.Count));

			Assert.That(errors.ToList().All(x => x.ErrorCode == ValidationErrorCodes.Required.ToString()));
			Assert.That(errors.ToList().All(x => errorFieldNames.Contains(x.FieldName)));
		}
开发者ID:nuxleus,项目名称:ServiceStack.Extras,代码行数:9,代码来源:RequiredTextValidationTests.cs

示例9: WhenEnumerableHasItems_ReturnsItemInEnumerable

        public void WhenEnumerableHasItems_ReturnsItemInEnumerable()
        {
            //Arrange
            var list = new [] {"Michael", "Bob", "Joe"};

            //Act
            var result = list.Random();

            //Assert
            Assert.IsTrue(list.Contains(result));
        }
开发者ID:run00,项目名称:Utilities,代码行数:11,代码来源:Random.cs

示例10: ContainsTest

        public void ContainsTest()
        {
            //ARRANGE
            var list1 = new[] { "a", "aa", "aaa", "aaaa" };

            //ACT
            var contains = list1.Contains("bbb", x => x.Length);

            //ASSERT
            Assert.IsTrue(contains);
        }
开发者ID:vilinski,项目名称:LambdaComparer,代码行数:11,代码来源:EnumerableExTest.cs

示例11: Can_select_ints_using_list_contains

        public void Can_select_ints_using_list_contains()
        {
            var ints = new[] { 1, 2, 3 }.ToList();

            using (var db = OpenDbConnection())
            {
                db.Select<TestType>(x => ints.Contains(x.Id));

                Assert.That(db.GetLastSql(), Is.StringContaining("(1,2,3)"));
            }
        }
开发者ID:JackFong,项目名称:ServiceStack.OrmLite,代码行数:11,代码来源:MethodExpressionTests.cs

示例12: Can_select_ints_using_array_contains

        public void Can_select_ints_using_array_contains()
        {
            var ints = new[] { 1, 2, 3 };

            using (var db = OpenDbConnection())
            {
                db.Select<TestType>(x => ints.Contains(x.Id));

                Assert.That(db.GetLastSql(), Is.StringContaining("(@0,@1,@2)").
                                             Or.StringContaining("(:0,:1,:2)"));
            }
        }
开发者ID:brian6peng,项目名称:ServiceStack.OrmLite,代码行数:12,代码来源:MethodExpressionTests.cs

示例13: IsCommitCharacter

        internal static bool IsCommitCharacter(CompletionItem completionItem, char ch, string textTypedSoFar)
        {
            // TODO(cyrusn): Don't hardcode this in.  Suck this out of the user options.
            var commitCharacters = new[]
            {
                ' ', '{', '}', '[', ']', '(', ')', '.', ',', ':',
                ';', '+', '-', '*', '/', '%', '&', '|', '^', '!',
                '~', '=', '<', '>', '?', '@', '#', '\'', '\"', '\\'
            };

            return commitCharacters.Contains(ch);
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:12,代码来源:CompletionUtilities.cs

示例14: Execute

        public void Execute()
        {
            var refreshOn = new[]
            {
                BuildConfigurations.Debug.Description(),
                BuildConfigurations.TestsUnit.Description()
            };
            if (!refreshOn.Contains(appSettings.Configuration))
                return;

            persistenceConfiguration.RecreateDatabase();
        }
开发者ID:caiokf,项目名称:smart-track,代码行数:12,代码来源:RefreshDatabase.cs

示例15: GetUrls_should_return_urls_from_provider_that_is_passed_in

        public void GetUrls_should_return_urls_from_provider_that_is_passed_in()
        {
            var expected = new[] {new GoogleUrl(), new GoogleUrl()};

            var providerFake = new Mock<IGoogleUrlProvider>();
            providerFake.Setup(x => x.GetUrls())
                .Returns(expected);

            var provider = new GoogleSiteMapProvider(new[] {providerFake.Object});
            var results = provider.GetUrls();

            results.Count().ShouldEqual(2);
            results.ToList().ForEach(url => expected.Contains(url).ShouldBeTrue());
        }
开发者ID:darrencauthon,项目名称:MvcTurbine.GoogleSiteMap,代码行数:14,代码来源:GoogleSiteMapProviderTests.cs


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