public void Refresh() { var validators = new Dictionary <Type, IRegistrationValidator>() { [typeof(ContainerRegistrationDirect)] = new DirectRegistrationValidator(), [typeof(ContainerRegistrationMethod)] = new MethodRegistrationValidator() }; var generators = new Dictionary <Type, ICodeRegistrationGenerator>() { [typeof(ContainerRegistrationDirect)] = new DirectCodeRegistrationGenerator(), [typeof(ContainerRegistrationMethod)] = new MethodCodeRegistrationGenerator() }; var validator = new ContainerDependencyValidator(validators); var generator = new StatorCodeGenerator(validator, generators); var factoryBaseType = typeof(ContainerFactory); var factoryTypes = AppDomain.CurrentDomain .GetAssemblies() .SelectMany(a => a.GetTypes()) .Where(t => factoryBaseType.IsAssignableFrom(t)) .Where(t => t != factoryBaseType) .ToArray(); var asmdefFolders = GetAsmDefToFolder(); var files = Generate(generator, factoryTypes, asmdefFolders); var allFiles = GetAllGeneratedFiles(asmdefFolders); var fileForDelete = allFiles.Except(files); foreach (var deletingFile in fileForDelete) { Info($"Remove old file {deletingFile}"); File.Delete(deletingFile); } AssetDatabase.Refresh(); DebugInfo($"Finish generating code"); }
public StatorCodeGenerator(ContainerDependencyValidator validator, IDictionary <Type, ICodeRegistrationGenerator> registrationGenerators) { Validator = validator; RegistrationGenerators = registrationGenerators; }