Ejemplo n.º 1
0
        public TypeReference ImportType(TypeReference type, IGenericContext context)
        {
            if (type.IsTypeSpecification())
            {
                return(ImportTypeSpecification(type, context));
            }

            var reference = new TypeReference(
                type.Namespace,
                type.Name,
                module,
                ImportScope(type.Scope),
                type.IsValueType);

            MetadataSystem.TryProcessPrimitiveType(reference);

            if (type.IsNested)
            {
                reference.DeclaringType = ImportType(type.DeclaringType, context);
            }

            if (type.HasGenericParameters)
            {
                ImportGenericParameters(reference, type);
            }

            return(reference);
        }
        static void AppendType(TypeReference type, StringBuilder name, bool fq_name, bool top_level)
        {
            var declaring_type = type.DeclaringType;

            if (declaring_type != null)
            {
                AppendType(declaring_type, name, false, top_level);
                name.Append('+');
            }

            var @namespace = type.Namespace;

            if (!string.IsNullOrEmpty(@namespace))
            {
                name.Append(@namespace);
                name.Append('.');
            }

            name.Append(type.GetElementType().Name);

            if (!fq_name)
            {
                return;
            }

            if (type.IsTypeSpecification())
            {
                AppendTypeSpecification((TypeSpecification)type, name);
            }

            if (RequiresFullyQualifiedName(type, top_level))
            {
                name.Append(", ");
                name.Append(GetScopeFullName(type));
            }
        }
        static bool AreSame(TypeReference a, TypeReference b)
        {
            if (ReferenceEquals(a, b))
            {
                return(true);
            }

            if (a == null || b == null)
            {
                return(false);
            }

            if (a.etype != b.etype)
            {
                return(false);
            }

            if (a.IsGenericParameter)
            {
                return(AreSame((GenericParameter)a, (GenericParameter)b));
            }

            if (a.IsTypeSpecification())
            {
                return(AreSame((TypeSpecification)a, (TypeSpecification)b));
            }

            if (a.Name != b.Name || a.Namespace != b.Namespace)
            {
                return(false);
            }

            //TODO: check scope

            return(AreSame(a.DeclaringType, b.DeclaringType));
        }
Ejemplo n.º 4
0
		public TypeReference ImportType (TypeReference type, IGenericContext context)
		{
			if (type.IsTypeSpecification ())
				return ImportTypeSpecification (type, context);

			var reference = new TypeReference (
				type.Namespace,
				type.Name,
				module,
				ImportScope (type.Scope),
				type.IsValueType);

			MetadataSystem.TryProcessPrimitiveType (reference);

			if (type.IsNested)
				reference.DeclaringType = ImportType (type.DeclaringType, context);

			if (type.HasGenericParameters)
				ImportGenericParameters (reference, type);

			return reference;
		}
		static bool AreSame (TypeReference a, TypeReference b)
		{
			if (ReferenceEquals (a, b))
				return true;

			if (a == null || b == null)
				return false;

			if (a.etype != b.etype)
				return false;

			if (a.IsGenericParameter)
				return AreSame ((GenericParameter) a, (GenericParameter) b);

			if (a.IsTypeSpecification ())
				return AreSame ((TypeSpecification) a, (TypeSpecification) b);

			if (a.Name != b.Name || a.Namespace != b.Namespace)
				return false;

			//TODO: check scope

			return AreSame (a.DeclaringType, b.DeclaringType);
		}