public static IEnumerable RemoveAssembliesThatAreSignedWithToken()

in Managed/Util/ExceptionHelper.cs [74:102]


        public static IEnumerable<Assembly> RemoveAssembliesThatAreSignedWithToken(IEnumerable<Assembly> input, byte[] publicKeyToken)
        {
            Debug.Assert(publicKeyToken.Length == PublicKeyTokenLength, "public key tokens should be 8 bytes");
            foreach (Assembly assembly in input)
            {
                byte[] currentToken = assembly.GetName().GetPublicKeyToken();
                bool shouldReturn;
                if (currentToken.Length == 0)
                {
                    // unsigned assembly
                    shouldReturn = true;
                }
                else if (AreTokensTheSame(currentToken, publicKeyToken))
                {
                    // tokens are the same skip the assembly
                    shouldReturn = false;
                }
                else
                {
                    // didnt match anything, return it
                    shouldReturn = true;
                }

                if (shouldReturn)
                {
                    yield return assembly;
                }
            }
        }