예제 #1
0
        public IEnumerable <StatementSyntax> GetInitialization()
        {
            var bufferType = SF.ArrayType(SH.PredefinedType(SyntaxKind.ByteKeyword),
                                          SF.SingletonList(SF.ArrayRankSpecifier(SF.SingletonSeparatedList((ExpressionSyntax)SH.Literal(BufferSize)))));

            yield return(SH.LocalDeclaration(SF.IdentifierName("var"), outputBuffer,
                                             SF.ArrayCreationExpression(bufferType)));

            yield return(SH.LocalDeclaration(SH.PredefinedType(SyntaxKind.IntKeyword), outputIndex, SH.Literal(0)));
        }
예제 #2
0
        public IEnumerable <StatementSyntax> GetInitialization()
        {
            yield return(SH.LocalDeclaration(SF.IdentifierName("var"), output,
                                             SF.ObjectCreationExpression(_stringBuilder.CreateSyntax())
                                             .WithArgumentList(SF.ArgumentList(SF.SeparatedList <ArgumentSyntax>()))));

            var bufferType = SF.ArrayType(SH.PredefinedType(SyntaxKind.CharKeyword),
                                          SF.SingletonList(SF.ArrayRankSpecifier(SF.SingletonSeparatedList((ExpressionSyntax)SH.Literal(BufferSize)))));

            yield return(SH.LocalDeclaration(SF.IdentifierName("var"), outputBuffer,
                                             SF.ArrayCreationExpression(bufferType)));

            yield return(SH.LocalDeclaration(SH.PredefinedType(SyntaxKind.IntKeyword), outputIndex, SH.Literal(0)));
        }
        static IEnumerable <MemberDeclarationSyntax> ColumnToMembers(string column, IEnumerable <IFieldSymbol> fields)
        {
            var        fieldsList = fields.ToList();
            TypeSyntax columnElementType;

            if (fieldsList.Count > 1)
            {
                var fieldGroupTypeName = SF.IdentifierName($"{column}_t");
                yield return(SF.StructDeclaration(fieldGroupTypeName.Identifier)
                             .WithMembers(SF.List(fields.Select(x => SF.FieldDeclaration(SF.VariableDeclaration(
                                                                                             SF.IdentifierName(x.Type.Name),
                                                                                             SF.SingletonSeparatedList(SF.VariableDeclarator(x.Name))))).Cast <MemberDeclarationSyntax>())));

                columnElementType = fieldGroupTypeName;
            }
            else
            {
                columnElementType = SF.IdentifierName(fields.First().Type.Name);
            }

            yield return(SF.FieldDeclaration(SF.VariableDeclaration(
                                                 SF.ArrayType(columnElementType, SF.SingletonList(SF.ArrayRankSpecifier())),
                                                 SF.SingletonSeparatedList(SF.VariableDeclarator(column)))));
        }
        public IEnumerable <ParameterSyntax> GetParameters()
        {
            var inputArrayType = SF.ArrayType(_inputType, SF.SingletonList(SF.ArrayRankSpecifier()));

            return(new[] { SF.Parameter(inputParameter).WithType(inputArrayType) });
        }