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


C# HashSet.AddRange方法代码示例

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


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

示例1: Get

 public HashSet<CartItem> Get(CartItemBasedDiscountApplication application, CartModel cart)
 {
     var cartItems = new HashSet<CartItem>();
     cartItems.AddRange(_getCartItemsBySKUList.GetCartItems(cart, application.SKUs));
     cartItems.AddRange(_getCartItemsByCategoryIdList.GetCartItems(cart, application.CategoryIds));
     return cartItems;
 }
开发者ID:neozhu,项目名称:Ecommerce,代码行数:7,代码来源:GetCartItemBasedApplicationProducts.cs

示例2: RenameLocationSet

        private RenameLocationSet(ISymbol symbol, Solution solution, OptionSet optionSet, SearchResult originalSymbolResult, List<SearchResult> overloadsResult, IEnumerable<RenameLocation> stringsResult, IEnumerable<RenameLocation> commentsResult)
        {
            _symbol = symbol;
            _solution = solution;
            _optionSet = optionSet;
            _originalSymbolResult = originalSymbolResult;
            _overloadsResult = overloadsResult;
            _stringsResult = stringsResult;
            _commentsResult = commentsResult;

            var mergedLocations = new HashSet<RenameLocation>();
            var mergedReferencedSymbols = new List<ISymbol>();
            var mergedImplicitLocations = new List<ReferenceLocation>();

            if (optionSet.GetOption(RenameOptions.RenameInStrings))
            {
                mergedLocations.AddRange(stringsResult);
            }

            if (optionSet.GetOption(RenameOptions.RenameInComments))
            {
                mergedLocations.AddRange(commentsResult);
            }

            var overloadsToMerge = (optionSet.GetOption(RenameOptions.RenameOverloads) ? overloadsResult : null) ?? SpecializedCollections.EmptyEnumerable<SearchResult>();
            foreach (var result in overloadsToMerge.Concat(originalSymbolResult))
            {
                mergedLocations.AddRange(result.Locations);
                mergedImplicitLocations.AddRange(result.ImplicitLocations);
                mergedReferencedSymbols.AddRange(result.ReferencedSymbols);
            }

            _mergedResult = new SearchResult(mergedLocations, mergedImplicitLocations, mergedReferencedSymbols);
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:34,代码来源:RenameLocationSet.cs

示例3: ProcessAssembly

        protected override void ProcessAssembly(AssemblyDefinition assemblyDef)
        {
            if (_frameworkProfile == null) {
                _frameworkProfile = assemblyDef.GuessAssemblyProfile();
            }
            if (_frameworkProfile != null) {
                _assemblyResolver.AddSearchDirectory(_frameworkProfile.ReferencesDirectory);
            }
            var typesDependenciesCollector = new CollectTypesDependenciesProcessor(_frameworkProfile);
            typesDependenciesCollector.Process(assemblyDef);

            var goodAssemblyNames = assemblyDef.Modules.SelectMany(asmDef => asmDef.AssemblyReferences);
            if(_removeNonRetargetable) {
                goodAssemblyNames = goodAssemblyNames.Where(asmRef => asmRef.IsRetargetable);
            }
            if (_frameworkProfile != null) {
                goodAssemblyNames = goodAssemblyNames.Concat(_frameworkProfile.GetFrameworkAssemblies());
            }

            var goodModules = new HashSet<ModuleDefinition>(CecilEqualityComparer.Default);
            goodModules.AddRange(assemblyDef.Modules);
            goodModules.AddRange(goodAssemblyNames.Select(_assemblyResolver.TryResolve).Where(asmDef => asmDef != null).SelectMany(asmDef => asmDef.Modules));

            var allTypesDependencies = typesDependenciesCollector.AllTypesDependencies;
            var typeDependenciesToRemove = new Queue<TypeReferenceAndDependencies>(allTypesDependencies.Where(
                kv => {
                    var typeRef = kv.Key;
                    var typeDef = typeRef.TryResolve();
                    return typeDef == null || !goodModules.Contains(typeDef.Module);
                }).Select(kv => (TypeReferenceAndDependencies)kv));

            var removedDependencies = new HashSet<TypeDependency>();
            while (typeDependenciesToRemove.Any()) {
                var typeDependencies = typeDependenciesToRemove.Dequeue();
                var typeRef = typeDependencies.Type;
                var dependencies = typeDependencies.DependingMembers;
                Trace.WriteLine(string.Format("Removing dependencies on type {0}:", typeRef), "RemoveExternalTypesUsage");
                Trace.Indent();
                foreach (var dependency in dependencies) {
                    if (!removedDependencies.Contains(dependency)) {
                        dependency.Break();
                        removedDependencies.Add(dependency);

                        var baseClassDependency = dependency as BaseClassDependency;
                        if (baseClassDependency != null) {
                            var removedClass = baseClassDependency.DerivedClass;
                            if (allTypesDependencies.ContainsKey(removedClass)) {
                                var removedClassDependencies = allTypesDependencies[removedClass];
                                typeDependenciesToRemove.Enqueue(new TypeReferenceAndDependencies(removedClass, removedClassDependencies));
                            }
                        }
                    }
                }
                Trace.Unindent();
            }

            base.ProcessAssembly(assemblyDef);
        }
开发者ID:LoveDuckie,项目名称:Piranha,代码行数:58,代码来源:RemoveExternalTypesUsageProcessor.cs

示例4: Edits

        private static IEnumerable<string> Edits(string word)
        {
            var set = new HashSet<string>();

            var splits = Splits(set, word);
            set.AddRange(Deletes(splits));
            set.AddRange(Transposes(splits));
            set.AddRange(Replaces(splits));
            set.AddRange(Inserts(splits));

            return set;
        }
开发者ID:brucewu16899,项目名称:lacjam,代码行数:12,代码来源:SpellingExtensions.cs

示例5: Grant

        public void Grant(params string[] permissions)
        {
            if (permissions == null || permissions.Length == 0)
                throw new ArgumentNullException(nameof(permissions));

            var grantingStack = GetGrantingStack(true);

            if (grantingStack.Count > 0)
            {
                var oldSet = grantingStack.Peek();
                if (oldSet == null)
                {
                    grantingStack.Push(null);
                }
                else
                {
                    var newSet = new HashSet<string>(oldSet);
                    newSet.AddRange(permissions);
                    grantingStack.Push(newSet);
                }
            }
            else
            {
                grantingStack.Push(new HashSet<string>(permissions));
            }
        }
开发者ID:VictorTomaili,项目名称:Sanity,代码行数:26,代码来源:TransientGrantingPermissionService.cs

示例6: UpdateLayout

        public void UpdateLayout()
        {
            HashSet<UIElement> arrangedElements = new HashSet<UIElement>();

            while (measureQueue.Count > 0 || arrangeQueue.Count > 0)
            {
                while (measureQueue.Count > 0)
                {
                    UIElement element = GetTopElement(measureQueue);
                    element.Measure(element.VisualParent == null || element.PreviousAvailableSize.IsEmpty ? Size.Infinity : element.PreviousAvailableSize);
                }

                arrangedElements.AddRange(arrangeQueue.SelectMany(element => GetElementPath(element)));

                while (arrangeQueue.Count > 0)
                {
                    UIElement element = GetTopElement(arrangeQueue);
                    element.Arrange(element.VisualParent == null || element.PreviousFinalRect.IsEmpty ? new Rect(element.DesiredSize) : element.PreviousFinalRect);
                }

                while (arrangedElements.Count > 0 && measureQueue.Count == 0 && arrangeQueue.Count == 0) // LayoutUpdated can invalidate other elements
                {
                    UIElement element = arrangedElements.First();
                    arrangedElements.Remove(element);

                    element.RaiseLayoutUpdated();
                }
            }
        }
开发者ID:diab0l,项目名称:Granular,代码行数:29,代码来源:LayoutManager.cs

示例7: GetAppAssembliesAsync

        /// <summary>
        /// Gets the application assemblies.
        /// </summary>
        /// <param name="assemblyFilter">(Optional) A filter for the assemblies.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// A promise of an enumeration of application assemblies.
        /// </returns>
        public virtual async Task<IEnumerable<Assembly>> GetAppAssembliesAsync(Func<AssemblyName, bool> assemblyFilter = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // TODO The assemblies from the current domain do not consider the not loaded
            // but required referenced assemblies. Therefore load all the references recursively.
            // This could be optimized somehow.
            var assemblies = this.GetLoadedAssemblies();

            assemblyFilter = assemblyFilter ?? this.AssemblyFilter;
            var loadedAssemblyRefs = new HashSet<string>(assemblies.Select(a => a.GetName().FullName));
            var assembliesToCheck = assemblies.Where(a => assemblyFilter(a.GetName())).ToList();

            while (assembliesToCheck.Count > 0)
            {
                var assemblyRefsToLoad = new HashSet<AssemblyName>();
                foreach (var assembly in assembliesToCheck)
                {
                    var referencesToLoad = this.GetReferencedAssemblies(assembly).Where(a => !loadedAssemblyRefs.Contains(a.FullName) && assemblyFilter(a));
                    assemblyRefsToLoad.AddRange(referencesToLoad);
                }

                loadedAssemblyRefs.AddRange(assemblyRefsToLoad.Select(an => an.FullName));
                assembliesToCheck = assemblyRefsToLoad.Select(this.AssemblyLoader.LoadAssembly).ToList();
                assemblies.AddRange(assembliesToCheck);
            }

            await this.AddAdditionalAssembliesAsync(assemblies, assemblyFilter, cancellationToken).PreserveThreadContext();
            return assemblies;
        }
开发者ID:raimu,项目名称:kephas,代码行数:36,代码来源:AppRuntimeBase.cs

示例8: GetAllAvailableLocalTextKeys

        public HashSet<string> GetAllAvailableLocalTextKeys()
        {
            var result = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

            foreach (var assembly in ExtensibilityHelper.SelfAssemblies)
            {
                foreach (NavigationItemAttribute attr in assembly.GetCustomAttributes(typeof(NavigationItemAttribute), false))
                    result.Add("Navigation." + (attr.Category.IsEmptyOrNull() ? "" : attr.Category + "/") + attr.Title);

                foreach (var type in assembly.GetTypes())
                {
                    var attr = type.GetCustomAttribute<FormScriptAttribute>();
                    if (attr != null)
                    {
                        foreach (var member in type.GetMembers(BindingFlags.Instance | BindingFlags.Public))
                        {
                            var category = member.GetCustomAttribute<CategoryAttribute>();
                            if (category != null && !category.Category.IsEmptyOrNull())
                                result.Add("Forms." + attr.Key + ".Categories." + category.Category);
                        }
                    }
                }
            }

            var repository = Dependency.Resolve<ILocalTextRegistry>() as LocalTextRegistry;
            if (repository != null)
                result.AddRange(repository.GetAllTextKeys(false));

            return result;
        }
开发者ID:cengkaplan33,项目名称:CoPro,代码行数:30,代码来源:TranslationRepository.cs

示例9: UpdateCompilerComboBox

		void UpdateCompilerComboBox()
		{
			if (listView.SelectedItems.Count > 0) {
				// Fetch list of available compiler versions
				HashSet<CompilerVersion> availableVersionsSet = new HashSet<CompilerVersion>();
				HashSet<CompilerVersion> currentVersions = new HashSet<CompilerVersion>();
				foreach (Entry entry in listView.SelectedItems) {
					if (entry.CompilerVersion != null)
						currentVersions.Add(entry.CompilerVersion);
					availableVersionsSet.AddRange(entry.Project.GetAvailableCompilerVersions());
				}
				List<CompilerVersion> availableVersions = availableVersionsSet.OrderBy(n => n.MSBuildVersion).ThenBy(n => n.DisplayName).ToList();
				if (currentVersions.Count != 1) {
					availableVersions.Insert(0, new UnchangedCompilerVersion());
				}
				// Assign available versions to newVersionComboBox
				// Unless the user has already chosen a version, automatically set the selection to the
				// current version of the chosen projects, or to 'do not change' if there are different
				// current versions.
				newCompilerSelectionChangingByCode = true;
				newVersionComboBox.ItemsSource = availableVersions;
				
				CompilerVersion oldSelectedVersion = newVersionComboBox.SelectedValue as CompilerVersion;
				if (!newCompilerSelectionSetByUser || oldSelectedVersion == null) {
					newCompilerSelectionSetByUser = false;
					if (currentVersions.Count == 1)
						newVersionComboBox.SelectedValue = currentVersions.Single();
					else
						newVersionComboBox.SelectedValue = new UnchangedCompilerVersion();
				}
				newCompilerSelectionChangingByCode = false;
				UpdateTargetFrameworkComboBox();
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:34,代码来源:UpgradeView.xaml.cs

示例10: ClientTypesGenerator

 static ClientTypesGenerator()
 {
     lookupEditorBaseOptions = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
     lookupEditorBaseOptions.AddRange(typeof(LookupEditorBaseAttribute)
         .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
         .Select(x => x.Name));
 }
开发者ID:CodeFork,项目名称:Serenity,代码行数:7,代码来源:ClientTypesGenerator.cs

示例11: FindDerivedClasses

		static void FindDerivedClasses(HashSet<IClass> resultList, IClass baseClass, IEnumerable<IProjectContent> projectContents, bool directDerivationOnly)
		{
			baseClass = baseClass.GetCompoundClass();
			string baseClassName = baseClass.Name;
			string baseClassFullName = baseClass.FullyQualifiedName;
			LoggingService.Debug("FindDerivedClasses for " + baseClassFullName);
			List<IClass> list = new List<IClass>();
			foreach (IProjectContent pc in projectContents) {
				if (pc != baseClass.ProjectContent && !pc.ReferencedContents.Contains(baseClass.ProjectContent)) {
					// only project contents referencing the content of the base class
					// can derive from the class
					continue;
				}
				AddDerivedClasses(pc, baseClass, baseClassName, baseClassFullName, pc.Classes, list);
			}
			if (directDerivationOnly) {
				resultList.AddRange(list);
			} else {
				foreach (IClass c in list) {
					if (resultList.Add(c)) {
						FindDerivedClasses(resultList, c, projectContents, directDerivationOnly);
					}
				}
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:25,代码来源:RefactoringService.cs

示例12: AddImportsAsync

        public async Task<Document> AddImportsAsync(Document document, IEnumerable<TextSpan> spans, OptionSet options, CancellationToken cancellationToken)
        {
            options = options ?? document.Project.Solution.Workspace.Options;

            var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
            var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);

            // Create a simple interval tree for simplification spans.
            var spansTree = new SimpleIntervalTree<TextSpan>(TextSpanIntervalIntrospector.Instance, spans);

            Func<SyntaxNodeOrToken, bool> isInSpan = (nodeOrToken) =>
                spansTree.GetOverlappingIntervals(nodeOrToken.FullSpan.Start, nodeOrToken.FullSpan.Length).Any();

            var nodesWithExplicitNamespaces = root.DescendantNodesAndSelf().Where(n => isInSpan(n) && GetExplicitNamespaceSymbol(n, model) != null).ToList();

            var namespacesToAdd = new HashSet<INamespaceSymbol>();
            namespacesToAdd.AddRange(nodesWithExplicitNamespaces.Select(n => GetExplicitNamespaceSymbol(n, model)));

            // annotate these nodes so they get simplified later
            var newRoot = root.ReplaceNodes(nodesWithExplicitNamespaces, (o, r) => r.WithAdditionalAnnotations(Simplifier.Annotation));
            var newDoc = document.WithSyntaxRoot(newRoot);
            var newModel = await newDoc.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            newRoot = await this.AddNamespaceImportsAsync(newDoc, newModel, options, namespacesToAdd, cancellationToken).ConfigureAwait(false);
            return document.WithSyntaxRoot(newRoot);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:26,代码来源:ImportAdderService.cs

示例13: Get

 public ActorId[] Get(ActorId id)
 {
     lock (creatorToOther)
     {
         var actors = new HashSet<ActorId>();
         List<ActorId> a;
         foreach (var alias in DnsAlias.Get(id))
         {
             if (creatorToOther.TryGetValue(alias, out a))
                 actors.AddRange(a);
             if (otherToCreator.TryGetValue(alias, out a))
                 actors.AddRange(a);
         }
         return actors.ToArray();
     }
 }
开发者ID:stangelandcl,项目名称:Actors,代码行数:16,代码来源:Link.cs

示例14: ExchangeInfoProvider

		/// <summary>
		/// Initializes a new instance of the <see cref="ExchangeInfoProvider"/>.
		/// </summary>
		/// <param name="entityRegistry">The storage of trade objects.</param>
		public ExchangeInfoProvider(IEntityRegistry entityRegistry)
		{
			if (entityRegistry == null)
				throw new ArgumentNullException(nameof(entityRegistry));

			ExchangeBoard.EnumerateExchanges().ForEach(exchange => _exchanges.Add(exchange.Name, exchange));
			ExchangeBoard.EnumerateExchangeBoards().ForEach(board => _boards.Add(board.Code, board));

			_entityRegistry = entityRegistry;

			var boardCodes = new HashSet<string>();

			var boardList = _entityRegistry.ExchangeBoards as ExchangeBoardList;
			boardCodes.AddRange(boardList != null ? boardList.GetIds() : _entityRegistry.ExchangeBoards.Select(b => b.Code));

			var boards = Boards.Where(b => !boardCodes.Contains(b.Code)).ToArray();

			if (boards.Length > 0)
			{
				boards
					.Select(b => b.Exchange)
					.Distinct()
					.ForEach(Save);

				boards
					.ForEach(Save);
			}

			_entityRegistry.Exchanges.ForEach(e => _exchanges[e.Name] = e);
			_entityRegistry.ExchangeBoards.ForEach(b => _boards[b.Code] = b);
		}
开发者ID:zjxbetter,项目名称:StockSharp,代码行数:35,代码来源:ExchangeInfoProvider.cs

示例15: AddRange_should_add_provided_values_to_target_Set

        public void AddRange_should_add_provided_values_to_target_Set()
        {
            var target = new HashSet<int>();    
            var source = new[] {1, 2, 3, 4, 5};
            target.AddRange(source);

            CollectionAssert.AreEquivalent(source, target);
        }
开发者ID:CallWall,项目名称:CallWall.Windows,代码行数:8,代码来源:SetExtensionsTests.cs


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