本文整理汇总了C#中System.Security.PermissionToken.FromXml方法的典型用法代码示例。如果您正苦于以下问题:C# PermissionToken.FromXml方法的具体用法?C# PermissionToken.FromXml怎么用?C# PermissionToken.FromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.PermissionToken
的用法示例。
在下文中一共展示了PermissionToken.FromXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
[System.Security.SecurityCritical] // auto-generated
private static Object Deserialize(byte[] blob)
{
if (blob == null)
return null;
if (blob[0] == 0)
{
Parser parser = new Parser( blob, Tokenizer.ByteTokenEncoding.UTF8Tokens, 1 );
SecurityElement root = parser.GetTopElement();
if (root.Tag.Equals( "IPermission" ) || root.Tag.Equals( "Permission" ))
{
IPermission ip = System.Security.Util.XMLUtil.CreatePermission( root, PermissionState.None, false );
if (ip == null)
{
return null;
}
ip.FromXml( root );
return ip;
}
else if (root.Tag.Equals( "PermissionSet" ))
{
PermissionSet permissionSet = new PermissionSet();
permissionSet.FromXml( root, false, false );
return permissionSet;
}
else if (root.Tag.Equals( "PermissionToken" ))
{
PermissionToken pToken = new PermissionToken();
pToken.FromXml( root );
return pToken;
}
else
{
return null;
}
}
else
{
Object obj = null;
using(MemoryStream stream = new MemoryStream( blob, 1, blob.Length - 1 )) {
obj = CrossAppDomainSerializer.DeserializeObject(stream);
}
Contract.Assert( !(obj is IPermission), "IPermission should be xml deserialized" );
Contract.Assert( !(obj is PermissionSet), "PermissionSet should be xml deserialized" );
return obj;
}
}
示例2: Deserialize
private static object Deserialize(byte[] blob)
{
if (blob == null)
{
return null;
}
if (blob[0] == 0)
{
SecurityElement topElement = new Parser(blob, Tokenizer.ByteTokenEncoding.UTF8Tokens, 1).GetTopElement();
if (topElement.Tag.Equals("IPermission") || topElement.Tag.Equals("Permission"))
{
IPermission permission = XMLUtil.CreatePermission(topElement, PermissionState.None, false);
if (permission == null)
{
return null;
}
permission.FromXml(topElement);
return permission;
}
if (topElement.Tag.Equals("PermissionSet"))
{
PermissionSet set = new PermissionSet();
set.FromXml(topElement, false, false);
return set;
}
if (topElement.Tag.Equals("PermissionToken"))
{
PermissionToken token = new PermissionToken();
token.FromXml(topElement);
return token;
}
return null;
}
using (MemoryStream stream = new MemoryStream(blob, 1, blob.Length - 1))
{
return CrossAppDomainSerializer.DeserializeObject(stream);
}
}