Exemplo n.º 1
0
        public static string AddModule(string name, BridgeType type, bool excludeNs, bool isNested, out bool isCustomName)
        {
            isCustomName = false;
            var    emitter         = type.Emitter;
            var    currentTypeInfo = emitter.TypeInfo;
            Module module          = null;
            string moduleName      = null;

            if (type.TypeInfo == null)
            {
                BridgeTypes.EnsureModule(type);
                module = type.Module;
            }
            else
            {
                module = type.TypeInfo.Module;
            }

            if (currentTypeInfo != null && module != null)
            {
                if (emitter.Tag != "TS" || currentTypeInfo.Module == null || !currentTypeInfo.Module.Equals(module))
                {
                    if (!module.PreventModuleName || (currentTypeInfo.Module != null && currentTypeInfo.Module.Equals(module)))
                    {
                        moduleName = module.ExportAsNamespace;
                    }

                    EnsureDependencies(type, emitter, currentTypeInfo, module);
                }
            }

            return(GetCustomName(name, type, excludeNs, isNested, ref isCustomName, moduleName));
        }
Exemplo n.º 2
0
        public static string AddModule(string name, BridgeType type, bool excludeNs, out bool isCustomName)
        {
            isCustomName = false;
            var    emitter         = type.Emitter;
            var    currentTypeInfo = emitter.TypeInfo;
            Module module          = null;
            string moduleName      = null;

            if (type.TypeInfo == null)
            {
                BridgeTypes.EnsureModule(type);
                module = type.Module;
            }
            else
            {
                module = type.TypeInfo.Module;
            }

            if (currentTypeInfo != null && module != null)
            {
                if (!module.PreventModuleName || type.TypeInfo != null)
                {
                    moduleName = module.ExportAsNamespace;
                }

                EnsureDependencies(type, emitter, currentTypeInfo, module);
            }

            var customName = emitter.Validator.GetCustomTypeName(type.TypeDefinition, emitter, excludeNs);

            if (!String.IsNullOrEmpty(customName))
            {
                isCustomName = true;
                name         = customName;
            }

            if (!String.IsNullOrEmpty(moduleName))
            {
                name = string.IsNullOrWhiteSpace(name) ? moduleName : (moduleName + "." + name);
            }

            return(name);
        }