예제 #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;
        }
예제 #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");
        }
예제 #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);
            }
        }
예제 #4
0
파일: BridgeType.cs 프로젝트: txdv/Builder
 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);
     }
 }
예제 #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;
                }
            }
        }
예제 #6
0
 public static string GetTypeDefinitionKey(TypeDefinition type)
 {
     return(BridgeTypes.GetTypeDefinitionKey(type.FullName));
 }
예제 #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));
 }
예제 #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));
 }