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


C# IEnumerable.Contains方法代码示例

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


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

示例1: Generate

        public Dictionary<string, string> Generate(List<NameNode> idNameNodes, IEnumerable<string> excludedNames)
        {
            Generator.Reset();

            int varCount = idNameNodes.Count;
            string[] newNames = new string[varCount];
            var newSubstitution = new Dictionary<string, string>();

            for (int i = 0; i < varCount; i++)
            {
                string newName;
                do
                {
                    newName = Generator.Next();
                }
                while (excludedNames.Contains(newName) || NamesGenerator.CSharpKeywords.Contains(newName));
                newNames[i] = newName;
            }

            int ind = 0;
            foreach (NameNode v in idNameNodes)
                if (!newSubstitution.ContainsKey(v.Name))
                    newSubstitution.Add(v.Name, newNames[ind++]);

            return newSubstitution;
        }
开发者ID:KvanTTT,项目名称:CSharp-Minifier,代码行数:26,代码来源:Substitutor.cs

示例2: GetServiceProvidersPage

        public IPagedList<User> GetServiceProvidersPage(int page, int itemsPerPage, IEnumerable<int> locations, IEnumerable<Guid> tags, string searchString)
        {
            IQueryable<User> users = _serviceHubEntities.Users
                    .Include("Tags")
                    .Include("Ratings")
                    .Include("Locations")
                    .Where(o => o.IsPublic);

            if (locations.Count() > 0)
                locations = _serviceHubEntities.GetLocationsHierarchy(string.Join(",", locations)).Select(o => o.Id);

            if (locations.Count() > 0 && tags.Count() > 0)
                users = users.Where(o => o.Locations.Any(i => locations.Contains(i.Id)) || o.Tags.Any(i => tags.Contains(i.Id)));
            else if (locations.Count() > 0)
                users = users.Where(o => o.Locations.Any(i => locations.Contains(i.Id)));
            else if (tags.Count() > 0)
                users = users.Where(o => o.Tags.Any(i => tags.Contains(i.Id)));

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                string searchStringUpperCase = searchString.ToUpper();
                users = users.Where(o => o.Name.ToUpper().Contains(searchStringUpperCase));
            }

            return users
                .OrderByDescending(o => o.Ratings.Average(i => i.Score))
                .ToPagedList(page, itemsPerPage);
        }
开发者ID:pirovorster,项目名称:ServiceHub,代码行数:28,代码来源:DirectoryService.cs

示例3: AssertGetSensorsResult

		private static void AssertGetSensorsResult(IEnumerable<string> sensors)
		{
			Assert.IsNotNull(sensors);
			Assert.AreEqual(2, sensors.Count());
			Assert.IsTrue(sensors.Contains("Temperature Sensor"));
			Assert.IsTrue(sensors.Contains("Velocity Sensor"));
		}
开发者ID:mkandroid15,项目名称:Samples,代码行数:7,代码来源:SensorTests.cs

示例4: CompareUserProfiles

        /// <summary>
        /// Compares 2 userprofile.
        /// </summary>
        /// <param name="userProfile"></param>
        /// <param name="compUserProfile"></param>
        /// <param name="objectsToCompare"> optional (if not given, all objects will be taken into account)</param>
        /// <param name="networks"> optional (if not given, all networks will be added to the resulting usercomparison)</param>
        /// <returns></returns>
        internal static UserComparison CompareUserProfiles(ProfileData userProfile, ProfileData compUserProfile, IEnumerable<ProfileDataObjects> objectsToCompare = null, IEnumerable<Network> networks = null)
        {
            UserComparison userComparison = new UserComparison();
            if (userProfile == null)
                userProfile = new ProfileData();
            if (compUserProfile == null)
                compUserProfile = new ProfileData();
            if(objectsToCompare == null)
                objectsToCompare = ProfileData.GetAllProfileDataObjects();
            if (networks == null)
                networks = Network.GetAllNetworks();

            userComparison.Networks = networks.ToList();

            if (objectsToCompare.Contains(ProfileDataObjects.EDUCATION))
                CompareEducation(ref userComparison, userProfile, compUserProfile);
            if(objectsToCompare.Contains(ProfileDataObjects.WORK))
                CompareWork(ref userComparison, userProfile, compUserProfile);
            if (objectsToCompare.Contains(ProfileDataObjects.TEAM))
                CompareInterests(ref userComparison, userProfile, compUserProfile, InterestType.TEAM);
            if (objectsToCompare.Contains(ProfileDataObjects.ATHLETE))
                CompareInterests(ref userComparison, userProfile, compUserProfile, InterestType.ATHLETE);

            return userComparison;
        }
开发者ID:kingdom442,项目名称:ConnectUs,代码行数:33,代码来源:ProfileComparisonUtil.cs

