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; }
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); }
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); }
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; }
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)); } }
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(); } } }
/// <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; }
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; }
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(); } }
static ClientTypesGenerator() { lookupEditorBaseOptions = new HashSet<string>(StringComparer.OrdinalIgnoreCase); lookupEditorBaseOptions.AddRange(typeof(LookupEditorBaseAttribute) .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) .Select(x => x.Name)); }
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); } } } }
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); }
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(); } }
/// <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); }
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); }
/// <summary> /// Retrieves all of the document's siblings /// </summary> /// <param name="extended">The extended <see cref="XmlDocument"/></param> /// <returns>An <see cref="IEnumerable{T}"/> containing all the document's sibling <see cref="XmlNode"/>s</returns> public static IEnumerable<XmlNode> GetAllSiblings(this XmlDocument extended) { HashSet<XmlNode> siblings; siblings = new HashSet<XmlNode>(); siblings.Add(extended.FirstChild); siblings.AddRange(extended.FirstChild.GetAllSiblings()); return siblings; }
public VirtualRepository(IPackageRepository repo) { _packages = new HashSet<IPackage>(PackageEqualityComparer.IdAndVersion); if (repo != null) { _packages.AddRange(repo.GetPackages()); } }
/// <summary> /// Gets the runtime elements from the application assemblies. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// A promise of an enumeration of runtime elements. /// </returns> public async Task<IEnumerable<object>> GetRuntimeElementsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var assemblies = await this.appRuntime.GetAppAssembliesAsync(cancellationToken: cancellationToken).PreserveThreadContext(); var eligibleAssemblyPairs = (from kv in from a in assemblies select new KeyValuePair<Assembly, IList<ModelAssemblyAttribute>>( a, a.GetCustomAttributes<ModelAssemblyAttribute>().ToList()) where kv.Value.Count > 0 select kv).ToList(); var types = new HashSet<Type>(); foreach (var kv in eligibleAssemblyPairs) { var assembly = kv.Key; // first of all add all explicitely given types. var attrs = kv.Value; foreach (var attr in attrs.Where(attr => attr.ModelTypes != null && attr.ModelTypes.Length > 0)) { types.AddRange(attr.ModelTypes); } // then add the types indicated by their namespace. var allTypesAttribute = attrs.FirstOrDefault(a => a.ModelTypes == null && a.ModelNamespaces == null); if (allTypesAttribute != null) { // if no model types or namespaces are indicated, simply add all // exported types from the assembly with no further processing types.AddRange(assembly.GetLoadableExportedTypes()); } else { // add only the types from the provided namespaces var allTypes = assembly.GetLoadableExportedTypes().ToList(); var namespaces = new HashSet<string>(attrs.Where(a => a.ModelNamespaces != null && a.ModelNamespaces.Length > 0).SelectMany(a => a.ModelNamespaces)); var namespacePatterns = namespaces.Select(n => n + ".").ToList(); types.AddRange(allTypes.Where(t => namespaces.Contains(t.Namespace) || namespacePatterns.Any(p => t.Namespace.StartsWith(p)))); } } return types; }
public void Run() { ITypeWeaver bulkWeaving = null; var compositesQueue = new Queue<ITypeWeaver>(); AspectsAttributeWeaver aspectRepository = null; AspectArgsMapperWeaver aspectArgsMapperWeaver = null; var aspectDefinitionsTypeSet = new HashSet<Type>(); var composites = typeFactory.Types.Select(type => new { Type = type, Attributes = type.GetCustomAttributesArray<CompositeAttribute>() }) .Where(composite => composite.Attributes.Length > 0); var compositeWeavingSettings = composites.ToList(composite => { var compositeType = composite.Type; var mixinsMap = new MixinsMap(compositeType); var aspectMappedMembers = new AspectMemberMapper(compositeType, mixinsMap); var aspectsMap = new AspectsMap(aspectMappedMembers); var aspectDefinitionsTypes = aspectsMap.SelectMany(aspectMap => { return aspectMap.Aspects.Select(aspectDefinition => { return aspectDefinition.Aspect.AspectType; }); }); aspectDefinitionsTypeSet.AddRange(aspectDefinitionsTypes); return new CompositeWeavingSettingsImpl { Registry = registry, MixinsMap = mixinsMap, AspectsMap = aspectsMap, CompositeType = compositeType, AspectMemebrsCollection = aspectMappedMembers }; }); aspectArgsMapperWeaver = new AspectArgsMapperWeaver(); aspectRepository = new AspectsAttributeWeaver(aspectDefinitionsTypeSet); compositesQueue.Enqueue(aspectArgsMapperWeaver); compositesQueue.Enqueue(aspectRepository); compositeWeavingSettings.ForEach(compositeSettings => { IBuilder<ITypeWeaver> builder = null; compositeSettings.AspectRepository = aspectRepository; compositeSettings.AspectArgsMapper = aspectArgsMapperWeaver; builder = new CompositeTypeWeaverBuilder(compositeSettings); compositesQueue.Enqueue(builder.Build()); }); bulkWeaving = new BulkWeaving(compositesQueue); bulkWeaving.Weave(); }
/// <summary> /// Tokenize the specified string value. /// </summary> /// <returns> /// Returns string list which will contain only the unique word tokens in lower case which have >= 2 length from initial value. /// The resulting tokens also will be sorted. /// </returns> /// <param name="value">String value.</param> public static List<string> Tokenize(this string value) { if (value == null) return null; var tokens = stringTokenizer.Split(value); HashSet<string> uniqueTokens = new HashSet<string>(); uniqueTokens.AddRange(tokens.Where(t => t.Length >= 2).Select(t => t.ToLower())); var sorted = uniqueTokens.ToList(); sorted.Sort(); return sorted; }
//Validate that the we are using valid colors and set appropriate defaults if not. private void CheckForInvalidColorData() { HashSet<Color> validColors = new HashSet<Color>(); validColors.AddRange(TargetNodes.SelectMany(x => ColorModule.getValidColorsForElementNode(x, true))); if (validColors.Any() && (!validColors.Contains(_data.StaticColor) || !_data.ColorGradient.GetColorsInGradient().IsSubsetOf(validColors))) //Discrete colors specified { _data.ColorGradient = new ColorGradient(validColors.DefaultIfEmpty(Color.White).First()); _data.StaticColor = validColors.First(); } }
private IEnumerable<string> GetReferencedAssemblyPaths(IList<FilePathAbsolute> projects) { var list = new HashSet<string>(projects.AsStrings()); foreach (var binDir in projects.Select(p => p.ParentDirectoryPath)) { var files = Directory.EnumerateFiles(binDir.Path, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".dll") || s.EndsWith(".pdb")) .Where(p => !projects.Contains(p.ToFilePathAbs())); list.AddRange(files); } return list; }
/// <summary> /// Gets the historical data for specified symbol in format like KC, CC etc; /// </summary> public IEnumerable<Quote> GetWeeklyData(string symbol) { var quotes = new HashSet<Quote>(); var contractSpecification = ContractSpecification.Data.First(d => d.Symbol == symbol); var yearlyCodes = GetExpirationMonths(contractSpecification); foreach (var code in yearlyCodes) { OnDownload(code); quotes.AddRange(_robot.GetHistoricalData(code, Period.Weekly, BarChartProxy.FrameSize.Largest)); } return new List<Quote>(quotes).OrderBy(d => d.DateTime); }
public ICollection<Number640> Evaluate1(IDictionary<PeerAddress, IDictionary<Number640, Number160>> rawKeys) { var result = new HashSet<Number640>(); if (rawKeys != null) { foreach (var dictionary in rawKeys.Values) { result.AddRange(dictionary.Keys); } } return result; }
public static HashSet<Color> GetDiscreteColors(object component) { var validColors = new HashSet<Color>(); if (component is IEffect) { var effect = (IEffect)component; validColors.AddRange(effect.TargetNodes.SelectMany(x => ColorModule.getValidColorsForElementNode(x, true))); } else if (component is Array) { foreach (var item in (Array)component) { if (item is IEffect) { var effect = (IEffect)item; validColors.AddRange(effect.TargetNodes.SelectMany(x => ColorModule.getValidColorsForElementNode(x, true))); } } } return validColors; }
/// <summary> /// Retrieves all the siblings of the specified <see cref="XmlNode"/> /// </summary> /// <param name="extended">The extended <see cref="XmlNode"/></param> /// <returns>An <see cref="IEnumerable{T}"/> containing all of the <see cref="XmlNode"/> siblings</returns> public static IEnumerable<XmlNode> GetAllSiblings(this XmlNode extended) { HashSet<XmlNode> siblings; siblings = new HashSet<XmlNode>(); if(extended.ChildNodes != null) { foreach (XmlNode node in extended.ChildNodes) { siblings.Add(node); siblings.AddRange(node.ChildNodes); } } return siblings; }
public override void ExecuteCommand() { WithMasterConnection((connection, db) => { // Get the list of backups var backups = db.Query<Db>( "SELECT name, state FROM sys.databases WHERE name LIKE 'WarehouseBackup_%'", new { state = Util.OnlineState }) .Select(d => new OnlineDatabaseBackup(Util.GetDatabaseServerName(ConnectionString), d.Name, d.State)) .OrderByDescending(b => b.Timestamp) .ToList(); // Any currently copying are safe var keepers = new HashSet<string>(); keepers.AddRange(backups.Where(b => b.State == Util.CopyingState).Select(b => b.DatabaseName)); // The last online database is safe keepers.AddRange(backups .Where(b => b.State == Util.OnlineState && b.Timestamp != null) .OrderByDescending(d => d.Timestamp.Value) .Select(b => b.DatabaseName) .Take(1)); // Figure out how many we're keeping Log.Info("Keeping the following Backups: {0}", String.Join(", ", keepers)); // Done! Delete the non-keepers foreach (var backup in backups.Where(b => !keepers.Contains(b.DatabaseName))) { if (!WhatIf) { db.Execute("DROP DATABASE " + backup.DatabaseName); } Log.Info("Deleted {0}", backup.DatabaseName); } }); }
public static int Answer() { int max = 28123; var range = Enumerable.Range(1, max).ToList(); var abundantNumbers = range.Where(i => i.IsAbundant()).ToList(); var abundantSums = new HashSet<int>(); abundantSums.AddRange(from a in abundantNumbers from b in abundantNumbers select a + b); return range .Where(i => !abundantSums.Contains(i)) .Sum(); }
public HgBundle BuildBundle(HgRepository hgRepository, HgRevset hgRevset) { log.Debug("bundling changelog"); var paths = new HashSet<string>(); var changelog = BuildChangesetBundleGroup(hgRepository, hgRevset, hc => paths.AddRange(hc.Files)); log.Debug("bundling manifests"); var manifest = BuildManifestBundleGroup(hgRepository, hgRevset); // // List of all files that ever were tracked log.Debug("bundling filelogs"); var files = BuildBundleFiles(hgRepository, hgRevset, paths); var hgBundle = new HgBundle(changelog, manifest, files); return hgBundle; }
/// <summary> /// Tokenize the specified string values. /// </summary> /// <returns> /// Returns string list which will contain only the unique word tokens in lower case from each of the initial string values. /// The resulting tokens also will be sorted. /// </returns> /// <param name="values">Values.</param> public static List<string> Tokenize(this IEnumerable<string> values) { if (values == null) return null; HashSet<string> uniqueTokens = new HashSet<string>(); foreach (var value in values) { if (value != null) { var tokens = Tokenize(value); uniqueTokens.AddRange(tokens); } } var sorted = uniqueTokens.ToList(); sorted.Sort(); return sorted; }