/// <summary> /// Initializes TS exporter. Reads all types configuration, applies fluent configuration, resolves references /// </summary> public void Initialize() { if (_isInitialized) { return; } // 1st step - searching and processing [TsGlobal] attribute var tsGlobal = _context.SourceAssemblies.Select(c => c.GetCustomAttribute <TsGlobalAttribute>()) .Where(c => c != null) .OrderByDescending(c => c.Priority) .FirstOrDefault(); ApplyTsGlobal(tsGlobal, _context.Global); // 2nd step - searching and processing fluent configuration var fluentConfigurationPresents = _context.ConfigurationMethod != null; if (fluentConfigurationPresents) { var configurationBuilder = new ConfigurationBuilder(_context); _context.ConfigurationMethod(configurationBuilder); } _context.Documentation = new DocumentationManager(_context.Global.GenerateDocumentation ? _context.DocumentationFilePath : null, _context.Warnings); foreach (var additionalDocumentationPath in _context.Project.AdditionalDocumentationPathes) { _context.Documentation.CacheDocumentation(additionalDocumentationPath, _context.Warnings); } _allTypes = _context.SourceAssemblies .SelectMany(c => c._GetTypes(_context.Warnings).Where(d => d.GetCustomAttribute <TsAttributeBase>(false) != null)) .Union(_context.Project.BlueprintedTypes).Distinct() .ToList(); _allTypesHash = new HashSet <Type>(_allTypes); ReferenceInspector = new ReferenceInspector(_context, _allTypesHash); if (_context.Hierarchical) { foreach (var type in _allTypesHash) { _context.Project.AddFileSeparationSettings(type); } } GlobalReferences = ReferenceInspector.InspectGlobalReferences(); _context.Generators = new GeneratorManager(_context); if (!_context.Hierarchical) { _typesToFilesMap = new Dictionary <string, IEnumerable <Type> >(); } else { _typesToFilesMap = _allTypes.GroupBy(c => ReferenceInspector.GetPathForType(c, stripExtension: false)) .ToDictionary(c => c.Key, c => c.AsEnumerable()); } _isInitialized = true; }
/// <summary> /// Constructs new type resolver /// </summary> internal TypeResolver(ExportContext context, ExportedFile file, ReferenceInspector refInspector) { _context = context; _file = file; _refInspector = refInspector; }