Example #1
0
        /// <summary>
        /// Determines whether two types are considered equal according to their signature.
        /// </summary>
        /// <param name="signature1">The first type to compare.</param>
        /// <param name="descriptor">The second type to compare.</param>
        /// <returns><c>True</c> if the types are considered equal, <c>False</c> otherwise.</returns>
        public bool Equals(MsCorLibTypeSignature signature1, ITypeDescriptor descriptor)
        {
            if (signature1 == null && descriptor == null)
            {
                return(true);
            }
            if (signature1 == null || descriptor == null)
            {
                return(false);
            }

            var signature2 = descriptor as TypeDefOrRefSignature;

            if (signature2 != null)
            {
                return(Equals(signature1.Type, signature2.Type));
            }

            var corlibType = descriptor as MsCorLibTypeSignature;

            if (corlibType != null)
            {
                return(signature1.ElementType == corlibType.ElementType);
            }

            var typeDefOrRef = descriptor as ITypeDefOrRef;

            if (typeDefOrRef != null)
            {
                return(Equals(signature1.Type, typeDefOrRef));
            }

            return(false);
        }
Example #2
0
        private MsCorLibTypeSignature CreateSignature(ElementType type, string name, bool isValueType)
        {
            MsCorLibTypeSignature signature;

            if (_isMsCorLib)
            {
                signature = new MsCorLibTypeSignature(_typeDefinitions.First(x => x.Name == name), type, isValueType);
            }
            else
            {
                signature = new MsCorLibTypeSignature(new TypeReference(MsCorLibReference, "System", name), type, isValueType);
            }

            _typesByName[name]        = signature;
            _typesByElementType[type] = signature;
            return(signature);
        }
Example #3
0
        private MsCorLibTypeSignature CreateSignature(ElementType type, string name, bool isValueType)
        {
            MsCorLibTypeSignature signature;

            if (_isMsCorLib)
            {
                if (_typeDefinitions == null)
                {
                    _typeDefinitions = _header.GetStream <TableStream>().GetTable <TypeDefinition>();
                }
                signature = new MsCorLibTypeSignature(_typeDefinitions.First(x => x.Name == name), type, isValueType);
            }
            else
            {
                signature = new MsCorLibTypeSignature(new TypeReference(MsCorLibReference, "System", name)
                {
                    Header = _header
                }, type, isValueType);
            }

            _typesByName[name]        = signature;
            _typesByElementType[type] = signature;
            return(signature);
        }
Example #4
0
 private TypeSignature ImportCorlibTypeSignature(MsCorLibTypeSignature corlibType)
 {
     return(TargetImage.TypeSystem.GetMscorlibType(corlibType));
 }
Example #5
0
 private TypeSignature ImportCorlibTypeSignature(MsCorLibTypeSignature corlibType)
 {
     return(_tableStreamBuffer.StreamHeader.MetadataHeader.TypeSystem.GetMscorlibType(corlibType));
 }