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


C# Dictionary.Union方法代码示例

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


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

示例1: UnionDefaultEqualityComparer_SameKeyDifferentValues_Throws

        public void UnionDefaultEqualityComparer_SameKeyDifferentValues_Throws()
        {
            var first = new Dictionary<int, int> { { 2, 3 }, { 3, 5 }, { 6, 4 } };
            var second = new SortedList<int, int> { { 3, 2 }, { 6, 4 } };

            var actual = first.Union(second, EqualityComparer<KeyValuePair<int, int>>.Default);
        }
开发者ID:cureos,项目名称:dictionarylinq,代码行数:7,代码来源:UnionTests.cs

示例2: ARPScan

        static void ARPScan(ScanOptions options)
        {
            Dictionary<IPAddress, List<ArpEntry>> results = new Dictionary<IPAddress, List<ArpEntry>>();

            IEnumerable<string> targets;

            if (options.FromFile)
            {
                List<string> targetList = new List<string>();
                foreach (string filename in options.StringSeq)
                {
                    using (System.IO.TextReader r = System.IO.File.OpenText(filename))
                    {
                        string s = String.Empty;
                        while ((s = r.ReadLine()) != null)
                        {
                            string[] separators = options.separator == "" ?
                                new string[] { System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ListSeparator } :
                                new string[] { options.separator };
                            string[] lineElts = s.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                            if(lineElts.Length == 1) //IP only
                            {
                                targetList.Add(lineElts[0]);
                            }
                            else if (lineElts.Length == 2) //Target name,IP
                            {
                                targetList.Add(lineElts[1]);
                            }
                        }
                    }
                }
                targets = targetList;
            }
            else
            {
                targets = options.StringSeq;
            }

            foreach (string target in targets)
            {
                Dictionary<IPAddress, List<ArpEntry>> scanresult = ScanTarget(target, options);
                results = results.Union(scanresult).ToDictionary(k => k.Key, v => v.Value);
            }

            if (options.OutputFileName != "")
            {
                OutputToCSV(results, options);
            }
            else
            {
                foreach (IPAddress ipaddr in results.Keys)
                {
                    foreach (ArpEntry entry in results[ipaddr])
                        Console.WriteLine("On {0}, IP {1} : MAC {2}", ipaddr, entry.ipEntry.AddressList[0], entry.physAddress);
                }
                Console.ReadLine();
            }
        }
开发者ID:jeremygibbons,项目名称:SnmpArpScanner,代码行数:58,代码来源:Program.cs

示例3: UnionNoEqualityComparer_SameKeyInSecondDict_TakesDuplicateKeyValuePair

        public void UnionNoEqualityComparer_SameKeyInSecondDict_TakesDuplicateKeyValuePair()
        {
            var first = new Dictionary<int, int> { { 2, 3 }, { 3, 5 }, { 6, 4 } };
            var second = new SortedList<int, int> { { 3, 2 }, { 4, 7 } };

            var expected = 4;
            var actual = first.Union(second).Count;
            Assert.AreEqual(expected, actual);
        }
开发者ID:cureos,项目名称:dictionarylinq,代码行数:9,代码来源:UnionTests.cs

示例4: Insert

 public Dictionary<string, object> Insert(string tableName, Dictionary<string, object> row)
 {
     var allRows = _getTable(tableName);
     var keys = _getKeys(tableName, row, allRows);
     var prepedRow = row.Union(keys);
     var toWrite = allRows.And(prepedRow);
     _writeTable(tableName, toWrite);
     return keys;
 }
开发者ID:badjer,项目名称:Lasy,代码行数:9,代码来源:JsonDB.cs

示例5: ReadTestDurations

 public IDictionary<TestCase, int> ReadTestDurations(IEnumerable<TestCase> testcases)
 {
     IDictionary<string, List<TestCase>> groupedTestcases = testcases.GroupByExecutable();
     var durations = new Dictionary<TestCase, int>();
     foreach (string executable in groupedTestcases.Keys)
     {
         durations = durations.Union(ReadTestDurations(executable, groupedTestcases[executable])).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
     }
     return durations;
 }
开发者ID:csoltenborn,项目名称:GoogleTestAdapter,代码行数:10,代码来源:TestDurationSerializer.cs

