Ejemplo n.º 1
0
        /// <summary>
        /// Gets a <see cref="CorLibTypeSig"/> if <paramref name="type"/> matches a primitive type.
        /// </summary>
        /// <param name="self">this</param>
        /// <param name="type">The type</param>
        /// <returns>A <see cref="CorLibTypeSig"/> or <c>null</c> if it didn't match any primitive type</returns>
        public static CorLibTypeSig GetCorLibTypeSig(this ICorLibTypes self, ITypeDefOrRef type)
        {
            CorLibTypeSig corLibType;

            if (type is TypeDef td &&
                td.DeclaringType is null &&
                !((corLibType = self.GetCorLibTypeSig(td.Namespace, td.Name, td.DefinitionAssembly)) is null))
            {
                return(corLibType);
            }

            if (type is TypeRef tr &&
                !(tr.ResolutionScope is TypeRef) &&
                !((corLibType = self.GetCorLibTypeSig(tr.Namespace, tr.Name, tr.DefinitionAssembly)) is null))
            {
                return(corLibType);
            }

            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a <see cref="CorLibTypeSig"/> if <paramref name="type"/> matches a primitive type.
        /// </summary>
        /// <param name="self">this</param>
        /// <param name="type">The type</param>
        /// <returns>A <see cref="CorLibTypeSig"/> or <c>null</c> if it didn't match any primitive type</returns>
        public static CorLibTypeSig GetCorLibTypeSig(this ICorLibTypes self, ITypeDefOrRef type)
        {
            CorLibTypeSig corLibType;

            TypeDef td;

            if ((td = type as TypeDef) != null &&
                td.DeclaringType == null &&
                (corLibType = self.GetCorLibTypeSig(td.Namespace, td.Name, td.DefinitionAssembly)) != null)
            {
                return(corLibType);
            }

            TypeRef tr;

            if ((tr = type as TypeRef) != null &&
                !(tr.ResolutionScope is TypeRef) &&
                (corLibType = self.GetCorLibTypeSig(tr.Namespace, tr.Name, tr.DefinitionAssembly)) != null)
            {
                return(corLibType);
            }

            return(null);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets a <see cref="CorLibTypeSig"/> if <paramref name="namespace"/> and
 /// <paramref name="name"/> matches a primitive type.
 /// </summary>
 /// <param name="self">this</param>
 /// <param name="namespace">Namespace</param>
 /// <param name="name">Name</param>
 /// <param name="defAsm">Definition assembly</param>
 /// <returns>A <see cref="CorLibTypeSig"/> or <c>null</c> if it didn't match any primitive type</returns>
 public static CorLibTypeSig GetCorLibTypeSig(this ICorLibTypes self, UTF8String @namespace, UTF8String name, IAssembly defAsm)
 {
     return(self.GetCorLibTypeSig(UTF8String.ToSystemStringOrEmpty(@namespace), UTF8String.ToSystemStringOrEmpty(name), defAsm));
 }