public void FromXml(SecurityElement elRoot) { // For the most part there is no parameter checking here since this is an // internal class and the serialization/deserialization path is controlled. if (!elRoot.Tag.Equals("PermissionToken")) { Contract.Assert(false, "Tried to deserialize non-PermissionToken element here"); } String strName = elRoot.Attribute("Name"); PermissionToken realToken; if (strName != null) { realToken = GetToken(strName, true); } else { realToken = FindTokenByIndex(Int32.Parse(elRoot.Attribute("Index"), CultureInfo.InvariantCulture)); } this.m_index = realToken.m_index; this.m_type = (PermissionTokenType)Enum.Parse(typeof(PermissionTokenType), elRoot.Attribute("Type")); Contract.Assert((this.m_type & PermissionTokenType.DontKnow) == 0, "Should have valid token type when FromXml is called."); this.m_strTypeName = realToken.m_strTypeName; }
internal PermissionToken(int index, PermissionTokenType type, String strTypeName) { m_index = index; m_type = type; #if FEATURE_CAS_POLICY m_strTypeName = strTypeName; #endif // FEATURE_CAS_POLICY }
public void FromXml(SecurityElement elRoot) { elRoot.Tag.Equals("PermissionToken"); string typeStr = elRoot.Attribute("Name"); PermissionToken permissionToken = typeStr == null?PermissionToken.FindTokenByIndex(int.Parse(elRoot.Attribute("Index"), (IFormatProvider)CultureInfo.InvariantCulture)) : PermissionToken.GetToken(typeStr, true); this.m_index = permissionToken.m_index; this.m_type = (PermissionTokenType)Enum.Parse(typeof(PermissionTokenType), elRoot.Attribute("Type")); this.m_strTypeName = permissionToken.m_strTypeName; }
internal PermissionToken BuiltInGetToken(int index, IPermission perm, Type cls) { PermissionToken token = Volatile.Read(ref m_builtIn[index]); if (token == null) { lock (this) { token = m_builtIn[index]; if (token == null) { PermissionTokenType permType = PermissionTokenType.DontKnow; if (perm != null) { permType = PermissionTokenType.IUnrestricted; } else if (cls != null) { permType = PermissionTokenType.IUnrestricted; } token = new PermissionToken(index, permType | PermissionTokenType.BuiltIn, null); Volatile.Write(ref m_builtIn[index], token); PermissionToken.s_tokenSet.SetItem(token.m_index, token); } } } if ((token.m_type & PermissionTokenType.DontKnow) != 0) { token.m_type = PermissionTokenType.BuiltIn; if (perm != null) { token.m_type |= PermissionTokenType.IUnrestricted; } else if (cls != null) { token.m_type |= PermissionTokenType.IUnrestricted; } else { token.m_type |= PermissionTokenType.DontKnow; } } return(token); }
public void FromXml(SecurityElement elRoot) { PermissionToken token; elRoot.Tag.Equals("PermissionToken"); string typeStr = elRoot.Attribute("Name"); if (typeStr != null) { token = GetToken(typeStr, true); } else { token = FindTokenByIndex(int.Parse(elRoot.Attribute("Index"), CultureInfo.InvariantCulture)); } this.m_index = token.m_index; this.m_type = (PermissionTokenType) Enum.Parse(typeof(PermissionTokenType), elRoot.Attribute("Type")); this.m_strTypeName = token.m_strTypeName; }
internal PermissionToken BuiltInGetToken(int index, IPermission perm, Type cls) { PermissionToken permissionToken = Volatile.Read <PermissionToken>(ref this.m_builtIn[index]); if (permissionToken == null) { lock (this) { permissionToken = this.m_builtIn[index]; if (permissionToken == null) { PermissionTokenType local_3 = PermissionTokenType.DontKnow; if (perm != null) { local_3 = PermissionTokenType.IUnrestricted; } else if (cls != (Type)null) { local_3 = PermissionTokenType.IUnrestricted; } permissionToken = new PermissionToken(index, local_3 | PermissionTokenType.BuiltIn, (string)null); Volatile.Write <PermissionToken>(ref this.m_builtIn[index], permissionToken); PermissionToken.s_tokenSet.SetItem(permissionToken.m_index, (object)permissionToken); } } } if ((permissionToken.m_type & PermissionTokenType.DontKnow) != (PermissionTokenType)0) { permissionToken.m_type = PermissionTokenType.BuiltIn; if (perm != null) { permissionToken.m_type |= PermissionTokenType.IUnrestricted; } else if (cls != (Type)null) { permissionToken.m_type |= PermissionTokenType.IUnrestricted; } else { permissionToken.m_type |= PermissionTokenType.DontKnow; } } return(permissionToken); }
public void FromXml(SecurityElement elRoot) { PermissionToken token; elRoot.Tag.Equals("PermissionToken"); string typeStr = elRoot.Attribute("Name"); if (typeStr != null) { token = GetToken(typeStr, true); } else { token = FindTokenByIndex(int.Parse(elRoot.Attribute("Index"), CultureInfo.InvariantCulture)); } this.m_index = token.m_index; this.m_type = (PermissionTokenType)Enum.Parse(typeof(PermissionTokenType), elRoot.Attribute("Type")); this.m_strTypeName = token.m_strTypeName; }
internal PermissionToken BuiltInGetToken(int index, IPermission perm, Type cls) { PermissionToken item = this.m_builtIn[index]; if (item == null) { lock (this) { item = this.m_builtIn[index]; if (item == null) { PermissionTokenType dontKnow = PermissionTokenType.DontKnow; if (perm != null) { dontKnow = PermissionTokenType.IUnrestricted; } else if (cls != null) { dontKnow = PermissionTokenType.IUnrestricted; } item = new PermissionToken(index, dontKnow | PermissionTokenType.BuiltIn, null); this.m_builtIn[index] = item; PermissionToken.s_tokenSet.SetItem(item.m_index, item); } } } if ((item.m_type & PermissionTokenType.DontKnow) != 0) { item.m_type = PermissionTokenType.BuiltIn; if (perm != null) { item.m_type |= PermissionTokenType.IUnrestricted; return(item); } if (cls != null) { item.m_type |= PermissionTokenType.IUnrestricted; return(item); } item.m_type |= PermissionTokenType.DontKnow; } return(item); }
internal PermissionToken(int index, PermissionTokenType type, string strTypeName) { this.m_index = index; this.m_type = type; this.m_strTypeName = strTypeName; }
public void FromXml(SecurityElement elRoot) { // For the most part there is no parameter checking here since this is an // internal class and the serialization/deserialization path is controlled. if (!elRoot.Tag.Equals( "PermissionToken" )) Contract.Assert( false, "Tried to deserialize non-PermissionToken element here" ); String strName = elRoot.Attribute( "Name" ); PermissionToken realToken; if (strName != null) realToken = GetToken( strName, true ); else realToken = FindTokenByIndex( Int32.Parse( elRoot.Attribute( "Index" ), CultureInfo.InvariantCulture ) ); this.m_index = realToken.m_index; this.m_type = (PermissionTokenType) Enum.Parse(typeof(PermissionTokenType), elRoot.Attribute("Type")); Contract.Assert((this.m_type & PermissionTokenType.DontKnow) == 0, "Should have valid token type when FromXml is called."); this.m_strTypeName = realToken.m_strTypeName; }
internal PermissionToken(int index, PermissionTokenType type, String strTypeName) { m_index = index; m_type = type; #if FEATURE_CAS_POLICY m_strTypeName = strTypeName; #endif // FEATURE_CAS_POLICY }
internal PermissionToken(int index, PermissionTokenType type, string strTypeName) { this.m_index = index; this.m_type = type; this.m_strTypeName = strTypeName; }
internal PermissionToken BuiltInGetToken(int index, IPermission perm, Type cls) { PermissionToken token = m_builtIn[index]; if (token == null) { lock (this) { token = m_builtIn[index]; if (token == null) { PermissionTokenType permType = PermissionTokenType.DontKnow; if (perm != null) { if (CodeAccessSecurityEngine.DoesFullTrustMeanFullTrust() || perm is IUnrestrictedPermission) { permType = PermissionTokenType.IUnrestricted; } else { permType = PermissionTokenType.Normal; } } else if (cls != null) { if (CodeAccessSecurityEngine.DoesFullTrustMeanFullTrust() || cls.GetInterface("System.Security.Permissions.IUnrestrictedPermission") != null) { permType = PermissionTokenType.IUnrestricted; } else { permType = PermissionTokenType.Normal; } } token = new PermissionToken(index, permType | PermissionTokenType.BuiltIn, null); m_builtIn[index] = token; PermissionToken.s_tokenSet.SetItem(token.m_index, token); } } } if ((token.m_type & PermissionTokenType.DontKnow) != 0) { token.m_type = PermissionTokenType.BuiltIn; if (perm != null) { if (CodeAccessSecurityEngine.DoesFullTrustMeanFullTrust() || perm is IUnrestrictedPermission) { token.m_type |= PermissionTokenType.IUnrestricted; } else { token.m_type |= PermissionTokenType.Normal; } } else if (cls != null) { if (CodeAccessSecurityEngine.DoesFullTrustMeanFullTrust() || cls.GetInterface("System.Security.Permissions.IUnrestrictedPermission") != null) { token.m_type |= PermissionTokenType.IUnrestricted; } else { token.m_type |= PermissionTokenType.Normal; } } else { token.m_type |= PermissionTokenType.DontKnow; } } return(token); }
internal PermissionToken(int index, PermissionTokenType type, String strTypeName) { m_index = index; m_type = type; m_strTypeName = strTypeName; }
internal PermissionToken(int index, PermissionTokenType type, String strTypeName) { m_index = index; m_type = type; m_strTypeName = strTypeName; }