本文整理汇总了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;
}
示例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;
}