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


C# System.Collections.Generic.ToDictionary方法代码示例

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


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

示例1: Should_get_dictionary_of_property_values

		public void Should_get_dictionary_of_property_values()
		{
			var something = new {Value = 123, Another = "Test"};
			IDictionary<string, object> dictionary = something.ToDictionary();
			dictionary["Value"].ShouldEqual(123);
			dictionary["Another"].ShouldEqual("Test");
		}
开发者ID:sthapa123,项目名称:codecampserver,代码行数:7,代码来源:ObjectExtensionsTester.cs

示例2: Initialize

 public static void Initialize()
 {
     var initialState = new[]
     {
         new Stall {Id = 1, Available = true, Location = "asynchrony"},
         new Stall {Id = 2, Available = true, Location = "asynchrony"},
         new Stall {Id = 3, Available = true, Location = "asynchrony"},
     };
     _cache = initialState.ToDictionary(s => s.Id);
 }
开发者ID:TMcManemy,项目名称:OpenThrone,代码行数:10,代码来源:StallCache.cs

示例3: should_read_from_cache_when_no_update_in_po_file

        public void should_read_from_cache_when_no_update_in_po_file()
        {
            var parser = new Mock<IPoFileParser>();
            var expectedI18NMessages = new[] { new I18NMessage("translation key", "translation key") };
            var localeEnUsMessagesPo = Path.Combine(TestHelper.GetRuntimePath(),"locale\\en-US\\messages.po");
            parser.Setup(p => p.Parse(localeEnUsMessagesPo)).Returns(expectedI18NMessages.ToDictionary(d=> d.MsgId));

            var i18NMessagesCache = new GenericCache<IDictionary<string, I18NMessage>>();
            var actualI18NMessages = i18NMessagesCache.Get("en-US", () => parser.Object.Parse(localeEnUsMessagesPo));

            VerifyResult(expectedI18NMessages, actualI18NMessages);
        }
开发者ID:xianjing,项目名称:i18n,代码行数:12,代码来源:I18NMessagesCacheFacts.cs

示例4: should_return_correct_translation_value_given_correct_key

        public void should_return_correct_translation_value_given_correct_key()
        {
            var parser = new Mock<IPoFileParser>();
            var expectedI18NMessages = new[] { new I18NMessage("translation key", "translation vlaue") };
            var localeEnUsMessagesPo = Path.Combine(TestHelper.GetRuntimePath(), "locale\\en-US\\messages.po");
            parser.Setup(p =>p.Parse(localeEnUsMessagesPo)).Returns(expectedI18NMessages.ToDictionary(d => d.MsgId));

            var i18NMessagesCache = new GenericCache<IDictionary<string, I18NMessage>>();
            var result = new LocalizingService(i18NMessagesCache, TestHelper.GetRuntimePath(), parser.Object)
                .GetText("translation key", new []{"en-US"});

            Assert.Equal("translation vlaue", result);
        }
开发者ID:xianjing,项目名称:i18n,代码行数:13,代码来源:I18NMessagesCacheFacts.cs

示例5: GetDictionary

        public static Dictionary<string, Creature> GetDictionary()
        {
            var entries = new[]
            {
                new Creature()
                {
                    Name ="Rat",
                    Health =10,
                    Damage =3
                },
                new Creature()
                {
                    Name = "Kobold",
                    Health = 15,
                    Damage = 5
                }
            };

            return entries.ToDictionary(item => item.Name);
        }
开发者ID:KarmaLaBelle,项目名称:SunshineRogue,代码行数:20,代码来源:Creature.cs

示例6: GenerateUsername

		public async Task<string> GenerateUsername(string givenName, string surName) //100%
		{
			var parameters =
				new[]
					{
						new { Key = "givenName", Value = givenName },
						new { Key = "surName", Value = surName }
					};

			var y = await Api("usernamegenerator/", parameters.ToDictionary(e => e.Key, e => e.Value));
			var x = JsonConvert.DeserializeAnonymousType(y, new { username = string.Empty });
			return x.username;
		}
开发者ID:kfwls,项目名称:RS2013-Refugees-United-USSD,代码行数:13,代码来源:RefugeesUnitedService.cs

示例7: Login

		public async Task<Profile> Login(Device device, string username, string password) //99*%
		{
			//todo sort out returns
			var parameters = new[]
				{
					new { Key = "password", Value = password}
				};
			var y = await Api("profile/login/" + username, parameters.ToDictionary(e => e.Key, e => e.Value));
			var x = JsonConvert.DeserializeObject<LoginResponse>(y);

			return null;			//Don't know what data returns when logged is SUCCESSFULL - Would need ProfileID to get the profile.

			//EG "\n{\"authenticated\":false,\"verificationRequired\":false,\"forcePasswordReset\":false}"
		}
开发者ID:kfwls,项目名称:RS2013-Refugees-United-USSD,代码行数:14,代码来源:RefugeesUnitedService.cs


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