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


C# DynamicDictionary.Add方法代码示例

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


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

示例1: HomeModule

        public HomeModule(ITransient transient, IRequestScoped requestScoped)
            : base("/home")
        {
            _transient = transient;
            _requestScoped = requestScoped;
            Debug.Assert(_requestScoped == _transient.RequestScoped);

            Get["/"] = _ =>
            {
                var viewBag = new DynamicDictionary();
                viewBag.Add("Transient", _transient);
                viewBag.Add("RequestScoped", _requestScoped);
                return View["home/index", viewBag];
            };

            Get["/index", runAsync: true] = async (_, token) =>
            {
                await Task.Delay(1000);
                return "123";
            };

            Get["/list", runAsync: true] = async (_, token) =>
            {
                await Task.Delay(1);
                return 500;
            };

            Get["/edit", runAsync: true] = async (_, token) =>
            {
                await Task.Delay(1);
                return 404;
            };
        }
开发者ID:lcssk8board,项目名称:DryIoc-Nancy,代码行数:33,代码来源:HomeModule.cs

示例2: TestContainsKey

        public void TestContainsKey()
        {
            var d = new DynamicDictionary();

            d.Add("key", "value");

            Assert.IsTrue(d.ContainsKey("key"), "Did not contain key: \"key\"");
        }
开发者ID:harunpehlivan,项目名称:LiveSDK-for-Windows,代码行数:8,代码来源:DynamicDictionaryTest.cs

示例3: TestAdd

        public void TestAdd()
        {
            var d = new DynamicDictionary();

            d.Add("key", "value");

            Assert.AreEqual("value", d["key"]);
        }
开发者ID:harunpehlivan,项目名称:LiveSDK-for-Windows,代码行数:8,代码来源:DynamicDictionaryTest.cs

示例4: Test_get_cards_by_filter

        public void Test_get_cards_by_filter ()
        {
            DynamicDictionary query = new DynamicDictionary(); 

            query.Add ("name", "Ankh of Mishra");
            Card[] cards = repository.GetCards (query).Result;
            Assert.Greater (cards.Length,1);
        }
开发者ID:jesseflorig,项目名称:api.mtgdb.info,代码行数:8,代码来源:TestApi.cs

示例5: Should_add_value_when_invoking_string_dynamic_overload_of_add_method

        public void Should_add_value_when_invoking_string_dynamic_overload_of_add_method()
        {
            // Given
            var input = new DynamicDictionary();

            // When
            input.Add("test", 10);
            var value = (int)input["test"];

            // Then
            value.ShouldEqual(10);
        }
开发者ID:DarrellMozingo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryFixture.cs

示例6: Should_add_value_when_invoking_keyvaluepair_overload_of_add_method

        public void Should_add_value_when_invoking_keyvaluepair_overload_of_add_method()
        {
            // Given
            var input = new DynamicDictionary();

            // When
            input.Add(new KeyValuePair<string, dynamic>("test", 10));
            var value = (int)input["test"];

            // Then
            value.ShouldEqual(10);
        }
开发者ID:DarrellMozingo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryFixture.cs

示例7: Deserialize

        public object Deserialize( BsonDeserializationContext context, BsonDeserializationArgs args )
        {
            var bsonReader = context.Reader;
            BsonType bsonType = bsonReader.CurrentBsonType;

            object result;

            if( bsonType == BsonType.Null )
            {
                bsonReader.ReadNull();
                result = null;
            }
            else
            {
                if( bsonType == BsonType.Document )
                {
                    var dictionary = new DynamicDictionary();

                    bsonReader.ReadStartDocument();

                    IDiscriminatorConvention valueDiscriminatorConvention = BsonSerializer.LookupDiscriminatorConvention( typeof( object ) );

                    while( bsonReader.ReadBsonType() != BsonType.EndOfDocument )
                    {
                        string key = bsonReader.ReadName();
                        Type valueType = valueDiscriminatorConvention.GetActualType( bsonReader, typeof( object ) );
                        IBsonSerializer valueSerializer = BsonSerializer.LookupSerializer( valueType );
                        object value = valueSerializer.Deserialize( context );

                        if( key != "_t" )
                        {
                            dictionary.Add( key.Replace( '\x03', '.' ), value );
                        }
                    }
                    bsonReader.ReadEndDocument();
                    result = dictionary;
                }
                else
                {
                    string message = string.Format( "Can't deserialize a {0} from BsonType {1}.", context.Reader.CurrentBsonType, bsonType );
                    throw new BsonException( message );
                }
            }

            return result;
        }
