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


C# Dictionary.Except方法代码示例

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


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

示例1: Except

        public void Except()
        {
            var dict = new Dictionary<int, string>();
            dict.Add(1, "one");
            dict.Add(2, "two");
            dict.Add(3, "three");

            Assert.AreEqual("([1,one],[2,two])", dict.Except(3).Print());
            Assert.AreEqual("([2,two])", dict.Except(1, 3).Print());
            Assert.AreEqual("([1,one],[2,two],[3,three])", dict.Except(57).Print());
        }
开发者ID:weima,项目名称:Nvelope,代码行数:11,代码来源:DictionaryExtensionTests.cs

示例2: OnPostprocessAllAssets

        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPaths)
        {
            string[] created = importedAssets.Except (Watcher.allAssets).ToArray ();
            string[] modified = importedAssets.Except (created).ToArray ();

            Dictionary<string, string> allMoved = new Dictionary<string, string> ();
            for (int i = 0; i < movedAssets.Length; i++) {
                allMoved.Add (movedAssets [i], movedFromPaths [i]);
            }

            // Renamed to, renamed from
            Dictionary<string, string> renamed =
                (from m in allMoved
                 where (Path.GetDirectoryName (m.Key)) == (Path.GetDirectoryName (m.Value))
                 select m).ToDictionary (p => p.Key, p => p.Value);

            Dictionary<string, string> moved = allMoved.Except (renamed).ToDictionary (p => p.Key, p => p.Value);

            // Dispatch asset events to available watchers
            foreach (Watcher w in Watcher.allWatchers) {
                w.InvokeEventForPaths (created, w.onAssetCreated);
                w.InvokeEventForPaths (deletedAssets, w.onAssetDeleted);
                w.InvokeEventForPaths (modified, w.onAssetModified);
                w.InvokeMovedEventForPaths (renamed, w.onAssetRenamed);
                w.InvokeMovedEventForPaths (moved, w.onAssetMoved);
            }

            // Update asset paths cache
            Watcher.allAssets = AssetDatabase.GetAllAssetPaths ();
        }
开发者ID:mstevenson,项目名称:AssetsWatcher,代码行数:30,代码来源:WatcherPostprocessor.cs

示例3: TestMethod2

        public void TestMethod2()
        {
            var dictionary = new Dictionary<string, int>();

            WordCounter text = new WordCounter(string.Empty);
            text.Count();
            Assert.IsTrue(!dictionary.Except(text.GetDictionary()).Any(), "Error");
        }
开发者ID:Sniti,项目名称:GitHubVS2013,代码行数:8,代码来源:WordCounterTest.cs

示例4: ExceptNoEqualityComparer_SameKeyInSecondDict_RemovesDuplicateKeyValuePair

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

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

示例5: ExceptDefaultEqualityComparer_SameKeyDifferentValues_KeepsKeyValuePairWithMatchingKey

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

            var expected = 2;
            var actual = first.Except(second, EqualityComparer<KeyValuePair<int, int>>.Default).Count;
            Assert.AreEqual(expected, actual);
        }
开发者ID:cureos,项目名称:dictionarylinq,代码行数:9,代码来源:ExceptTests.cs

示例6: GetFieldTypes

        public Dictionary<string, SqlColumnType> GetFieldTypes(string tablename, Dictionary<string, object> example)
        {
            if (!TableExists(tablename))
                return null;

            var types = _items.First(i => i.Name == tablename).Types;
            var extras = example.Except(types.Keys).SelectVals(v => SqlTypeConversion.GetSqlType(v));
            var res = extras.Union(types);
            return res;
        }
开发者ID:badjer,项目名称:Lasy,代码行数:10,代码来源:ObjectAnalyzer.cs

示例7: TestMethod3

        public void TestMethod3()
        {
            var dictionary = new Dictionary<string, int>
                              {
                                  { "123", 2 },
                                  { "21312", 1 },
                                  { "2452", 1 }
                              };

            WordCounter text = new WordCounter("21312 2452 123 123!!$$%#$^&$%");
            text.Count();
            Assert.IsTrue(!dictionary.Except(text.GetDictionary()).Any(), "Error");
        }
开发者ID:Sniti,项目名称:GitHubVS2013,代码行数:13,代码来源:WordCounterTest.cs

示例8: CreateTable

        public static void CreateTable(this IDBModifier meta, string tablename, Dictionary<string, object> instance)
        {
            var taxonomyTypes = meta.Taxonomy == null ?
                new Dictionary<string, SqlColumnType>() :
                meta.Taxonomy.GetFieldTypes(tablename, instance);

            taxonomyTypes = taxonomyTypes ?? new Dictionary<string, SqlColumnType>();

            var missingTypes = instance.Except(taxonomyTypes.Keys)
                .SelectVals(v => SqlTypeConversion.GetSqlType(v));

            var fieldTypes = missingTypes.Union(taxonomyTypes);

            meta.CreateTable(tablename, fieldTypes);
        }
