Exemplo n.º 1
0
        internal static bool IsTagItemType(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (type == typeof(string) || type == typeof(ITagItem))
            {
                return(true);
            }

            if (type != _iTaskItem && (type.Name == "ITaskItem" && type.Namespace == "Microsoft.Build.Framework"))
            {
                if (_iTaskItem == null)
                {
                    // Never load the assembly ourselves, but allow nevertheless
                    AssemblyName name = new AssemblyName(type.Assembly.FullName);

                    if (QQnCryptoHelpers.HashString(name.GetPublicKeyToken()) == "b03f5f7f11d50a3a")
                    {
                        _iTaskItem = type;
                    }
                }
            }

            return(type == _iTaskItem);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
        /// </summary>
        public override void Close()
        {
            if (_closed)
            {
                return;
            }

            _closed = true;
            if (!string.IsNullOrEmpty(_newHash) && _size != Length)
            {
                Debug.WriteLine(">>> Got invalid predefined hash");
                _hashOnClose = true;
            }


            if (_hashOnClose)
            {
                if (!_hashWhileWriting)
                {
                    if (_hashAlgorithm != null)
                    {
                        Hasher.TransformFinalBlock(_emptyBytes, 0, 0);
                        GC.KeepAlive(Hasher.Hash);
                    }

                    base.Position = 0;
                    byte[] buffer = new byte[16384];
                    int    nRead;

                    while (0 <= (nRead = base.Read(buffer, 0, buffer.Length)))
                    {
                        Hasher.TransformBlock(buffer, 0, nRead, null, 0);
                    }
                }

                Hasher.TransformFinalBlock(_emptyBytes, 0, 0);

                _newHash = QQnCryptoHelpers.HashString(Hasher.Hash, _hashType);
                _size    = Length;
            }
            base.Close();

            if (_updateOnClose)
            {
                _file.UpdateData(_newHash, _size, File.GetLastWriteTimeUtc(_file.FullName));
            }

            if (_hashAlgorithm != null)
            {
                _hashAlgorithm.Clear();                 // Disposes the hasher
                _hashAlgorithm = null;
            }
        }
Exemplo n.º 3
0
        public void TestTokens()
        {
            StrongNameKey snkIn = StrongNameKey.LoadFrom(SnkFile);

            Assert.That(snkIn.PublicKeyToken, Is.EqualTo(QQnCryptoHelpers.HashString(typeof(QQnCryptoHelpers).Assembly.GetName().GetPublicKeyToken())), "Our public-token api matches the .Net one");
        }