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


C# ICollection.Remove方法代码示例

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


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

示例1: CreateEncodingBindingElement

 private MessageEncodingBindingElement CreateEncodingBindingElement(ICollection<XmlElement> assertions, out XmlElement encodingAssertion)
 {
     encodingAssertion = null;
     foreach (XmlElement element in assertions)
     {
         string namespaceURI = element.NamespaceURI;
         if (namespaceURI == null)
         {
             continue;
         }
         if (!(namespaceURI == "http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"))
         {
             if (namespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization")
             {
                 goto Label_005F;
             }
             continue;
         }
         if (!(element.LocalName == "BinaryEncoding"))
         {
             continue;
         }
         encodingAssertion = element;
         assertions.Remove(encodingAssertion);
         return new BinaryMessageEncodingBindingElement();
     Label_005F:
         if (element.LocalName == "OptimizedMimeSerialization")
         {
             encodingAssertion = element;
             assertions.Remove(encodingAssertion);
             return new MtomMessageEncodingBindingElement();
         }
     }
     return new TextMessageEncodingBindingElement();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:MessageEncodingBindingElementImporter.cs

示例2: ModifySetForTest

 private void ModifySetForTest(ICollection<int> set)
 {
     set.Remove(1);
     set.Remove(2);
     set.Add(4);
     set.Add(5);
 }
开发者ID:SaladLab,项目名称:TrackableData,代码行数:7,代码来源:StorageSetValueTestKit.cs

示例3: TestReadOnly

 private void TestReadOnly(ICollection<string> collection)
 {
     Assert.Equal(true, collection.IsReadOnly);
     Assert.Throws<NotSupportedException>(() => collection.Add("x"));
     Assert.Throws<NotSupportedException>(() => collection.Remove("x"));
     Assert.Throws<NotSupportedException>(() => collection.Clear());
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:IdentifierCollectionTests.cs

示例4: SyncFileCollectionFromPath

        public bool SyncFileCollectionFromPath(ICollection<SiqualFile> files, DatabaseServer server, Project project)
        {
            string folderPath = project.FolderPath;
              if (!Directory.Exists(folderPath))
            return false;

            string[] filePaths = Directory.GetFiles(folderPath, "*.sql", SearchOption.AllDirectories);

            IList<SiqualFile> filesRemovedFromPath = new List<SiqualFile>();

            foreach (SiqualFile file in files)
            {
              if (filePaths.FirstOrDefault(x => x == file.FullFilePath) != null) continue;

            filesRemovedFromPath.Add(file);
              _filesChanged = true;
            }

            foreach (string filePath in filePaths)
            {
              if (files.FirstOrDefault(x => x.FullFilePath == filePath) != null) continue;

            files.Add(new SiqualFile(filePath, server, project));
              _filesChanged = true;
            }

            foreach (SiqualFile fileToRemove in filesRemovedFromPath)
            {
                files.Remove(fileToRemove);
            }

              return _filesChanged;
        }
开发者ID:sirrocco,项目名称:SqlScriptRunner,代码行数:33,代码来源:FileSynchronizer.cs

示例5: GetAllTypesAsString

        string GetAllTypesAsString(ICollection<string> types)
        {
            // This causes a conflict with the vim keyword 'contains'
            types.Remove("Contains");

            return types.Aggregate("", (current, type) => current + type + " ");
        }
开发者ID:sphynx79,项目名称:dotfiles,代码行数:7,代码来源:LookupAllTypesHandler.cs

示例6: CompareLists

        /// <summary>
        /// Compares the lists of articles in the 2 provided Lists
        /// Best to provide an already sorted list. List 1 should be the smallest list
        /// </summary>
        /// <param name="list1">First List (preferably the smallest)</param>
        /// <param name="list2">Second List</param>
        /// <param name="lb1">List Box where unique items from list1 should go</param>
        /// <param name="lb2">List Box where unique items from list2 should go</param>
        /// <param name="lb3">List Box where the duplicates should go</param>
        private static void CompareLists(IList<Article> list1, ICollection<Article> list2, ListBox lb1, ListBox lb2, ListBox lb3)
        {
            lb1.BeginUpdate();
            lb2.BeginUpdate();
            lb3.BeginUpdate();

            while (list1.Count > 0)
            {
                Article a = list1[0];
                if (list2.Contains(a))
                {
                    lb3.Items.Add(a.Name);
                    list2.Remove(a);
                }
                else
                    lb1.Items.Add(a.Name);

                list1.Remove(a);
            }

            foreach (Article article in list2)
            {
                lb2.Items.Add(article.Name);
            }

            lb1.EndUpdate();
            lb2.EndUpdate();
            lb3.EndUpdate();
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:38,代码来源:ListComparer.cs

示例7: CheckDataIfStartMenuIsExpectedToNotExist

        private static CheckResult CheckDataIfStartMenuIsExpectedToNotExist(ICollection<FileChange> fileChanges, ICollection<Registryhange> registryChanges,
            FileChange fileChange, StartMenuData startMenuData, Registryhange registryChange)
        {
            if (fileChange == null)
            {
               return CheckResult.Succeeded(startMenuData);
            }

            if (fileChange.Type != FileChangeType.Delete)
            {
                fileChanges.Remove(fileChange);
                if (registryChange != null)
                {
                    registryChanges.Remove(registryChange);
                }
                return CheckResult.Failure("Found menu item:'" + startMenuData.Name + "' when is was not expected");
            }

            // When uninstalling this key get changed
            const string startPageKey = @"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartPage";
            var uninstallStartMenuKey =
                registryChanges.FirstOrDefault(x => string.Equals(x.Key, startPageKey, StringComparison.InvariantCultureIgnoreCase) &&
                                                    x.ValueName == "FavoritesRemovedChanges" &&
                                                    x.Type == RegistryChangeType.SetValue);

            if (uninstallStartMenuKey == null)
            {
                fileChanges.Remove(fileChange);
                return CheckResult.Failure("");
            }

            registryChanges.Remove(uninstallStartMenuKey);
            fileChanges.Remove(fileChange);
            return CheckResult.Succeeded(startMenuData);
        }
开发者ID:pwibeck,项目名称:InstallerVerificationFramework,代码行数:35,代码来源:StartMenuCheck.cs

示例8: FillFees

		public void FillFees(ICollection<AppraiserFee> fees, FeesViewModel feesViewModel)
		{
			if (fees == null)
			{
				throw new ArgumentNullException("fees");
			}
			if (feesViewModel == null)
			{
				throw new ArgumentNullException("fees view model");
			}
			var feesArray = fees.ToArray();
			foreach (var fee in feesArray)
			{
				if (!feesViewModel.FeesItems.Any(f => f.Id == fee.Id.ToString()))
				{
					fees.Remove(fee);
				}
			}
			foreach (var item in feesViewModel.FeesItems)
			{
				if (string.IsNullOrEmpty(_refManager.GetProductNameById(item.ProductType)))
				{
					throw new ArgumentException("product id");
				}
				var fee = fees.SingleOrDefault(e => e.Id.ToString() == item.Id);
				if (fee == null)
				{
					fee = new AppraiserFee();
					fees.Add(fee);
				}
				fee.Amount = item.Fee.Value;
				fee.ProductId = item.ProductType;
			}
		}
开发者ID:evkap,项目名称:DVS,代码行数:34,代码来源:FeeManager.cs

示例9: BuildTableList

        private static string[] BuildTableList(ICollection<string> allTables, ICollection<Relationship> allRelationships)
        {
            var tablesToDelete = new List<string>();

            while (allTables.Any())
            {
                string[] leafTables = allTables.Except(allRelationships.Select(rel => rel.PrimaryKeyTable)).ToArray();

                if(leafTables.Length == 0)
                {
                    tablesToDelete.AddRange(allTables);
                    break;
                }

                tablesToDelete.AddRange(leafTables);

                foreach (string leafTable in leafTables)
                {
                    allTables.Remove(leafTable);
                    Relationship[] relToRemove =
                        allRelationships.Where(rel => rel.ForeignKeyTable == leafTable).ToArray();
                    foreach (Relationship rel in relToRemove)
                    {
                        allRelationships.Remove(rel);
                    }
                }
            }

            return tablesToDelete.ToArray();
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:30,代码来源:DatabaseEmptier.cs

示例10: EnsurePeersDiscovered

        public static void EnsurePeersDiscovered(ref bool peersDiscovered, IPeerUrlSource urls, ICollection<string> peers, string handlerName, Guid selfId, object locker, Action<HttpWebRequest> requestPreparer)
        {
            if (peersDiscovered)
            {
                return;
            }

            lock (locker)
            {
                if (peersDiscovered)
                {
                    return;
                }
                foreach (var url in urls.GetPeerUrls())
                {
                    peers.Add(url);
                }
                // Loop through peers and send the loopbackTest
                var queryString = "?" + RequestKeys.LoopbackTest + "=" + HttpUtility.UrlEncode(selfId.ToString());
                var peersToRemove = new List<string>();
                Parallel.ForEach(peers, peer =>
                {
                    try
                    {
                        CreatePrepareAndSendRequestAsync(peer + handlerName + queryString, requestPreparer)
                            .ContinueWith(t =>
                            {
                                if (t.Exception != null)
                                {
                                    peersToRemove.Add(peer);
                                }
                                else
                                {
                                    using (var sr = new StreamReader(t.Result.GetResponseStream()))
                                    {
                                        var result = sr.ReadToEnd();
                                        if (result != ResponseValues.Ack)
                                        {
                                            // Something wrong with peer, or is ourself, so remove from list
                                            peersToRemove.Add(peer);
                                        }
                                    }
                                }
                            })
                            .Wait();
                    }
                    catch (Exception)
                    {
                        // Problem contacting peer, remove it from the list
                        peersToRemove.Add(peer);
                    }
                });
                if (peersToRemove.Count > 0)
                {
                    peersToRemove.ForEach(p => peers.Remove(p));
                }
                peersDiscovered = true;
            }
        }
开发者ID:abuhmead1987,项目名称:Presentations,代码行数:59,代码来源:PeerToPeerHelper.cs

示例11: InitializeController

        public EventsController InitializeController(ICollection<Event> events)
        {
            var repo = new Mock<IEventRepository>();
            repo.Setup(n => n.GetAll()).Returns(events.AsEnumerable());
            repo.Setup(n => n.Delete(It.IsAny<int>())).Callback<int>(id => events.Remove(events.First(n => n.Id == id)));

            return new EventsController(repo.Object);
        }
开发者ID:TommyNewbie,项目名称:TimeManager,代码行数:8,代码来源:DeleteEventTest.cs

示例12: TryC5Coll

 public void TryC5Coll(ICollection<double> coll) {
     Assert.AreEqual(0, coll.Count);
     double[] arr = { };
     coll.CopyTo(arr, 0);
     Assert.IsFalse(coll.IsReadOnly);
     coll.Add(2.3);
     coll.Add(3.2);
     Assert.AreEqual(2, coll.Count);
     Assert.IsTrue(coll.Contains(2.3));
     Assert.IsFalse(coll.Contains(3.1));
     Assert.IsFalse(coll.Remove(3.1));
     Assert.IsTrue(coll.Remove(3.2));
     Assert.IsFalse(coll.Contains(3.1));
     Assert.AreEqual(1, coll.Count);
     coll.Clear();
     Assert.AreEqual(0, coll.Count);
     Assert.IsFalse(coll.Remove(3.1));
 }
开发者ID:debop,项目名称:NFramework,代码行数:18,代码来源:InterfacesTest.cs

示例13: RemoveReferenceTypeProperty

        private static void RemoveReferenceTypeProperty(KeyValuePair<string, Schema> property, ICollection<KeyValuePair<string, Schema>> properties)
        {
            Contract.Requires(property.Value != null);
            Contract.Requires(property.Value.type != null || [email protected] == null || properties != null);

            if (property.Value.type == null && [email protected] != null)
            {
                properties.Remove(property);
            }
        }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:10,代码来源:LimitSchemaGraphToTopLevelEntity.cs

示例14: OffsetDuration

 private static void OffsetDuration(ICollection<Activity> domain, Activity parent, int offset)
 {
     var children = domain.Where(a => a.Dependencies.Contains(parent.Id)).ToList();
     foreach (var child in children)
     {
         child.StartDateConsecutive = child.StartDateConsecutive.AddSeconds(offset);
         domain.Remove(child);
         OffsetDuration(domain, child, offset);
     }
 }
开发者ID:jsbsantos,项目名称:teamworks,代码行数:10,代码来源:ActivityExtensions.cs

示例15: TestContractLocals

    public static void TestContractLocals(ICollection<string> coll)
    {
      Contract.Requires(coll != null);
      Contract.Requires(!coll.IsReadOnly);

      if (coll.Contains("foo")) {
        Contract.Assert(coll.Count > 0);
        coll.Remove("foo");
      }
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:10,代码来源:General.cs


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