开发者ID:badjer,项目名称:Lasy,代码行数:15,代码来源:IDBModifier.cs

示例9: _getCreateTableSql

        public override string _getCreateTableSql(string schema, string table, Dictionary<string, SqlColumnType> fieldTypes)
        {
            // Strip off the primary key if it was supplied in fields - we'll make it ourselves
            var datafields = fieldTypes.Except(table + "Id");
            var fieldList = _fieldDefinitions(datafields);

            var sql = String.Format(@"CREATE TABLE `{1}`
            (
                {1}Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
                {2}
            )",
               schema, table, fieldList);

            return sql;
        }
开发者ID:badjer,项目名称:Lasy,代码行数:15,代码来源:MySqlModifier.cs

示例10: TestMethod1

        public void TestMethod1()
        {
            var dictionary = new Dictionary<string, int>
                              {
                                  { "is", 2 },
                                  { "this", 2 },
                                  { "a", 1 },
                                  { "and", 1 },
                                  { "so", 1 },
                                  { "statement", 1 }
                              };

            WordCounter text = new WordCounter("This is a statement, and so is this.");
            text.Count();
            Assert.IsTrue(!dictionary.Except(text.GetDictionary()).Any(), "Error");
        }
开发者ID:Sniti,项目名称:GitHubVS2013,代码行数:16,代码来源:WordCounterTest.cs

示例11: SplitByRack

 private void SplitByRack(Dictionary<int, int> smpPlasmaSlices)
 {
     int totalSliceCnt = smpPlasmaSlices.Count;
     while (smpPlasmaSlices.Any())
     {
         int remaining = smpPlasmaSlices.Count;
         int splitted = totalSliceCnt - remaining;
         var tmpPlasmaSlices = smpPlasmaSlices.Take(Math.Min(remaining, 16)).ToDictionary(x => x.Key, x => x.Value);
         allRackSmpPlasmaSlices.Add(tmpPlasmaSlices);
         var tmpPackageInfos = CreatePackInfo(tmpPlasmaSlices);
         allPackageExpectedInfos.Add(new Dictionary<Point, string>(tmpPackageInfos));
         allPackageScannedInfos.Add(new Dictionary<Point, string>());
         smpPlasmaSlices = smpPlasmaSlices.Except(tmpPlasmaSlices).ToDictionary(x => x.Key, x => x.Value);
     }
     ChangeRackIndex(0);
 }
开发者ID:zhoukongjava,项目名称:Biobanking,代码行数:16,代码来源:Barcodes.cs

示例12: _getCreateTableSql

        /// <summary>
        /// 
        /// </summary>
        /// <param name="schema"></param>
        /// <param name="table"></param>
        /// <param name="fieldTypes">A mapping of the fieldname to .NET type of the fields</param>
        /// <returns></returns>
        public virtual string _getCreateTableSql(string schema, string table, Dictionary<string, SqlColumnType> fieldTypes)
        {
            // Strip off the primary key if it was supplied in fields - we'll make it ourselves
            var datafields = fieldTypes.Except(table + "Id");
            var fieldList = _fieldDefinitions(datafields);

            var sql = String.Format(@"CREATE TABLE [{0}].[{1}]
            (
                {1}Id int NOT NULL IDENTITY (1,1) PRIMARY KEY,
                {2}
            ) ON [PRIMARY]",
               schema, table, fieldList);

            return sql;
        }
开发者ID:badjer,项目名称:Lasy,代码行数:22,代码来源:SqlModifier.cs

示例13: GetInternalKeys

        public void GetInternalKeys()
        {
            downloader.Pages["http://myhost:222/api/rules/search?f=internalKey&ps=" + int.MaxValue + "&repositories=fxcop"] = "{\"total\":2,\"p\":1,\"ps\":10,\"rules\":[{\"key\":\"fxcop:My_Own_FxCop_Rule\"},{\"key\":\"fxcop:UriParametersShouldNotBeStrings\",\"internalKey\":\"CA1054\"}]}";
            var expected = new Dictionary<string, string>();
            expected["fxcop:UriParametersShouldNotBeStrings"] = "CA1054";
            var actual = ws.GetInternalKeys("fxcop");

            Assert.AreEqual(true, expected.Count == actual.Count && !expected.Except(actual).Any());
        }
开发者ID:Rinorragi,项目名称:sonar-msbuild-runner,代码行数:9,代码来源:SonarWebServiceTest.cs

