예제 #1
0
        private IEnumerable <ClassEntity> RegisterNamespaceEntitiesAsClassEntities(IEnumerable <NamespaceEntity> namespaceEntities)
        {
            var nestedNamespaceEntities = namespaceEntities
                                          .Where(namespaceEntity => namespaceEntity.Parent is not null)
                                          .ToArray();

            return(namespaceEntities
                   .Except(nestedNamespaceEntities)
                   .SelectMany(namespaceEntity =>
            {
                var classEntity = classEntityRegistrar.RegisterNamespaceApi(namespaceEntity.NamespaceDefinitions, namespaceEntity);
                var nestedClassEntities = RegisterNestedNamespaceEntitiesAsPropertyToClassEntity(classEntity, nestedNamespaceEntities);
                return new[] { classEntity }.Concat(nestedClassEntities);
            })
                   .ToArray());
        }
예제 #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);
        }