示例6: MatrixPetriNet

 public MatrixPetriNet(string id,
     Dictionary<int, string> placeNames,
     Dictionary<int, string> transitionNames,
     Dictionary<int, List<InArc>> inArcs,
     Dictionary<int, List<OutArc>> outArcs,
     Dictionary<int, int> transitionOrdering)
     : this(id, placeNames, transitionNames, inArcs, outArcs)
 {
     var x = transitionNames.Select(t => t.Key).Except(transitionOrdering.Select(t => t.Key));
     var y = transitionOrdering.Union(x.ToDictionary(t => t, t => 0)); // baseline priority level
     TransitionPriorities = y.ToDictionary(a => a.Key, a => a.Value);
 }
开发者ID:aabs,项目名称:PetriNets,代码行数:12,代码来源:MatrixPetriNet.cs

示例7: LoadAffixes

 public static void LoadAffixes(string languageCode)
 {
     string json = File.ReadAllText(string.Format(@"data\affixes.{0}.json", languageCode));
     affixMatches = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
     json = File.ReadAllText(string.Format(@"data\strings.{0}.json", languageCode));
     var strings = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(json);
     ItemQualities = strings["ItemQualities"];
     WeaponTypes = strings["WeaponTypes"];
     OffHandTypes = strings["OffHandTypes"];
     FollowerTypes = strings["FollowerTypes"];
     CommonTypes = strings["CommonTypes"];
     ItemTypes = WeaponTypes.Union(OffHandTypes).Union(CommonTypes).ToDictionary(a => a.Key, b => b.Value);
 }
开发者ID:CreepGin,项目名称:D3Bit,代码行数:13,代码来源:Data.cs

示例8: AuditActionMapper

        static AuditActionMapper()
        {
            actions = new Dictionary<MessageAction, MessageMaps>();

            actions = actions
                .Union(LoginActionsMapper.GetMaps())
                .Union(ProjectsActionsMapper.GetMaps())
                .Union(CrmActionMapper.GetMaps())
                .Union(PeopleActionMapper.GetMaps())
                .Union(DocumentsActionMapper.GetMaps())
                .Union(SettingsActionsMapper.GetMaps())
                .ToDictionary(x => x.Key, x => x.Value);
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:13,代码来源:AuditActionMapper.cs

示例9: Ensure

 /// <summary>
 /// Inserts the row if it doesn't exist, update the row(s) if they do
 /// </summary>
 /// <param name="readWrite"></param>
 /// <param name="tablename"></param>
 /// <param name="dataFields"></param>
 /// <param name="keyFields"></param>
 /// <param name="trans"></param>
 public static void Ensure(this IReadWrite readWrite,
     string tablename,
     Dictionary<string, object> dataFields,
     Dictionary<string, object> keyFields)
 {
     // See if the keyFields exist
     // If so, update them, otherwise insert them
     var existing = readWrite.Read(tablename, keyFields);
     if (existing.Any())
         readWrite.Update(tablename, dataFields, keyFields);
     else
     {
         var newRow = dataFields.Union(keyFields);
         var newKeys = readWrite.Insert(tablename, newRow);
     }
 }
开发者ID:badjer,项目名称:Lasy,代码行数:24,代码来源:IReadWrite.cs

示例10: GetCustomVariablesAsync

        public async Task<ActionResult> GetCustomVariablesAsync()
        {
            var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true);

            var model = new Dictionary<string, string>();
            var iType = typeof(ICustomJavascriptVariable);
            var members = iType.GetTypeMembers<ICustomJavascriptVariable>();

            foreach (var member in members)
            {
                var items = await member.GetAsync(this.Tenant, meta.OfficeId).ConfigureAwait(true);
                model = model.Union(items).ToDictionary(k => k.Key, v => v.Value);
            }


            return this.Ok(model);
        }
开发者ID:frapid,项目名称:frapid,代码行数:17,代码来源:DefaultController.cs