示例14: GetProperties

        public void GetProperties()
        {
            // This test includes a regression scenario for SONARMSBRU-187:
            // Requesting properties for project:branch should return branch-specific data

            // Check that properties are correctly defaulted as well as branch-specific
            downloader.Pages["http://myhost:222/api/properties?resource=foo+bar"] = "[{\"key\": \"sonar.property1\",\"value\": \"value1\"},{\"key\": \"sonar.property2\",\"value\": \"value2\"}]";
            downloader.Pages["http://myhost:222/api/properties?resource=foo+bar%3AaBranch"] = "[{\"key\": \"sonar.property1\",\"value\": \"anotherValue1\"},{\"key\": \"sonar.property2\",\"value\": \"anotherValue2\"}]";

            // default
            var expected1 = new Dictionary<string, string>();
            expected1["sonar.property1"] = "value1";
            expected1["sonar.property2"] = "value2";
            expected1["sonar.cs.msbuild.testProjectPattern"] = SonarProperties.DefaultTestProjectPattern;
            var actual1 = ws.GetProperties("foo bar");

            Assert.AreEqual(true, expected1.Count == actual1.Count && !expected1.Except(actual1).Any());

            // branch specific
            var expected2 = new Dictionary<string, string>();
            expected2["sonar.property1"] = "anotherValue1";
            expected2["sonar.property2"] = "anotherValue2";
            expected2["sonar.cs.msbuild.testProjectPattern"] = SonarProperties.DefaultTestProjectPattern;
            var actual2 = ws.GetProperties("foo bar", "aBranch");

            Assert.AreEqual(true, expected2.Count == actual2.Count && !expected2.Except(actual2).Any());
        }
开发者ID:Rinorragi,项目名称:sonar-msbuild-runner,代码行数:27,代码来源:SonarWebServiceTest.cs

示例15: TC13_VerifyDrainWashStepFunctionality

 public void TC13_VerifyDrainWashStepFunctionality()
 {
     Thread.Sleep(2000);
     if (Page.WasherGroupPage.WasherGroupTableGrid.Rows.Count > 1)
     {
         Thread.Sleep(1000);
         Page.WasherGroupPage.WasherGroupTableGrid.SelectedRows(setWasherType)[0].GetButtonControls()[4].DeskTopMouseClick();
         Page.WasherGroupPage.TabFormula.DeskTopMouseClick();
         Thread.Sleep(1000);
         Page.WasherGroupPage.WasherGroupFormulaTabelGrid.Rows[1].GetButtonControls()[4].DeskTopMouseClick();
         Thread.Sleep(1000);
         if (Page.WasherGroupPage.WashStepsTableGrid.Rows.Count > 1)
         {
             //Verifying the conditions.
             Thread.Sleep(1000);
             for (int k = 1; k <= Page.WasherGroupPage.WashStepsTableGrid.Rows.Count; k++)
             {
                 Thread.Sleep(1000);
                 if (Page.WasherGroupPage.WashStepsTableGrid.Rows[k].GetColumnValues()[2].ToString() == "Drain")
                 {
                     Dictionary<string, string> ActualDrainWashStep = new Dictionary<string, string>();
                     Dictionary<string, string> ExpectedDrainWashStep = new Dictionary<string, string>();
                     ExpectedDrainWashStep.Add("Operations", "Drain");
                     ExpectedDrainWashStep.Add("Run Time (mm:ss)", "02:00");
                     ExpectedDrainWashStep.Add("Temperature (oF)", "1");
                     ExpectedDrainWashStep.Add("Water Level (inches)", "0");
                     //Need to find the list of row values to compare and fail or pass the test case....with this finish...
                     ReadOnlyCollection<string> getValues = Page.WasherGroupPage.WashStepsTableGrid.Rows[k].GetColumnValues();
                     ActualDrainWashStep.Add("Operations", getValues[2]);
                     ActualDrainWashStep.Add("Run Time (mm:ss)", getValues[3]);
                     ActualDrainWashStep.Add("Temperature (oF)", getValues[4]);
                     ActualDrainWashStep.Add("Water Level (inches)", getValues[5]);
                     List<KeyValuePair<string,string>> diffCount = ExpectedDrainWashStep.Except(ActualDrainWashStep).ToList();
                     if(diffCount.Count > 0)
                     {
                         Assert.Fail("Drain Wash Steps are not matching with Expected.Actual - " + diffCount[0]);
                     }
                     break;
                 }
             }
         }
         else
         {
             Assert.Fail("Drain WashStep not found in the gridview: Expected- Drain WashStep to be display while adding new WashStep");
         }
     }
     else
     {
         Assert.Fail("Washer Group data not found in grid page");
     }
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:51,代码来源:WasherGroupTest.cs


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