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


C# ParameterCollection.ContainsKey方法代码示例

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


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

示例1: UndefVarTest

        public void UndefVarTest()
        {
            var parameters = new ParameterCollection { { "a", 1 } };

            var undef = new Undefine(new Variable("a"));
            undef.Execute(parameters);
            Assert.False(parameters.ContainsKey("a"));
        }
开发者ID:sys27,项目名称:xFunc,代码行数:8,代码来源:UndefineTest.cs

示例2: SetItemFromCollectionTest

        public void SetItemFromCollectionTest()
        {
            var parameters = new ParameterCollection();
            parameters["x"] = 2.3;

            Assert.AreEqual(1, parameters.Collection.Count());
            Assert.IsTrue(parameters.ContainsKey("x"));
            Assert.AreEqual(2.3, parameters["x"]);
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:9,代码来源:MathParameterCollectionTest.cs

示例3: OverrideConstsTest

        public void OverrideConstsTest()
        {
            var parameters = new ParameterCollection();
            parameters["π"] = 4;

            Assert.AreEqual(1, parameters.Collection.Count());
            Assert.IsTrue(parameters.ContainsKey("π"));
            Assert.AreEqual(4, parameters["π"]);
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:9,代码来源:MathParameterCollectionTest.cs

示例4: OverrideConstsTest

        public void OverrideConstsTest()
        {
            var parameters = new ParameterCollection
            {
                ["π"] = 4
            };

            Assert.Equal(1, parameters.Collection.Count());
            Assert.True(parameters.ContainsKey("π"));
            Assert.Equal(4.0, parameters["π"]);
        }
开发者ID:sys27,项目名称:xFunc,代码行数:11,代码来源:MathParameterCollectionTest.cs

示例5: GetValue

        public object GetValue(ParameterCollection parameterCollection)
        {
            for (int i = 0; i < Keys.Length; ++i)
            {
                if (!parameterCollection.ContainsKey(Keys[i]))
                    return null;

                var value = parameterCollection.GetObject(Keys[i]);
                
                // Last key, returns result
                if (i == Keys.Length - 1)
                    return value;
                
                // Ohterwise, it should be a container
                if (!(value is ParameterCollection))
                    return null;

                parameterCollection = (ParameterCollection)value;
            }

            return null;
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:22,代码来源:ParameterPath.cs

示例6: TestCollectionsBasicValues

        public void TestCollectionsBasicValues()
        {
            //
            // => Initialize
            //
            // ---------------
            // |             | (Root)
            // |             |
            // ---------------
            //        |
            // ---------------
            // |             | (Child)    
            // |             |
            // ---------------
            var rootCollection = new ParameterCollection("Root");
            var childCollection = new ParameterCollection("Child");
            childCollection.AddSources(rootCollection);

            //
            // => Set P and V on Root (1,1,1)
            //
            // ---------------
            // |   V = 1,1,1 | (Root)
            // |   P = 1,1,1 |
            // ---------------
            //        |
            // ---------------
            // |   V = ^,^,^ | (Child)    
            // |   P = ^,^,^ |
            // ---------------
            var paramV = new ParameterKey<Vector3>("View");
            var paramP = new ParameterKey<Vector3>("Proj");
            rootCollection.Set(paramV, new Vector3(1, 1, 1));
            rootCollection.Set(paramP, new Vector3(1, 1, 1));

            // Verify collection.Count
            Assert.AreEqual(childCollection.Count, 2);

            // Verify collection.Contains
            Assert.AreEqual(childCollection.ContainsKey(paramV), true);
            Assert.AreEqual(childCollection.ContainsKey(paramP), true);

            //
            // => Set V in Root, Get from Child
            //
            // ---------------
            // |   V = 2,2,2 | (Root) 
            // |   P = 1,1,1 |
            // ---------------
            //        |
            // ---------------
            // |   V = ^,^,^ | (Child)   
            // |   P = ^,^,^ |
            // ---------------
            // Verify the Get and returned value
            Assert.AreEqual(childCollection.Get(paramV), new Vector3(1, 1, 1));
            rootCollection.Set(paramV, new Vector3(2,2,2));
            Assert.AreEqual(childCollection.Get(paramV), new Vector3(2, 2, 2));

            //
            // => Remove P from Root
            //
            // ---------------
            // |   V = 2,2,2 | (Root)  
            // |             |
            // ---------------
            //        |
            // ---------------
            // |   V = ^,^,^ | (Child)    
            // ---------------
            rootCollection.Remove(paramP);
            Assert.AreEqual(childCollection.Count, 1);

            //
            // => Overrides V in Child (3,3,3)
            //
            // ---------------
            // |   V = 2,2,2 | (Root)  
            // |             |
            // ---------------
            //        |
            // ---------------
            // |   V = 3,3,3 | (Child)    
            // ---------------            
            childCollection.Set(paramV, new Vector3(3, 3, 3));
            Assert.AreEqual(childCollection.Get(paramV), new Vector3(3, 3, 3));
            Assert.AreEqual(rootCollection.Get(paramV), new Vector3(2, 2, 2));

            //
            // => Reset Key V on Child
            //
            // ---------------
            // |   V = 2,2,2 | (Root)  
            // |             |
            // ---------------
            //        |
            // ---------------
            // |   V = ^,^,^ | (Child)    
            // ---------------            
            childCollection.Reset(paramV);
//.........这里部分代码省略.........
开发者ID:Powerino73,项目名称:paradox,代码行数:101,代码来源:TestParameters.cs

示例7: TestBasicValues

        public void TestBasicValues()
        {
            //
            // => Initialize, Set V (1,1,1)
            //
            // ---------------
            // |  V = 1,1,1  | (Test)
            // |             |
            // ---------------
            var collection = new ParameterCollection("Test");

            var paramV = new ParameterKey<Vector3>("View");
            var paramP = new ParameterKey<Vector3>("Proj");
            collection.Set(paramV, new Vector3(1, 1, 1));

            // Verify collection.Count
            Assert.AreEqual(collection.Count, 1);

            // Verify collection.Contains
            Assert.AreEqual(collection.ContainsKey(paramV), true);

            // Verify collection.Keys Enumerator
            int count = 0;
            foreach(var key in collection.Keys)
            {
                Assert.AreEqual(key, paramV);
                count++;
            }
            Assert.AreEqual(count, 1);

            // Verify the Get and returned value
            var value = collection.Get(paramV);
            Assert.AreEqual(value, new Vector3(1,1,1));

            //
            // => Set P (2,2,2)
            //
            // ---------------
            // |  V = 1,1,1  | (Test)
            // |  P = 2,2,2  |
            // ---------------
            collection.Set(paramP, new Vector3(2,2,2));
            Assert.AreEqual(collection.Count, 2);
            Assert.AreEqual(collection.Get(paramP), new Vector3(2, 2, 2));

            //
            // => Remove param V
            //
            // ---------------
            // |             | (Test)
            // |  P = 2,2,2  |
            // ---------------
            collection.Remove(paramV);
            Assert.AreEqual(collection.Count, 1);

            // Check that param
            Assert.AreEqual(collection.Get(paramP), new Vector3(2, 2, 2));

            //
            // => Remove param P
            //
            // ---------------
            // |             | (Test)
            // |             |
            // ---------------
            collection.Remove(paramP);
            Assert.AreEqual(collection.Count, 0);

            //
            // => Set param V
            //
            // ---------------
            // |  V = 2,2,2  | (Test)
            // |             |
            // ---------------
            // Just add same key to test that everything is going fine
            collection.Set(paramV, new Vector3(2, 2, 2));
            Assert.AreEqual(collection.Count, 1);
            Assert.AreEqual(collection.Get(paramV), new Vector3(2, 2, 2));
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:80,代码来源:TestParameters.cs

示例8: GetVarName

        private static string GetVarName(ParameterCollection parameters)
        {
            const string variable = "i";
            if (!parameters.ContainsKey(variable))
                return variable;

            for (int i = 1; ; i++)
            {
                var localVar = variable + i;
                if (!parameters.ContainsKey(localVar))
                    return localVar;
            }
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:13,代码来源:Product.cs

示例9: ContainersInPath

 private static IEnumerable<ParameterCollection> ContainersInPath(ParameterCollection parameterCollection, IEnumerable<ParameterKey> keys)
 {
     yield return parameterCollection;
     foreach (var key in keys)
     {
         if (!parameterCollection.ContainsKey(key))
             break;
         var nextContainer = parameterCollection.GetObject(key) as ParameterCollection;
         if (nextContainer == null)
             break;
         yield return nextContainer;
         parameterCollection = nextContainer;
     }
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:14,代码来源:ParameterPath.cs

示例10: SetExistItemFromCollectionTest

        public void SetExistItemFromCollectionTest()
        {
            var parameters = new ParameterCollection
            {
                new Parameter("x", 2.3)
            };
            parameters["x"] = 3.3;

            Assert.Equal(1, parameters.Collection.Count());
            Assert.True(parameters.ContainsKey("x"));
            Assert.Equal(3.3, parameters["x"]);
        }
开发者ID:sys27,项目名称:xFunc,代码行数:12,代码来源:MathParameterCollectionTest.cs

示例11: AreCollectionsEqual

 /// <summary>
 /// Test if two ParameterCollection are equal
 /// </summary>
 /// <param name="parameters0">The first ParameterCollection.</param>
 /// <param name="parameters1">The second ParameterCollection.</param>
 /// <returns>True if the collections are the same, false otherwise.</returns>
 private static bool AreCollectionsEqual(ParameterCollection parameters0, ParameterCollection parameters1)
 {
     bool result = true;
     foreach (var paramKey in parameters0)
     {
         result &= parameters1.ContainsKey(paramKey.Key) && parameters1[paramKey.Key].Equals(paramKey.Value);
     }
     foreach (var paramKey in parameters1)
     {
         result &= parameters0.ContainsKey(paramKey.Key) && parameters0[paramKey.Key].Equals(paramKey.Value);
     }
     return result;
 }
开发者ID:psowinski,项目名称:xenko,代码行数:19,代码来源:ImportModelCommand.cs


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