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


C# Guid.Contains方法代码示例

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


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

示例1: RemoveControls

 public void RemoveControls(Guid[] ids)
 {
     var controlsToRemove = Controls.Where(control => ids.Contains(control.Id)).ToArray();
     foreach (var control in controlsToRemove)
     {
         Controls.Remove(control);
     }
 }
开发者ID:johanclasson,项目名称:Akkomation,代码行数:8,代码来源:DeviceEntry.cs

示例2: GetHandlersExForProducts

 public static List<ISearchHandlerEx> GetHandlersExForProducts(Guid[] productIDs)
 {
     lock (handlers)
     {
         return handlers
             .Where(h => productIDs.Contains(h.ProductID) || h.ProductID.Equals(Guid.Empty))
             .ToList();
     }
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:9,代码来源:SearchHandlerManager.cs

示例3: GetPermittedRepositories

 public IList<RepositoryModel> GetPermittedRepositories(Guid userId, Guid[] userTeamsId)
 {
     if (userId == Guid.Empty) throw new ArgumentException("Do not pass invalid userId", "userId");
     return GetAllRepositories().Where(repo =>
         repo.Users.Any(user => user.Id == userId) ||
         repo.Administrators.Any(admin => admin.Id == userId) ||
         repo.Teams.Any(team => userTeamsId.Contains(team.Id)) ||
         repo.AnonymousAccess).ToList();
 }
开发者ID:Guzhongren,项目名称:Bonobo-Git-Server,代码行数:9,代码来源:RepositoryRepositoryBase.cs

示例4: SendMessage

 public void SendMessage(string subject, string body, Guid authorID, Guid[] recipientIDs)
 {
     var recipients = _repository.FindAllBy<Traveler>(t => recipientIDs.Contains(t.TravelerID));
     if (recipients == null || recipients.Count() != recipientIDs.Count()) throw new TravelerNotFoundException();
     Traveler author = _repository.FindBy<Traveler>(r => r.TravelerID == authorID);
     if (author == null) throw new TravelerNotFoundException();
     Message message = MessageFactory.CreateMessageFrom(subject, body, author, recipients);
     _repository.Add<Message>(message);
     _repository.Commit();
 }
开发者ID:Nimrodda,项目名称:TravelersAround,代码行数:10,代码来源:MessageService.cs

示例5: TestLinqArrayContains

        public void TestLinqArrayContains()
        {
            var app = SetupHelper.BooksApp;
              var session = app.OpenSession();

              var bookOrders = session.EntitySet<IBookOrder>();
              //Note: for debugging use table that is not fully cached, so we use IBookOrder entity

              // Test retrieving orders by Id-in-list
              var someOrders = bookOrders.Take(2).ToList();
              var someOrderIds = someOrders.Select(o => o.Id).ToArray();
              var qSomeOrders = from bo in bookOrders
                        where someOrderIds.Contains(bo.Id)
                        select bo;
              var someOrders2 = qSomeOrders.ToList();
              var cmd = session.GetLastCommand(); //just for debugging
              Assert.AreEqual(someOrderIds.Length, someOrders2.Count, "Test Array.Contains failed: order counts do not match.");

              // Try again with a single Id
              var arrOneId = new Guid[] { someOrderIds[0] };
              var qOrders = from bo in bookOrders
                    where arrOneId.Contains(bo.Id)
                    select bo;
              var orders = qOrders.ToList();
              Assert.AreEqual(1, orders.Count, "Test Array.Contains with one Id failed: order counts do not match.");

              // Again with empty list
              var arrEmpty = new Guid[] {};
              var qNoBooks = from b in session.EntitySet<IBook>()
                     where arrEmpty.Contains(b.Id)
                    select b;
              var noBooks = qNoBooks.ToList();
              cmd = session.GetLastCommand();
              Assert.AreEqual(0, noBooks.Count, "Test Array.Contains with empty array failed, expected 0 entities");

              // Again with list, not array
              var orderIdsList = someOrderIds.ToList();
              qOrders = from bo in bookOrders
                where orderIdsList.Contains(bo.Id)
                select bo;
              orders = qOrders.ToList();
              Assert.AreEqual(orderIdsList.Count, orders.Count, "Test constList.Contains, repeated query failed: order counts do not match.");

              // Test intList.Contains()
              var userTypes = new UserType[] { UserType.Customer, UserType.Author };
              var qOrders2 = from bo in bookOrders
                    where userTypes.Contains(bo.User.Type)
                    select bo;
              var orders2 = qOrders2.ToList();
              Assert.IsTrue(orders2.Count > 0, "No orders by type found.");
        }
开发者ID:yuanfei05,项目名称:vita,代码行数:51,代码来源:LinqTests.cs

示例6: Delete

        //删除文档
        public static void Delete(Guid[] ids)
        {
            using (var context = new DataModelDataContext())
            {
                var objs =
                    (from item in context.Documents where ids.Contains(item.Id) select item).ToList();

                foreach (Document item in objs)
                {
                    context.Documents.DeleteOnSubmit(item);
                }

                context.SubmitChanges();
            }
        }
开发者ID:jiguixin,项目名称:WF,代码行数:16,代码来源:DocumentHelper.cs

示例7: Ancestors

        /// <summary></summary>
        /// <param name="descendant"></param>
        /// <returns>A list of all ancestor timelines which also includes the current timeline.</returns>
        public static List<Guid> Ancestors(this Timeline descendant)
        {
            List<Guid> rv = new List<Guid>();

            Timeline timeline = descendant;
            Guid[] searchTerm;

            using (Storage storage = new Storage())
            {
                while (timeline != null)
                {
                    rv.Add(timeline.Id);
                    searchTerm = new Guid[] { timeline.Id };
                    timeline = storage.Timelines.Where(t => t.ChildTimelines.Any(ct => searchTerm.Contains(ct.Id))).FirstOrDefault(); // get parent if exists
                }
            }

            return rv;
        }
开发者ID:sadeghsm,项目名称:ChronoZoom,代码行数:22,代码来源:TimelineExtensions.cs

示例8: GetMembershipService

            private static IMembershipService GetMembershipService(Guid[] keys) {

                var users = GetDummyUsers(keys);
                var mockMemSrv = ServicesMockHelper
                    .GetInitialMembershipServiceMock();

                mockMemSrv.Setup(ms => ms.GetUser(
                        It.Is<Guid>(
                            key => keys.Contains(key)
                        )
                    )
                ).Returns<Guid>(key =>
                    users.FirstOrDefault(x =>
                        x.User.Key == key
                    )
                );

                mockMemSrv.Setup(ms => ms.UpdateUser(
                        It.IsAny<User>(), It.IsAny<string>(), It.IsAny<string>()
                    )
                ).Returns<User, string, string>(
                    (user, username, email) => {

                        var roles = users
                            .FirstOrDefault(
                                x => x.User.Name.Equals(user.Name, StringComparison.OrdinalIgnoreCase)).Roles;

                        user.Name = username;
                        user.Email = email;
                        return new UserWithRoles {
                            User = user,
                            Roles = roles
                        };
                    }
                );

                return mockMemSrv.Object;
            }
开发者ID:kinhnv,项目名称:PingYourPackage,代码行数:38,代码来源:UsersControllerIntegrationTest.cs

示例9: Get

 public IEnumerable<ControlEntry> Get(Guid[] controls)
 {
     return Dic.Values.SelectMany(l => l.Where(c => controls.Contains(c.Id)));
 }
开发者ID:johanclasson,项目名称:Akkomation,代码行数:4,代码来源:PluginControlEntryDictionary.cs

示例10: CardDatabaseDifferences

        public ActionResult CardDatabaseDifferences(bool? commit, Guid[] except)
        {
            var cardMembers = CardDatabaseService.GetEmergencyWorkers();
              var cardMembersDict = cardMembers.ToDictionary(f => f.PK, f => f);

              var dbMembers = this.db.Members
              .Where(f => f.WacLevel > WacLevel.None && f.Memberships.Any(g => g.EndTime == null && g.Status.IsActive) && f.ExternalKey1 != null)
              .OrderBy(f => f.LastName).ThenBy(f => f.FirstName).ToList();

              StringBuilder builder = new StringBuilder();

              var d = 0;

              while (d < dbMembers.Count)
              {
            if (cardMembersDict.ContainsKey(dbMembers[d].ExternalKey1.Value))
            {
              var cardMember = cardMembersDict[dbMembers[d].ExternalKey1.Value];

              string matchText = "";
              if (cardMember.IdentityCode != dbMembers[d].DEM)
            matchText += string.Format(", KCSO DEM={0} KCSARA DEM={1}", cardMember.IdentityCode, dbMembers[d].DEM);
              if (cardMember.Rank != dbMembers[d].WacLevel.ToString())
            matchText += string.Format(", KCSO Card={0} KCSARA Card={1}", cardMember.Rank, dbMembers[d].WacLevel.ToString());
              if (matchText.Length > 0)
            builder.AppendFormat("<b>{0}</b> has differences{1}<br/>", dbMembers[d].ReverseName, matchText);

              if (!cardMember.LastName.Equals(dbMembers[d].LastName, StringComparison.OrdinalIgnoreCase) || !cardMember.FirstName.Equals(dbMembers[d].FirstName, StringComparison.OrdinalIgnoreCase))
            builder.AppendFormat("<span style=\"color:#cccccc\">KCSARA member {0} in KCSO database as {1}, {2}</span><br/>", dbMembers[d].ReverseName, cardMember.LastName, cardMember.FirstName);

              cardMembersDict.Remove(dbMembers[d].ExternalKey1.Value);
              dbMembers.RemoveAt(d);
            }
            else
            {
              builder.AppendFormat("<b><a href=\"{1}\">{0}</a></b> was linked to a card database record that no longer exists<br/>", dbMembers[d].ReverseName, Url.Action("Detail", new { id = dbMembers[d].Id }));
              d++;
            }
              }

              cardMembers = cardMembersDict.Values.OrderBy(f => f.LastName).ThenBy(f => f.FirstName).ToList();
              dbMembers = this.db.Members.Where(f => f.WacLevel > WacLevel.None && f.Memberships.Any(g => g.EndTime == null && g.Status.IsActive) && f.ExternalKey1 == null)
              .OrderBy(f => f.LastName).ThenBy(f => f.FirstName).ToList();

              d = 0;
              while (d < dbMembers.Count)
              {
            var dbMember = dbMembers[d];

            var matches = cardMembers.Where(f => f.LastName.Equals(dbMember.LastName, StringComparison.OrdinalIgnoreCase) && f.FirstName.Equals(dbMember.FirstName, StringComparison.OrdinalIgnoreCase));
            if (matches.Count() > 1)
            {
              matches = cardMembers.Where(f => f.IdentityCode == dbMember.DEM && f.LastName.Equals(dbMember.LastName, StringComparison.OrdinalIgnoreCase) && f.FirstName.Equals(dbMember.FirstName, StringComparison.OrdinalIgnoreCase));
            }
            else if (matches.Count() == 0)
            {
              matches = cardMembers.Where(f => f.IdentityCode == dbMember.DEM && f.LastName.Equals(dbMember.LastName, StringComparison.OrdinalIgnoreCase));
            }

            if (matches.Count() == 0)
            {
              builder.AppendFormat("Can't find <b><a href=\"{1}\">{0}</a></b> in card database<br/>", dbMember.ReverseName, Url.Action("Detail", new { id = dbMember.Id }));
              d++;
            }
            else if (matches.Count() == 1)
            {
              var cardMember = matches.First();

              builder.AppendFormat("New linked member: <b>{0}, {1}</b> ({2}) - {3}  <i><a href=\"{5}\">{4}</a> [{6}]</i><br/>", cardMember.LastName, cardMember.FirstName, cardMember.IdentityCode, cardMember.Rank, dbMember.ReverseName, Url.Action("Detail", new { id = dbMember.Id }), cardMember.PK);

              string matchText = "";
              if (cardMember.IdentityCode != dbMember.DEM)
            matchText += string.Format(", KCSO DEM={0} KCSARA DEM={1}", cardMember.IdentityCode, dbMember.DEM);
              if (cardMember.Rank != dbMember.WacLevel.ToString())
            matchText += string.Format(", KCSO Card={0} KCSARA Card={1}", cardMember.Rank, dbMember.WacLevel.ToString());

              if (matchText.Length > 0)
            builder.AppendFormat("<b>{0}</b> has differences{1}<br/>", dbMember.ReverseName, matchText);

              if (except == null || !except.Contains(dbMember.Id))
              {
            dbMember.ExternalKey1 = cardMember.PK;
              }
              else
              {
            builder.AppendFormat("Skipped linking by request<br/>");
              }

              cardMembers.Remove(cardMember);
              dbMembers.RemoveAt(d);
            }
            else
            {
              builder.AppendFormat("Multiple card records with name {0} and DEM {1}<br/>", dbMember.FullName, dbMember.DEM);
              dbMembers.RemoveAt(d);
              cardMembers.RemoveAll(f => f.LastName.Equals(dbMember.LastName, StringComparison.OrdinalIgnoreCase) &&
              f.FirstName.Equals(dbMember.FirstName, StringComparison.OrdinalIgnoreCase) &&
              f.IdentityCode == dbMember.DEM);
            }
              }
//.........这里部分代码省略.........
开发者ID:robbiesmith,项目名称:KCSARA-Database,代码行数:101,代码来源:MembersController.cs

示例11: RequestFeedback

        public ActionResult RequestFeedback(Guid id, string message, Guid[] instructors)
        {
            var experience =
                RepositoryFactory.ExperienceRepository.Queryable.SingleOrDefault(
                    x => x.Id == id && x.Creator.Identifier == CurrentUser.Identity.Name);

            if (experience == null)
            {
                return new HttpNotFoundResult("Could not find the requested experience");
            }

            var instructorsToNotify =
                RepositoryFactory.InstructorRepository.Queryable.Where(x => instructors.Contains(x.Id)).ToList();

            foreach (var instructor in instructorsToNotify)
            {
                experience.AddFeedbackRequest(new FeedbackRequest {Message = message, Instructor = instructor});
            }

            if (experience.InstructorViewable == false)
            {
                experience.InstructorViewable = true;
            }

            RepositoryFactory.ExperienceRepository.EnsurePersistent(experience);

            Message = string.Format("Feedback Requests sent successfully");

            return RedirectToAction("ViewExperience", "Student", new {id});
        }
开发者ID:jorr0,项目名称:Badges,代码行数:30,代码来源:StudentController.cs

示例12: UpdateSubOrganizationsStatus

        private void UpdateSubOrganizationsStatus(MembershipDataContext ctx, Guid[] parentOrganizationIds, OrganizationStatus status)
        {
            var q = from org in ctx.Organizations
                    where org.ParentOrganizationId.HasValue
                        && parentOrganizationIds.Contains(org.ParentOrganizationId.Value)
                        && org.Status != status
                    select org;

            if (q.Count() == 0) return;

            foreach (Organization organization in q.AsEnumerable())
            {
                organization.Status = status;
                base.RemoveCache(organization.OrganizationId);
            }

            UpdateSubOrganizationsStatus(ctx, q.Select(org => org.OrganizationId).ToArray(), status);
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:18,代码来源:OrganizationApi.Organization.cs

示例13: GetSuggestions

        /// <summary>
        /// Suggests description instances from the defined in Suggester sources based on one or more semantic objects
        /// </summary>
        /// <param name="semanticObjects">RDF based concrete semantic object</param>
        /// <param name="sourceFilter">if Null all sources are used, if set only those set are processed</param>
        /// <returns>Returns collection of suggested description objects (such as keywords, RDF statements, etc.)</returns>
        public List<ISuggestionInstance> GetSuggestions(ISemanticObject[] semanticObjects, Guid[] sourceFilter = null)
        {
            Dictionary<string, Tuple<ISuggestionInstance, double>> CombinedCollection = new Dictionary<string, Tuple<ISuggestionInstance, double>>();
            double maxRelevanceSum = 0;
            double minRelevanceValue = double.MaxValue;
            const string combinedSourceName = "Multiple sources";
            Guid combinedGuid = Guid.NewGuid();

            foreach (var nextSource in this.sources)
            {
                if (sourceFilter == null || sourceFilter.Contains(nextSource.Guid))
                {
                    foreach (var nextResult in nextSource.GetSuggestions(semanticObjects))
                    {
                        double combinedrelevance;
                        if (CombinedCollection.ContainsKey(nextResult.GetTextValue()))
                        {
                            var oldvalue = CombinedCollection[nextResult.GetTextValue()];
                            combinedrelevance = oldvalue.Item2 + nextResult.Relevance;

                            // HACK - think how this should be when RDF suggestions sources implemented. Should we flatter them like this or do something else.
                            var combinedResult = new StringKeywordSuggestion(nextResult.GetTextValue(), combinedGuid, combinedSourceName);
                            nextResult.Rank = nextResult.Rank + oldvalue.Item1.Rank;
                            CombinedCollection[nextResult.GetTextValue()] = new Tuple<ISuggestionInstance, double>(combinedResult, combinedrelevance);
                        }
                        else
                        {
                            combinedrelevance = nextResult.Relevance;
                            CombinedCollection.Add(nextResult.GetTextValue(), new Tuple<ISuggestionInstance, double>(nextResult, combinedrelevance));
                        }

                        if (combinedrelevance > maxRelevanceSum)
                        {
                            maxRelevanceSum = combinedrelevance;
                        }

                        if (combinedrelevance < minRelevanceValue)
                        {
                            minRelevanceValue = combinedrelevance;
                        }
                    }
                }
            }

            // now normalize relevance
            var readyList = new List<ISuggestionInstance>();
            foreach (var nextSuggestion in CombinedCollection)
            {
                // map 0...max to 0..100;
                double newrelevance = (maxRelevanceSum * nextSuggestion.Value.Item2 == 0) ? 0 : 100 / maxRelevanceSum * nextSuggestion.Value.Item2;
                var nextsuggestion = nextSuggestion.Value.Item1;
                nextsuggestion.Relevance = newrelevance;
                readyList.Add(nextsuggestion);
            }

            readyList.Sort(delegate (ISuggestionInstance x, ISuggestionInstance y)
            {
                return y.Relevance.CompareTo(x.Relevance); // descending sort
            });
            return readyList;
        }
开发者ID:serrnovik,项目名称:SemanticDescription,代码行数:67,代码来源:Suggester.cs

示例14: LoadSetting

 public SearchResult LoadSetting(Guid[] checksum)
 {
     var sr = new SearchResult();
     var db = new x360ceModelContainer();
     sr.PadSettings = db.PadSettings.Where(x => checksum.Contains(x.PadSettingChecksum)).ToArray();
     db.Dispose();
     db = null;
     return sr;
 }
开发者ID:XxRaPiDK3LLERxX,项目名称:nucleuscoop,代码行数:9,代码来源:x360ce.asmx.cs

示例15: Delete

        /// <summary>
        /// 删除数据实体
        /// </summary>
        /// <param name="ids">要删除的数据实体主键列表</param>
        /// <returns>成功返回 true;否则返回 false。</returns>
        public virtual WebApiResult Delete(Guid[] ids)
        {
            var result = new WebApiResult();

            #region 删除
            var entities = from item in DataContext.Basic_Announcement
                           where ids.Contains(item.Id)
                           select item;
            DataContext.Basic_Announcement.RemoveRange(entities);
            DataContext.SaveChanges();
            #endregion

            return result;
        }
开发者ID:xiaocaiyuen,项目名称:src,代码行数:19,代码来源:AnnouncementService.cs


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