开发者ID:jango2015,项目名称:TrivialMongoMessageQueue,代码行数:46,代码来源:DynamicDictionarySerializer.cs

示例8: TestAddKeyValuePair

        public void TestAddKeyValuePair()
        {
            var d = new DynamicDictionary();

            d.Add(new KeyValuePair<string, object>("foo", "bar"));

            Assert.AreEqual("bar", d["foo"]);
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:8,代码来源:DynamicDictionaryTest.cs

示例9: TestGetEnumerator

        public void TestGetEnumerator()
        {
            var d = new DynamicDictionary();

            d.Add("key", "value");

            IEnumerator enumerator = d.GetEnumerator();

            int count = 0;
            while (enumerator.MoveNext())
            {
                var pair = (KeyValuePair<string, object>) enumerator.Current;

                Assert.AreEqual("key", pair.Key);
                Assert.AreEqual("value", pair.Value);

                count += 1;
            }

            Assert.AreEqual(1, count, "Enumerator did not move through the right number of items.");
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:21,代码来源:DynamicDictionaryTest.cs

示例10: TestRemoveKeyValuePair

        public void TestRemoveKeyValuePair()
        {
            var d = new DynamicDictionary();

            d.Add("key", "value");

            Assert.IsTrue(d.Remove(new KeyValuePair<string, object>("key", "value")));

            Assert.AreEqual(0, d.Count);
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:10,代码来源:DynamicDictionaryTest.cs

示例11: TestCount

        public void TestCount()
        {
            var d = new DynamicDictionary();

            Assert.AreEqual(0, d.Count);

            d.Add("key", "value");

            Assert.AreEqual(1, d.Count);

            d.Remove("key");

            Assert.AreEqual(0, d.Count);
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:14,代码来源:DynamicDictionaryTest.cs

示例12: TestCopyToKeyValuePair

        public void TestCopyToKeyValuePair()
        {
            var d = new DynamicDictionary();

            d.Add("foo", "bar");

            var array = new KeyValuePair<string, object>[d.Count];

            d.CopyTo(array, 0);

            KeyValuePair<string, object> pair = array[0];

            Assert.AreEqual("foo", pair.Key);
            Assert.AreEqual("bar", pair.Value);
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:15,代码来源:DynamicDictionaryTest.cs

示例13: ViewReportResults

        private dynamic ViewReportResults(dynamic args)
        {
            var requestId = new Guid(args.id);

            var results = reportResultService.GetResultsPage(requestId, Context.RequestedPage());

            var columns = results.FieldColumns.Select(x => new { name = String.Format(FieldNameFormat, x.FieldName, x.UnitName), id = x.FieldId }).ToList();
            columns.Insert(0, new { name = "Date Recorded", id = "DateRecorded" });
            columns.Insert(1, new { name = "Site Name", id = "SiteName" });

            var pagedResult = new
            {
                ReportName = results.ReportName,
                Count = results.Count,
                Pages = results.Pages,
                Columns = columns,
                Rows = results.Rows.Select(x =>
                {
                    var row = new DynamicDictionary();
                    row.Add("DateRecorded", x.RowDateTime.ToString(RowDateFormat));
                    row.Add("SiteName", x.SiteName);

                    foreach (var field in x.Fields)
                    {
                        row.Add(field.FieldId, field.Value);
                    }

                    return row;
                })
            };

            return pagedResult;
        }
开发者ID:apxnowhere,项目名称:Encore,代码行数:33,代码来源:ReportModule.cs

示例14: Should_remove_natural_key

        public void Should_remove_natural_key()
        {
            // Given
            var input = new DynamicDictionary();
            input.Add("a-b-c", "hello");

            //when
            input.Remove("a-b-c");

            //then
            input.ContainsKey("abc").ShouldBeFalse();
        }
开发者ID:DarrellMozingo,项目名称:Nancy,代码行数:12,代码来源:DynamicDictionaryFixture.cs

示例15: TestTryGetValueKeyExists

        public void TestTryGetValueKeyExists()
        {
            var d = new DynamicDictionary();

            d.Add("key", "value");

            object value;

            Assert.IsTrue(
                d.TryGetValue("key", out value), 
                "Expected true to trying to get a value for an existing key.");

            Assert.AreEqual("value", value);
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:14,代码来源:DynamicDictionaryTest.cs


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