private IEnumerable <ParameterSyntax> GetConstructorParameters(TransportModelEntity entityModel, out List <StatementSyntax> propertyInitializers, out List <ArgumentSyntax> baseConstructorArguments)
        {
            List <ParameterSyntax> result       = new List <ParameterSyntax>();
            List <StatementSyntax> initializers = new List <StatementSyntax>();
            List <ArgumentSyntax>  baseArgs     = new List <ArgumentSyntax>();

            var members     = CsEmitterHelper.GetMembers(entityModel);
            var baseMembers = entityModel.BaseEntity != null
                ? CsEmitterHelper.GetMembers(entityModel.BaseEntity.TransportModelItem, entityModel.BaseEntity.GenericArguments)
                : new Dictionary <string, TransportModelEntityMember>();

            foreach (var member in members)
            {
                if (member.Key != "kind")
                {
                    result.Add(Parameter(List <AttributeListSyntax>(), TokenList(), ParseTypeName(CsEmitterHelper.GetAstModelPropertyTypeName(member.Value, this.settings, true)), Identifier(NameHelper.GetSafeVariableName(member.Key)), null));

                    if (baseMembers.ContainsKey(member.Key))
                    {
                        baseArgs.Add(Argument(IdentifierName(NameHelper.GetSafeVariableName(member.Key))));
                    }
                    else
                    {
                        if (CsEmitterHelper.IsNodeCollection(member.Value.Type))
                        {
                            initializers.Add(
                                ExpressionStatement(
                                    InvocationExpression(
                                        MemberAccessExpression(
                                            SyntaxKind.SimpleMemberAccessExpression,
                                            MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, ThisExpression(), IdentifierName(NameHelper.GetSafeVariableName(member.Key))),
                                            IdentifierName("AddRange")),
                                        ArgumentList(SeparatedList <ArgumentSyntax>(new[] { Argument(IdentifierName(NameHelper.GetSafeVariableName(member.Key))) })))));
                        }
                        else
                        {
                            initializers.Add(
                                ExpressionStatement(
                                    AssignmentExpression(
                                        SyntaxKind.SimpleAssignmentExpression,
                                        MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, ThisExpression(), IdentifierName(NameHelper.GetSafeVariableName(member.Key))),
                                        IdentifierName(NameHelper.GetSafeVariableName(member.Key)))));
                        }
                    }
                }
            }

            if (entityModel.TsDiscriminant is TransportModelEntityTsDiscriminantBrand brandDiscriminant)
            {
                var member = entityModel.GetMemberByName(brandDiscriminant.BrandPropertyName);
                if (member != null)
                {
                    initializers.Add(
                        ExpressionStatement(
                            AssignmentExpression(
                                SyntaxKind.SimpleAssignmentExpression,
                                MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, ThisExpression(), IdentifierName(NameHelper.GetSafeVariableName(member.Name))),
                                ObjectCreationExpression(ParseTypeName(CsEmitterHelper.GetAstModelPropertyTypeName(member, this.settings)), ArgumentList(), null))));
                }
            }

            propertyInitializers     = initializers;
            baseConstructorArguments = baseArgs;
            return(result);
        }
        public static Dictionary <string, TransportModelEntityMember> GetMembers(TransportModelEntity entityModel, List <TransportModelTypeReference> genericArgumentsInScope = null, bool allMembers = false)
        {
            Dictionary <string, TransportModelEntityMember> result = new Dictionary <string, TransportModelEntityMember>();

            if (entityModel.BaseEntity != null)
            {
                result = GetMembers(entityModel.BaseEntity.TransportModelItem, entityModel.BaseEntity.GenericArguments, allMembers);
            }

            var members = entityModel.Members.Keys.Select(m => genericArgumentsInScope == null ? entityModel.GetMemberByName(m) : entityModel.GetMemberByNameAndResolveGenericArguments(m, genericArgumentsInScope));

            foreach (var member in members)
            {
                var finalMember = member;

                if (entityModel.MemberTypeLimiters.ContainsKey(member.Name))
                {
                    finalMember = entityModel.MemberTypeLimiters[member.Name];
                }

                if (result.ContainsKey(member.Name))
                {
                    result[member.Name] = finalMember;
                }
                else
                {
                    result.Add(member.Name, finalMember);
                }
            }

            if (!allMembers && entityModel.TsDiscriminant is TransportModelEntityTsDiscriminantBrand brandDiscriminant && result.ContainsKey(brandDiscriminant.BrandPropertyName))
            {
                result.Remove(brandDiscriminant.BrandPropertyName);
            }

            return(result);
        }