示例5: EdmDeltaModel

        public EdmDeltaModel(IEdmModel source, IEdmEntityType entityType, IEnumerable<string> propertyNames)
        {
            _source = source;
            _entityType = new EdmEntityType(entityType.Namespace, entityType.Name);

            foreach (var property in entityType.StructuralProperties())
            {
                if (propertyNames.Contains(property.Name))
                    _entityType.AddStructuralProperty(property.Name, property.Type, property.DefaultValueString, property.ConcurrencyMode);
            }

            foreach (var property in entityType.NavigationProperties())
            {
                if (propertyNames.Contains(property.Name))
                {
                    var navInfo = new EdmNavigationPropertyInfo()
                    {
                        ContainsTarget = property.ContainsTarget,
                        DependentProperties = property.DependentProperties(),
                        PrincipalProperties = property.PrincipalProperties(),
                        Name = property.Name,
                        OnDelete = property.OnDelete,
                        Target = property.Partner != null 
                            ? property.Partner.DeclaringEntityType()
                            : property.Type.TypeKind() == EdmTypeKind.Collection
                            ? (property.Type.Definition as IEdmCollectionType).ElementType.Definition as IEdmEntityType
                            : property.Type.TypeKind() == EdmTypeKind.Entity
                            ? property.Type.Definition as IEdmEntityType
                            : null,
                        TargetMultiplicity = property.TargetMultiplicity(),
                    };
                    _entityType.AddUnidirectionalNavigation(navInfo);
                }
            }
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:35,代码来源:EdmDeltaModel.cs

示例6: ResolveTargets

        public static GameObject[] ResolveTargets(GameObject source, IEnumerable<string> TargetIds, GameObjectCollection parent, GameConsole console, bool DeepProcess)
        {
            // If it passed, find all targets and activate them
            List<GameObject> foundTargets = new List<GameObject>(5);

            foreach (var item in parent)
            {
                if (item.Value != source && TargetIds.Contains(item.Value.GetSetting("id")))
                    foundTargets.Add(item.Value);
            }

            // Process all known collections
            if (DeepProcess)
            {
                for (int i = 0; i < console.LayeredTextSurface.LayerCount; i++)
                {
                    var objects = console.GetObjectCollection(i);
                    if (objects != parent)
                    {
                        foreach (var item in objects)
                        {
                            if (item.Value != source && TargetIds.Contains(item.Value.GetSetting("id")))
                                foundTargets.Add(item.Value);
                        }
                    }
                }
            }

            return foundTargets.ToArray();
        }
开发者ID:Thraka,项目名称:SadConsole,代码行数:30,代码来源:GameObjectParser.cs

示例7: VisibleTo

        internal static IQueryable<Agreement> VisibleTo(this IQueryable<Agreement> agreements, IPrincipal principal, IEnumerable<int> ownedTenantIds)
        {
            if (agreements == null) return null;
            if (principal == null) throw new ArgumentNullException("principal");
            if (ownedTenantIds == null) throw new ArgumentNullException("ownedTenantIds");

            // when user is not an agreement admin, filter out private agreements
            // and protected agreements that the user does not own
            if (!principal.IsInAnyRole(RoleName.AgreementManagers))
            {
                return agreements.Where(x => Public.Equals(x.VisibilityText, StringComparison.OrdinalIgnoreCase)
                    || (
                        Protected.Equals(x.VisibilityText, StringComparison.OrdinalIgnoreCase)
                        &&
                        x.Participants.Any(y => y.IsOwner && ownedTenantIds.Contains(y.EstablishmentId))
                    )
                );
            }

            // when user is an agreement admin, include all agreements they own
            return agreements.Where(x => Public.Equals(x.VisibilityText, StringComparison.OrdinalIgnoreCase)
                || (
                    x.Participants.Any(y => y.IsOwner && ownedTenantIds.Contains(y.EstablishmentId))
                )
            );
        }
开发者ID:ucosmic,项目名称:UCosmicAlpha,代码行数:26,代码来源:QueryAgreements.cs

示例8: String

 public void String(IEnumerable<string> source, IEqualityComparer<string> comparer, string value, bool expected)
 {
     if (comparer == null)
     {
         Assert.Equal(expected, source.Contains(value));
     }
     Assert.Equal(expected, source.Contains(value, comparer));
 }
开发者ID:chcosta,项目名称:corefx,代码行数:8,代码来源:ContainsTests.cs

示例9: GetUserProfilesByLastActivateOnClassRoomId

 /// <summary>
 /// ขอข้อมูล User profile จากรหัส class room ที่ใช้งานล่าสุด
 /// </summary>
 /// <param name="classRoomId">รหัส class room ที่จะทำการขอข้อมูล</param>
 public IEnumerable<UserProfile> GetUserProfilesByLastActivateOnClassRoomId(IEnumerable<string> classRoomIds)
 {
     var qry = _mongoUtil.GetCollection<UserProfile>(TableName)
         .Find(it => !it.DeletedDate.HasValue && it.Subscriptions.Any(s => classRoomIds.Contains(s.ClassRoomId)))
         .ToEnumerable()
         .Where(it => classRoomIds.Contains(it.Subscriptions.Where(s => !s.DeletedDate.HasValue && s.LastActiveDate.HasValue).OrderBy(s => s.LastActiveDate).LastOrDefault().ClassRoomId));
     return qry;
 }
开发者ID:teerachail,项目名称:mindsage2016,代码行数:12,代码来源:UserProfileRepository.cs

示例10: DeleteDataFor

        public void DeleteDataFor(IEnumerable<string> usersToDelete)
        {
            var postsToDelete = _container.Posts.Where(x => usersToDelete.Contains(x.CreatedBy));
            DeletePosts(postsToDelete.ToList());

            var questionsToDelete = _container.Questions.Where(x => usersToDelete.Contains(x.CreatedBy));
            DeleteQuestions(questionsToDelete.ToList());
        }
开发者ID:rfritz67,项目名称:Access-To-Justice,代码行数:8,代码来源:QuestionRepositorySql.cs

示例11: RemoveProperties

        protected void RemoveProperties(IEnumerable<string> paramNames, bool exclude)
        {
            var propNamesMappingsToRemove = new List<string>(PropertyMappings.Count);
            propNamesMappingsToRemove.AddRange(from propMapping in this.PropertyMappings where (exclude && !paramNames.Contains(propMapping.Value.PropertyName)) || (!exclude && paramNames.Contains(propMapping.Value.PropertyName)) select propMapping.Key);

            foreach (var propName in propNamesMappingsToRemove)
            {
                this.RemoveProperty(propName);
            }
        }
开发者ID:RightCrowd,项目名称:Dapper.FastCRUD,代码行数:10,代码来源:EntityMapping.cs

示例12: FindAllDealerManpowers

 public IEnumerable<DealerManpower> FindAllDealerManpowers(IEnumerable<int> dealerIds, string dse)
 {
     IEnumerable<DealerManpower> manpowers;
     if (string.IsNullOrEmpty(dse))
         manpowers = manpowerRepo.Fetch().Where(x => dealerIds.Contains(x.DealerId) && (x.ObjectInfo.DeletedDate == null || x.Profile.DateOfLeaving != null)).ToList();
     else
     {
         manpowers = manpowerRepo.Fetch().Where(x => dealerIds.Contains(x.DealerId) && x.Type == dse && (x.ObjectInfo.DeletedDate == null || x.Profile.DateOfLeaving != null)).ToList();
     }
     return manpowers;
 }
开发者ID:akhilrex,项目名称:DMP_New,代码行数:11,代码来源:DealerManpowerService.cs

示例13: FindProfilesByManPowerLevel

        public IEnumerable<Profile> FindProfilesByManPowerLevel(IEnumerable<int> dseIds, string value)
        {
            List<Profile> profiles;
            if (string.IsNullOrEmpty(value))
                profiles = profileRepo.Fetch().Where(x => dseIds.Contains(x.DealerManpower.Id) && x.ObjectInfo.DeletedDate == null).ToList();
            else
            {
                profiles = profileRepo.Fetch().Where(x => dseIds.Contains(x.DealerManpower.Id) && x.ObjectInfo.DeletedDate == null && x.TrainingLevel == value).ToList();

            }
            return profiles;
        }
开发者ID:akhilrex,项目名称:DMP_New,代码行数:12,代码来源:ProfileService.cs

示例14: AllRequiredTagsArePresent

        public async Task<bool> AllRequiredTagsArePresent(IEnumerable<int> tagsIds)
        {
            var exactlyOneSeasonTagIsPresent = await this.tags
                .All()
                .CountAsync(t => t.Type == TagType.Season && tagsIds.Contains(t.Id)) == 1;

            var languageOrTechnologyTagIsPresent = await this.tags
                .All()
                .AnyAsync(t => (t.Type == TagType.Technology || t.Type == TagType.Language) && tagsIds.Contains(t.Id));

            return exactlyOneSeasonTagIsPresent && languageOrTechnologyTagIsPresent;
        }
开发者ID:spptest,项目名称:Telerik,代码行数:12,代码来源:TagsService.cs

示例15: GetUnfinishedPackages

 public IEnumerable<Package> GetUnfinishedPackages(string userKey, IEnumerable<string> userPackageIds)
 {
     if (userPackageIds == null || !userPackageIds.Any())
     {
         return new Package[0];
     }
     _packageAuthenticator.EnsureKeyCanAccessPackages(userPackageIds, userKey);
     IEnumerable<Package> existingPublishedPackages = _publishedPackageRepository.Collection.Where(pp => userPackageIds.Contains(pp.Id)).ToList()
         .Select(pp => new Package { Id = pp.Id, Version = pp.Version});
     return _packageRepository.Collection.Where(p => userPackageIds.Contains(p.Id))
         .Except(existingPublishedPackages, (x, y) => x.Id == y.Id && x.Version == y.Version);
 }
开发者ID:dioptre,项目名称:nkd,代码行数:12,代码来源:UnfinishedPackageGetter.cs


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