public static void InitializeModules(AppDomain domain) { var assemblies = domain.GetAssemblies(); var allTypes = assemblies.SelectMany(x => x.GetTypes()).ToList(); var initializers = TypeSearcher.FindModulesKnownToWarpCore(allTypes); foreach (var moduleType in initializers) { var module = (IModuleInitializer)Activator.CreateInstance(moduleType); module.InitializeModule(); } }
public static void RegisterExtensibleTypesWithApi(AppDomain domain) { var assemblies = domain.GetAssemblies(); var allTypes = assemblies.SelectMany(x => x.GetTypes()).ToList(); var repositoryDescriptions = TypeSearcher.FindRepositoriesKnownToWarpCore(allTypes); foreach (var repositoryDescription in repositoryDescriptions) { BuildUpRepositoryMetadata(repositoryDescription); } //Break this one out later. var entities = TypeSearcher.FindEntitiesKnownToWarpCore(allTypes); var contentTypeMetadataRepository = new ContentTypeMetadataRepository(); var typeExtensionRepo = new ContentInterfaceRepository(); foreach (var entityType in entities) { var repositoryUid = entityType.GetCustomAttribute <WarpCoreEntityAttribute>(); var preexistingContentType = contentTypeMetadataRepository.Find().SingleOrDefault(x => x.TypeResolverId == repositoryUid.TypeExtensionUid); if (preexistingContentType == null) { preexistingContentType = new DynamicContentType { TypeResolverId = repositoryUid.TypeExtensionUid, } } ; preexistingContentType.ContentNameSingular = repositoryUid.ContentNameSingular; preexistingContentType.ContentNamePlural = repositoryUid.ContentNamePlural; if (string.IsNullOrWhiteSpace(preexistingContentType.ContentNameSingular)) { preexistingContentType.ContentNameSingular = entityType.Name; } if (string.IsNullOrWhiteSpace(preexistingContentType.ContentNamePlural)) { //todo: replace //PluralizationService.CreateService(CultureInfo.CurrentCulture) // .Pluralize(preexistingContentType.ContentNameSingular); } preexistingContentType.SupportsCustomFields = repositoryUid.SupportsCustomFields; preexistingContentType.TitleProperty = repositoryUid.TitleProperty; contentTypeMetadataRepository.Save(preexistingContentType); if (preexistingContentType.SupportsCustomFields) { var preexisting = typeExtensionRepo.Find().SingleOrDefault(x => x.ContentTypeId == repositoryUid.TypeExtensionUid && x.InterfaceName == KnownTypeExtensionNames.CustomFields); if (preexisting == null) { typeExtensionRepo.Save(new ContentInterface { ContentTypeId = repositoryUid.TypeExtensionUid, InterfaceName = KnownTypeExtensionNames.CustomFields }); } } } }