Esempio n. 1
0
        private static void MaybeLoadPrimitiveTables()
        {
            if (s_typeToPrimitive != null && s_primitiveToType != null)
            {
                return;
            }

            s_typeToPrimitive = new Dictionary <MetadataType, PrimitiveTypeCode>()
            {
                { MetadataDomain.GetMetadataType(typeof(bool)), PrimitiveTypeCode.Boolean },
                { MetadataDomain.GetMetadataType(typeof(byte)), PrimitiveTypeCode.Byte },
                { MetadataDomain.GetMetadataType(typeof(char)), PrimitiveTypeCode.Char },
                { MetadataDomain.GetMetadataType(typeof(double)), PrimitiveTypeCode.Double },
                { MetadataDomain.GetMetadataType(typeof(short)), PrimitiveTypeCode.Int16 },
                { MetadataDomain.GetMetadataType(typeof(int)), PrimitiveTypeCode.Int32 },
                { MetadataDomain.GetMetadataType(typeof(long)), PrimitiveTypeCode.Int64 },
                { MetadataDomain.GetMetadataType(typeof(object)), PrimitiveTypeCode.Object },
                { MetadataDomain.GetMetadataType(typeof(sbyte)), PrimitiveTypeCode.SByte },
                { MetadataDomain.GetMetadataType(typeof(float)), PrimitiveTypeCode.Single },
                { MetadataDomain.GetMetadataType(typeof(string)), PrimitiveTypeCode.String },
                { MetadataDomain.GetMetadataType(typeof(ushort)), PrimitiveTypeCode.UInt16 },
                { MetadataDomain.GetMetadataType(typeof(uint)), PrimitiveTypeCode.UInt32 },
                { MetadataDomain.GetMetadataType(typeof(ulong)), PrimitiveTypeCode.UInt64 },
                { MetadataDomain.GetMetadataType(typeof(void)), PrimitiveTypeCode.Void },
                { MetadataDomain.GetMetadataType(typeof(IntPtr)), PrimitiveTypeCode.IntPtr },
                { MetadataDomain.GetMetadataType(typeof(UIntPtr)), PrimitiveTypeCode.UIntPtr },
                { MetadataDomain.GetMetadataType(typeof(TypedReference)), PrimitiveTypeCode.TypedReference }
            };

            s_primitiveToType = s_typeToPrimitive.ToDictionary(
                pair => pair.Value,
                pair => pair.Key);
        }
Esempio n. 2
0
 public override Type[] GetGenericParameterConstraints()
 {
     return
         (Definition
          .GetConstraints()
          .Select(
              handle => MetadataDomain.GetMetadataType(
                  _metadata,
                  _metadata.GetGenericParameterConstraint(handle).Type))
          .ToArray());
 }
Esempio n. 3
0
 protected override Type[] GetInterfacesImpl()
 {
     return(new Type[]
     {
         MetadataDomain.GetMetadataType(typeof(ICloneable)),
         MetadataDomain.GetMetadataType(typeof(System.Collections.IList)),
         MetadataDomain.GetMetadataType(typeof(System.Collections.ICollection)),
         MetadataDomain.GetMetadataType(typeof(System.Collections.IEnumerable)),
         MetadataDomain.GetMetadataType(typeof(System.Collections.IStructuralComparable)),
         MetadataDomain.GetMetadataType(typeof(System.Collections.IStructuralEquatable)),
         MetadataDomain.GetMetadataType(typeof(System.Collections.Generic.IList <>)).MakeGenericType(GetElementType()),
         MetadataDomain.GetMetadataType(typeof(System.Collections.Generic.ICollection <>)).MakeGenericType(GetElementType()),
         MetadataDomain.GetMetadataType(typeof(System.Collections.Generic.IEnumerable <>)).MakeGenericType(GetElementType()),
         MetadataDomain.GetMetadataType(typeof(System.Collections.Generic.IReadOnlyList <>)).MakeGenericType(GetElementType()),
         MetadataDomain.GetMetadataType(typeof(System.Collections.Generic.IReadOnlyCollection <>)).MakeGenericType(GetElementType())
     });
 }
        private ConstructorInfo GetConstructor()
        {
            if (_constructor != null)
            {
                return(_constructor);
            }

            if (Definition.Constructor.Kind == HandleKind.MethodDefinition)
            {
                MethodDefinition definition = _metadata.GetMethodDefinition(
                    (MethodDefinitionHandle)Definition.Constructor);

                MetadataType type = MetadataDomain.GetMetadataType(
                    _metadata,
                    definition.GetDeclaringType());

                return(type.GetMetadataConstructor(
                           MetadataTokens.GetToken(
                               _metadata,
                               Definition.Constructor)));
            }

            MemberReference methodRef = _metadata.GetMemberReference(
                (MemberReferenceHandle)Definition.Constructor);

            MetadataType parent    = MetadataDomain.GetMetadataType(_metadata, methodRef.Parent);
            var          signature = methodRef.DecodeMethodSignature(
                new MetadataSignatureProvider(),
                new GenericContext()
            {
                DeclaringType = parent
            });

            ParameterModifier[] parameterModifier =
                signature.ParameterTypes.Length == 0
                    ? Empty <ParameterModifier> .Array
                    : new[] { new ParameterModifier(signature.RequiredParameterCount) };

            return(_constructor = parent.GetMetadataConstructor(
                       BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
                       null,
                       default(CallingConventions),
                       signature.ParameterTypes.ToArray(),
                       parameterModifier));
        }
 public MetadataType GetTypeFromSerializedName(string name)
 {
     return(MetadataDomain.GetMetadataType(name));
 }
 public MetadataType GetTypeFromReference(MetadataReader reader, TypeReferenceHandle handle, byte rawTypeKind)
 {
     return(MetadataDomain.GetMetadataType(reader, handle));
 }
 public MetadataType GetTypeFromDefinition(MetadataReader reader, TypeDefinitionHandle handle, byte rawTypeKind)
 {
     return(MetadataDomain.GetMetadataType(reader, handle));
 }
 public MetadataType GetSystemType()
 {
     return(MetadataDomain.GetMetadataType(typeof(System.Type)));
 }
 public bool IsSystemType(MetadataType type)
 {
     return(type == MetadataDomain.GetMetadataType(typeof(System.Type)));
 }