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


C# ObjectWriter.ReadValue方法代码示例

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


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

示例1: GetReplicationAuthParsedJson

 /// <exception cref="System.IO.IOException"></exception>
 public virtual IDictionary<string, object> GetReplicationAuthParsedJson()
 {
     var authJson = "{\n" + "    \"facebook\" : {\n" + "        \"email\" : \"[email protected]\"\n"
          + "     }\n" + "   }\n";
     mapper = new ObjectWriter();
     var authProperties = mapper.ReadValue<Dictionary<string, object>>(authJson);
     return authProperties;
 }
开发者ID:ertrupti9,项目名称:couchbase-lite-net,代码行数:9,代码来源:LiteTestCase.cs

示例2: ParseAssertion

		public static IDictionary<string, object> ParseAssertion(string assertion)
		{
			// https://github.com/mozilla/id-specs/blob/prod/browserid/index.md
			// http://self-issued.info/docs/draft-jones-json-web-token-04.html
			IDictionary<string, object> result = new Dictionary<string, object>();
			string[] components = assertion.Split("\\.");
			// split on "."
			if (components.Length < 4)
			{
				throw new ArgumentException("Invalid assertion given, only " + components.Length 
					+ " found.  Expected 4+");
			}
			string component1Decoded = Sharpen.Runtime.GetStringForBytes(Base64.Decode(components
				[1], Base64.Default));
			string component3Decoded = Sharpen.Runtime.GetStringForBytes(Base64.Decode(components
				[3], Base64.Default));
			try
			{
				ObjectWriter mapper = new ObjectWriter();
				IDictionary<object, object> component1Json = mapper.ReadValue<IDictionary>(component1Decoded
					);
				IDictionary<object, object> principal = (IDictionary<object, object>)component1Json
					.Get("principal");
				result.Put(AssertionFieldEmail, principal.Get("email"));
				IDictionary<object, object> component3Json = mapper.ReadValue<IDictionary>(component3Decoded
					);
				result.Put(AssertionFieldOrigin, component3Json.Get("aud"));
				long expObject = (long)component3Json.Get("exp");
				Log.D(Database.Tag, "PersonaAuthorizer exp: " + expObject + " class: " + expObject
					.GetType());
				DateTime expDate = Sharpen.Extensions.CreateDate(expObject);
				result.Put(AssertionFieldExpiration, expDate);
			}
			catch (IOException e)
			{
				string message = "Error parsing assertion: " + assertion;
				Log.E(Database.Tag, message, e);
				throw new ArgumentException(message, e);
			}
			return result;
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:41,代码来源:PersonaAuthorizer.cs


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