/// <include file='doc\WindowsPrincipal.uex' path='docs/doc[@for="WindowsPrincipal.IsInRole"]/*' /> public virtual bool IsInRole(String role) { if (role == null) { return(false); } if (!m_rolesLoaded) { lock (this) { if (!m_rolesLoaded) { m_roles = m_identity.GetRoles(); if (m_roles != null && m_roles.Length > MAGIC_NUMBER) { m_rolesTable = new Hashtable(m_roles.Length, 1.0f, s_provider, s_comparer); for (int i = 0; i < m_roles.Length; ++i) { try { if (m_roles[i] != null) { m_rolesTable.Add(m_roles[i], m_roles[i]); } } catch (ArgumentException) { } } m_roles = null; } m_rolesLoaded = true; } } } if (m_rolesLoaded && m_roles == null && m_rolesTable == null) { return(false); } if (m_rolesTable != null) { return(m_rolesTable.Contains(role)); } for (int i = 0; i < m_roles.Length; ++i) { if (m_roles[i] != null && String.Compare(m_roles[i], role, true, CultureInfo.InvariantCulture) == 0) { return(true); } } return(false); }