예제 #1
0
        private IEnumerable <NamespaceEntity> RegisterNamespaceTypesAsTypeEntities(IEnumerable <NamespaceDefinition> namespaceDefinitions)
        {
            var apiNamespaceEntities = new HashSet <NamespaceEntity>();

            foreach (var namespaceDefinition in namespaceDefinitions)
            {
                var clonedNamespaceDefinition = SerializationHelper.DeserializeTo <NamespaceDefinition>(namespaceDefinition);
                var namespaceEntity           = namespaceEntityRegistrar.RegisterNamespace(clonedNamespaceDefinition);
                if (namespaceEntity is null || !namespaceRegistrationFilter.ShouldProcess(namespaceEntity))
                {
                    continue;
                }

                typeEntityRegistrar.RegisterNamespaceTypes(clonedNamespaceDefinition.Types, namespaceEntity);

                if (ShouldRegisterNamespaceApi(clonedNamespaceDefinition))
                {
                    apiNamespaceEntities.Add(namespaceEntity);
                    while (namespaceEntity.Parent is not null)
                    {
                        namespaceEntity = namespaceEntity.Parent;
                        apiNamespaceEntities.Add(namespaceEntity);
                    }
                }
            }

            return(apiNamespaceEntities);
        }
예제 #2
0
        private IEnumerable <ClassEntity> RegisterNamespaceTypesAndApi(IEnumerable <NamespaceDefinition> namespaceDefinitions)
        {
            var apiClassEntities = new List <ClassEntity>();

            foreach (var namespaceDefinition in namespaceDefinitions)
            {
                var namespaceEntity = namespaceEntityRegistrar.RegisterNamespace(namespaceDefinition);
                if (namespaceEntity is null)
                {
                    continue;
                }

                if (registrationOptions.ExcludeNamespaces.Contains(namespaceEntity.Name))
                {
                    logger.LogWarning($"Skipped namespace '{namespaceEntity.Name}'.");
                    continue;
                }

                if (!registrationOptions.IncludeNamespaces.Contains(namespaceEntity.Name))
                {
                    logger.LogError($"Namespace '{namespaceEntity.Name}' is not recognized.");
                    continue;
                }

                typeEntityRegistrar.RegisterNamespaceTypes(namespaceDefinition.Types, namespaceEntity);

                if (ShouldRegisterNamespaceApi(namespaceDefinition))
                {
                    var namespaceApiTypeDefinition = GetNamespaceApiTypeDefinition(namespaceDefinition, namespaceEntity);
                    var classEntity = classEntityRegistrar.RegisterNamespaceApi(namespaceApiTypeDefinition, namespaceEntity);
                    apiClassEntities.Add(classEntity);
                }
            }

            return(apiClassEntities);
        }