示例#1
0
        private SyntaxList <StatementSyntax> CreateRegistrationStatement(SyntaxList <StatementSyntax> statements,
                                                                         string registratorIdentifier)
        {
            statements = statements.Add(
                SyntaxFactory.ExpressionStatement(SyntaxHelper.ToInvocationExpression(
                                                      SyntaxHelper.ToMemberAccessExpression(SyntaxHelper.ToInvocationExpression(
                                                                                                SyntaxHelper.ToMemberAccessExpression(registratorIdentifier, AddInstanceName), SyntaxHelper.ArgumentList(SyntaxHelper.ToInvocationExpression(_initializeContainerMethodName))),
                                                                                            SyntaxHelper.ToGenericName(AddSingletonName, _providerContractName, _fakeProviderName)))));

            statements = statements.Add(
                SyntaxFactory.ExpressionStatement(SyntaxHelper.ToInvocationExpression(
                                                      SyntaxHelper.ToMemberAccessExpression(registratorIdentifier, RegisterInstanceName), SyntaxHelper.ArgumentList(SyntaxHelper.ToInvocationExpression(
                                                                                                                                                                        SyntaxHelper.ToMemberAccessExpression(_providerBuilderName, CreateBuilderMethodName))))));

            return(statements);
        }
示例#2
0
        public override SyntaxNode VisitInitializerExpression(InitializerExpressionSyntax node)
        {
            if (NormalizeWhitespaceOnly &&
                node.IsKind(SyntaxKind.ArrayInitializerExpression) &&
                _checkingMethod != RegisterInstanceName)
            {
                var openBrace = node.OpenBraceToken.WithLeadingTrivia(SyntaxHelper.Whitespace(12));
                node = node.WithOpenBraceToken(openBrace);
                var closeBrace = node.CloseBraceToken.WithLeadingTrivia(SyntaxHelper.EndOfLineTrivia, SyntaxHelper.Whitespace(12));
                node = node.WithCloseBraceToken(closeBrace);
            }

            return(base.VisitInitializerExpression(node !));
        }