示例11: GetEntries

        public IReadOnlyCollection<RCompletion> GetEntries(RCompletionContext context) {
            List<RCompletion> completions = new List<RCompletion>();
            ImageSource functionGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupValueType, StandardGlyphItem.GlyphItemPublic);

            // Safety checks
            FunctionCall funcCall = context.AstRoot.GetNodeOfTypeFromPosition<FunctionCall>(context.Position);
            if (funcCall == null || funcCall.OpenBrace == null || funcCall.Arguments == null) {
                return completions;
            }

            if (context.Position < funcCall.OpenBrace.End || context.Position >= funcCall.SignatureEnd) {
                return completions;
            }

            // Retrieve parameter positions from the current text buffer snapshot
            ParameterInfo parametersInfo = SignatureHelp.GetParametersInfoFromBuffer(context.AstRoot, context.TextBuffer.CurrentSnapshot, context.Position);
            if (parametersInfo == null) {
                return completions;
            }

            // Get collection of function signatures from documentation (parsed RD file)
            IFunctionInfo functionInfo = FunctionIndex.GetFunctionInfo(parametersInfo.FunctionName, o => { }, context.Session.TextView);
            if (functionInfo == null) {
                return completions;
            }

            // Collect parameter names from all signatures
            IEnumerable<KeyValuePair<string, IArgumentInfo>> arguments = new Dictionary<string, IArgumentInfo>();
            foreach (ISignatureInfo signature in functionInfo.Signatures) {
                var args = signature.Arguments.ToDictionary(x => x.Name);
                arguments = arguments.Union(args);
            }

            // Add names of arguments that  are not yet specified to the completion
            // list with '=' sign so user can tell them from function names.
            IEnumerable<string> declaredArguments = funcCall.Arguments.Where(x => x is NamedArgument).Select(x => ((NamedArgument)x).Name);
            IEnumerable<KeyValuePair<string, IArgumentInfo>> possibleArguments = arguments.Where(x => x.Key != "..." && !declaredArguments.Contains(x.Key));

            foreach (KeyValuePair<string, IArgumentInfo> arg in possibleArguments) {
                string displayText = arg.Key + " =";
                string insertionText = arg.Key + " = ";
                completions.Add(new RCompletion(displayText, insertionText, arg.Value.Description, functionGlyph));
            }

            return completions;
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:46,代码来源:ParameterNameCompletionProvider.cs

示例12: Generate__GeneratedProperly

        public void Generate__GeneratedProperly()
        {
            // Prepare expected results
            var joinedModels = new Dictionary<string, string> {
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.CustomerFirstName), "Customer.FirstName" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.CustomerLastName), "Customer.LastName" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.CustomerFingersCount), "Customer.FingersCount" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.CustomerHairLength), "Customer.HairLength" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.CustomerPreviousSurgeryDate), "Customer.PreviousSurgeryDate" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.CustomerType), "Customer.Type" },
            };

            var components = new Dictionary<string, string> {
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.PaymentInfoOrderedDate), "PaymentInfo.OrderedDate" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.PaymentInfoState), "PaymentInfo.State" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.PaymentInfoDouble), "PaymentInfo.Double" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.PaymentInfoExternalPaymentId), "PaymentInfo.ExternalPaymentId" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.PaymentInfoNumber), "PaymentInfo.Number" },
            };

            var simpleProps = new Dictionary<string, string> {
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.Id), "Id" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.Type), "Type" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.OrderDate), "OrderDate" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.TotalPrice), "TotalPrice" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.Note), "Note" },
                { ObjectHelper.GetPropertyName<OrderGridModel>(v => v.ItemsCount), "ItemsCount" },
            };

            var allProps = joinedModels.Union(components).Union(simpleProps).ToDictionary(x => x.Key, x => x.Value);

            // ACT
            var modelDescription = GetTestModelDescription();
            var map = ViewModelToPersistenceModelPropertyNamesMapsGenerator.Generate(typeof(OrderGridModel), modelDescription);

            // ASSERT
            map.Should(Be.Not.Null);
            map.AllProperties.Count.Should(Be.EqualTo(17));
            map.AllProperties.Should(Be.EquivalentTo(allProps));
        }
开发者ID:dwdkls,项目名称:pizzamvc,代码行数:40,代码来源:ViewModelToPersistenceModelPropertyNamesMapsGeneratorTests.cs

