本文整理汇总了C#中IPrincipal.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IPrincipal.GetType方法的具体用法?C# IPrincipal.GetType怎么用?C# IPrincipal.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPrincipal
的用法示例。
在下文中一共展示了IPrincipal.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IPrincipalToString
public static string IPrincipalToString(IPrincipal principal)
{
if (principal == null) {
return "NULL";
}
if (typeof(CasPrincipal) == principal.GetType()) {
ICasPrincipal casPrincipal = (ICasPrincipal) principal;
return string.Format("Type>{0}< Identity[{1}] Assertion[{2}]",
principal.GetType().Name,
IIdentityToString(casPrincipal.Identity),
AssertionToString(casPrincipal.Assertion));
}
return string.Format("Type>{0}< Identity[{1}]",
principal.GetType().Name, IIdentityToString(principal.Identity));
}
示例2: AddPrincipalContext
private static void AddPrincipalContext(IDictionary exceptionContext, IPrincipal principal, string prefix)
{
if (exceptionContext == null)
throw new ArgumentNullException("exceptionContext");
if (prefix == null)
prefix = string.Empty;
if (principal != null)
{
exceptionContext.Add(prefix + ".Principal.TypeName", principal.GetType().FullName);
if (principal.Identity == null)
{
exceptionContext.Add((object)prefix + ".Principal.Identity", (object)"Null");
}
else
{
IIdentity identity = principal.Identity;
exceptionContext.Add(prefix + ".Principal.Identity.TypeName", identity.GetType().FullName);
exceptionContext.Add(prefix + ".Principal.Identity.AuthType", identity.AuthenticationType);
exceptionContext.Add(prefix + ".Principal.Identity.IsAuthenticated", Convert.ToBoolean(identity.IsAuthenticated ? 1 : 0));
exceptionContext.Add(prefix + ".Principal.Identity.Name", identity.Name);
}
}
else
exceptionContext.Add(prefix + ".Principal", "Null");
}
示例3: SerializePrincipal
static void SerializePrincipal (Thread th, IPrincipal value)
{
MemoryStream ms = new MemoryStream ();
bool done = false;
if (value.GetType () == typeof (GenericPrincipal)) {
GenericPrincipal gp = (GenericPrincipal) value;
if (gp.Identity != null && gp.Identity.GetType () == typeof (GenericIdentity)) {
GenericIdentity id = (GenericIdentity) gp.Identity;
if (id.Name == "" && id.AuthenticationType == "") {
if (gp.Roles == null) {
ms.WriteByte (2);
done = true;
} else if (gp.Roles.Length == 0) {
ms.WriteByte (3);
done = true;
}
} else {
ms.WriteByte (1);
BinaryWriter br = new BinaryWriter (ms);
br.Write (gp.Identity.Name);
br.Write (gp.Identity.AuthenticationType);
string [] roles = gp.Roles;
if (roles == null) {
br.Write ((int) (-1));
} else {
br.Write (roles.Length);
foreach (string s in roles) {
br.Write (s);
}
}
br.Flush ();
done = true;
}
}
}
if (!done) {
ms.WriteByte (0);
BinaryFormatter bf = new BinaryFormatter ();
try {
bf.Serialize (ms, value);
} catch {}
}
th.Internal._serialized_principal = ByteArrayToRootDomain (ms.ToArray ());
}
示例4: IsVistaPrincipal
public static bool IsVistaPrincipal(IPrincipal principal)
{
return principal.GetType().IsInstanceOfType(typeof(VistaPrincipal));
}