internal PermissionSet CodeGroupResolve(Evidence evidence, bool systemPolicy) { PermissionSet permissionSet = null; IEnumerator enumerator = this.PolicyLevels.GetEnumerator(); evidence.GetHostEvidence <Zone>(); evidence.GetHostEvidence <StrongName>(); evidence.GetHostEvidence <Url>(); byte[] serializedEvidence = evidence.RawSerialize(); int rawCount = evidence.RawCount; bool flag = AppDomain.CurrentDomain.GetData("IgnoreSystemPolicy") != null; bool flag2 = false; while (enumerator.MoveNext()) { object obj = enumerator.Current; PolicyLevel policyLevel = (PolicyLevel)obj; if (systemPolicy) { if (policyLevel.Type == PolicyLevelType.AppDomain) { continue; } } else if (flag && policyLevel.Type != PolicyLevelType.AppDomain) { continue; } PolicyStatement policyStatement = policyLevel.Resolve(evidence, rawCount, serializedEvidence); if (permissionSet == null) { permissionSet = policyStatement.PermissionSet; } else { permissionSet.InplaceIntersect(policyStatement.GetPermissionSetNoCopy()); } if (permissionSet == null || permissionSet.FastIsEmpty()) { break; } if ((policyStatement.Attributes & PolicyStatementAttribute.LevelFinal) == PolicyStatementAttribute.LevelFinal) { if (policyLevel.Type != PolicyLevelType.AppDomain) { flag2 = true; break; } break; } } if (permissionSet != null && flag2) { PolicyLevel policyLevel2 = null; for (int i = this.PolicyLevels.Count - 1; i >= 0; i--) { PolicyLevel policyLevel = (PolicyLevel)this.PolicyLevels[i]; if (policyLevel.Type == PolicyLevelType.AppDomain) { policyLevel2 = policyLevel; break; } } if (policyLevel2 != null) { PolicyStatement policyStatement = policyLevel2.Resolve(evidence, rawCount, serializedEvidence); permissionSet.InplaceIntersect(policyStatement.GetPermissionSetNoCopy()); } } if (permissionSet == null) { permissionSet = new PermissionSet(PermissionState.None); } if (!permissionSet.IsUnrestricted()) { IEnumerator hostEnumerator = evidence.GetHostEnumerator(); while (hostEnumerator.MoveNext()) { object obj2 = hostEnumerator.Current; IIdentityPermissionFactory identityPermissionFactory = obj2 as IIdentityPermissionFactory; if (identityPermissionFactory != null) { IPermission permission = identityPermissionFactory.CreateIdentityPermission(evidence); if (permission != null) { permissionSet.AddPermission(permission); } } } } permissionSet.IgnoreTypeLoadFailures = true; return(permissionSet); }