示例13: Page_Init

        protected void Page_Init(object sender, EventArgs e)
        {
            changeableOptions = new Dictionary<CheckBox, OptionView>()
            {
                { cbNotasAndQuarterlyReportsByPost,  new OptionView { Category = SendableDocumentCategories.NotasAndQuarterlyReports,
                                                                      Option   = SendingOptions.ByPost } },

                { cbNotasAndQuarterlyReportsByEmail, new OptionView { Category = SendableDocumentCategories.NotasAndQuarterlyReports,
                                                                      Option   = SendingOptions.ByEmail } }
            };

            nonChangeableOptions = new Dictionary<CheckBox, OptionView>()
            {
                { cbYearlyReportsByPost,             new OptionView { Category = SendableDocumentCategories.YearlyReports,
                                                                      Option   = SendingOptions.ByPost } },

                { cbYearlyReportsByEmail,            new OptionView { Category = SendableDocumentCategories.YearlyReports,
                                                                      Option   = SendingOptions.ByEmail } }
            };

            allOptions = changeableOptions.Union(nonChangeableOptions).ToDictionary(pair => pair.Key, pair => pair.Value);
        }
开发者ID:kiquenet,项目名称:B4F,代码行数:22,代码来源:Settings.aspx.cs

示例14: GetPossibleValues

        public static MultiSelectList GetPossibleValues(
            this PropertyValue propertyValue,
            bool addChooseItem = true)
        {
            if (propertyValue.Property.IsForeignKey)
            {
                var options = new Dictionary<string, string>();

                if (addChooseItem)
                {
                    options.Add(String.Empty, IlaroAdminResources.Choose);
                }
                options = options.Union(propertyValue.PossibleValues).ToDictionary(x => x.Key, x => x.Value);

                return propertyValue.Property.TypeInfo.IsCollection ?
                    new MultiSelectList(options, "Key", "Value", propertyValue.Values) :
                    new SelectList(options, "Key", "Value", propertyValue.AsString);
            }
            else
            {
                var options = addChooseItem ?
                    propertyValue.Property.TypeInfo.EnumType.GetOptions(String.Empty, IlaroAdminResources.Choose) :
                    propertyValue.Property.TypeInfo.EnumType.GetOptions();

                if (propertyValue.Property.TypeInfo.IsEnum)
                {
                    return new SelectList(
                        options,
                        "Key",
                        "Value",
                        propertyValue.AsObject);
                }

                return new SelectList(options, "Key", "Value", propertyValue.AsString);
            }
        }
开发者ID:rgonek,项目名称:Ilaro.Admin,代码行数:36,代码来源:PropertyExtensions.cs

示例15: GetEntries

        public IReadOnlyCollection<RCompletion> GetEntries(RCompletionContext context) {
            List<RCompletion> completions = new List<RCompletion>();
            FunctionCall funcCall;
            ImageSource functionGlyph = _glyphService.GetGlyphThreadSafe(StandardGlyphGroup.GlyphGroupValueType, StandardGlyphItem.GlyphItemPublic);

            // Safety checks
            if (!ShouldProvideCompletions(context, out funcCall)) {
                return completions;
            }

            // Get collection of function signatures from documentation (parsed RD file)
            IFunctionInfo functionInfo = GetFunctionInfo(context);
            if (functionInfo == null) {
                return completions;
            }

            // Collect parameter names from all signatures
            IEnumerable<KeyValuePair<string, IArgumentInfo>> arguments = new Dictionary<string, IArgumentInfo>();
            foreach (ISignatureInfo signature in functionInfo.Signatures) {
                var args = signature.Arguments.ToDictionary(x => x.Name);
                arguments = arguments.Union(args);
            }

            // Add names of arguments that  are not yet specified to the completion
            // list with '=' sign so user can tell them from function names.
            IEnumerable<string> declaredArguments = funcCall.Arguments.Where(x => x is NamedArgument).Select(x => ((NamedArgument)x).Name);
            var possibleArguments = arguments.Where(x => !x.Key.EqualsOrdinal("...") && !declaredArguments.Contains(x.Key, StringComparer.OrdinalIgnoreCase));

            foreach (var arg in possibleArguments) {
                string displayText = arg.Key + " =";
                string insertionText = arg.Key + " = ";
                completions.Add(new RCompletion(displayText, insertionText, arg.Value.Description, functionGlyph));
            }

            return completions;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:36,代码来源:ParameterNameCompletionProvider.cs


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