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


C# IPrincipal.GetType方法代码示例

本文整理汇总了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));
 }
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:15,代码来源:DebugUtils.cs

示例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");
        }
开发者ID:bfallar3,项目名称:DDD-rebar-demo,代码行数:27,代码来源:GlobalExceptionHandlingFilterAttribute.cs

示例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 ());
		}
开发者ID:Numpsy,项目名称:mono,代码行数:44,代码来源:Thread.cs

示例4: IsVistaPrincipal

 public static bool IsVistaPrincipal(IPrincipal principal)
 {
     return principal.GetType().IsInstanceOfType(typeof(VistaPrincipal));
 }
开发者ID:OSEHRA,项目名称:mdws,代码行数:4,代码来源:VistaPrincipal.cs


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