Beispiel #1
0
        public static TypeDefinition ToTypeDefinition(TypeReference reference, IEmitter emitter)
        {
            if (reference == null)
            {
                return null;
            }

            try
            {
                if (reference.IsGenericInstance)
                {
                    reference = reference.GetElementType();
                }

                string key = BridgeTypes.GetTypeDefinitionKey(reference.FullName);

                if (emitter.TypeDefinitions.ContainsKey(reference.FullName))
                {
                    return emitter.TypeDefinitions[reference.FullName];
                }

                return reference.Resolve();
            }
            catch
            {
            }

            return null;
        }
Beispiel #2
0
        public void InitItems(IEmitter emitter)
        {
            var logger = emitter.Log;

            logger.Trace("Initializing items for Bridge types...");

            this.Emitter = emitter;
            byType       = new Dictionary <IType, BridgeType>();
            foreach (var item in this)
            {
                var type = item.Value;
                var key  = BridgeTypes.GetTypeDefinitionKey(type.TypeDefinition);
                type.Emitter  = emitter;
                type.Type     = ReflectionHelper.ParseReflectionName(key).Resolve(emitter.Resolver.Resolver.TypeResolveContext);
                type.TypeInfo = emitter.Types.FirstOrDefault(t => t.Key == key);

                if (type.TypeInfo != null && emitter.TypeInfoDefinitions.ContainsKey(type.TypeInfo.Key))
                {
                    var typeInfo = this.Emitter.TypeInfoDefinitions[type.Key];

                    type.TypeInfo.Module       = typeInfo.Module;
                    type.TypeInfo.FileName     = typeInfo.FileName;
                    type.TypeInfo.Dependencies = typeInfo.Dependencies;
                }
            }

            logger.Trace("Initializing items for Bridge types done");
        }
Beispiel #3
0
        public void InitItems(IEmitter emitter)
        {
            this.Emitter = emitter;
            foreach (var type in typesOfKey_.Values)
            {
                var key = BridgeTypes.GetTypeDefinitionKey(type.TypeDefinition);
                type.Emitter  = emitter;
                type.Type     = ReflectionHelper.ParseReflectionName(key).Resolve(emitter.Resolver.Resolver.TypeResolveContext);
                type.TypeInfo = emitter.Types.FirstOrDefault(t => t.Key == key);

                if (type.TypeInfo != null && emitter.TypeInfoDefinitions.ContainsKey(type.TypeInfo.Key))
                {
                    var typeInfo = this.Emitter.TypeInfoDefinitions[type.Key];

                    type.TypeInfo.Module       = typeInfo.Module;
                    type.TypeInfo.FileName     = typeInfo.FileName;
                    type.TypeInfo.Dependencies = typeInfo.Dependencies;
                }

                typesOfTypeDefinition_.Add(type.TypeDefinition, type);
                typesOfFullName_.Add(type.TypeDefinition.FullName, type);
                typesOfIType_.Add(type.Type, type);
                namespaces_.Add(type.TypeDefinition.Namespace);
            }
        }
Beispiel #4
0
 public void InitItems(IEmitter emitter)
 {
     this.Emitter = emitter;
     foreach (var item in this)
     {
         var type = item.Value;
         var key  = BridgeTypes.GetTypeDefinitionKey(type.TypeDefinition);
         type.Emitter  = emitter;
         type.Type     = ReflectionHelper.ParseReflectionName(key).Resolve(emitter.Resolver.Resolver.TypeResolveContext);
         type.TypeInfo = emitter.Types.FirstOrDefault(t => t.Key == key);
     }
 }
Beispiel #5
0
        public void InitItems(IEmitter emitter)
        {
            this.Emitter = emitter;
            foreach (var item in this)
            {
                var type = item.Value;
                var key  = BridgeTypes.GetTypeDefinitionKey(type.TypeDefinition);
                type.Emitter  = emitter;
                type.Type     = ReflectionHelper.ParseReflectionName(key).Resolve(emitter.Resolver.Resolver.TypeResolveContext);
                type.TypeInfo = emitter.Types.FirstOrDefault(t => t.Key == key);

                if (type.TypeInfo != null && emitter.TypeInfoDefinitions.ContainsKey(type.TypeInfo.Key))
                {
                    var typeInfo = this.Emitter.TypeInfoDefinitions[type.Key];

                    type.TypeInfo.Module       = typeInfo.Module;
                    type.TypeInfo.FileName     = typeInfo.FileName;
                    type.TypeInfo.Dependencies = typeInfo.Dependencies;
                }
            }
        }
Beispiel #6
0
 public static string GetTypeDefinitionKey(TypeDefinition type)
 {
     return(BridgeTypes.GetTypeDefinitionKey(type.FullName));
 }
Beispiel #7
0
 public static string ToJsName(TypeDefinition type, IEmitter emitter, bool asDefinition = false, bool excludens = false, bool ignoreVirtual = false)
 {
     return(BridgeTypes.ToJsName(ReflectionHelper.ParseReflectionName(BridgeTypes.GetTypeDefinitionKey(type)).Resolve(emitter.Resolver.Resolver.TypeResolveContext), emitter, asDefinition, excludens, ignoreVirtual: ignoreVirtual));
 }
Beispiel #8
0
 public static string ToJsName(TypeDefinition type, IEmitter emitter, bool asDefinition = false)
 {
     return(BridgeTypes.ToJsName(ReflectionHelper.ParseReflectionName(BridgeTypes.GetTypeDefinitionKey(type)).Resolve(emitter.Resolver.Resolver.TypeResolveContext), emitter, asDefinition));
 }