コード例 #1
0
            private static CSharpCodeGenerator Create(
                InsertionPoint insertionPoint,
                SelectionResult selectionResult,
                AnalyzerResult analyzerResult,
                CSharpCodeGenerationOptions options,
                NamingStylePreferencesProvider namingPreferences,
                bool localFunction)
            {
                if (ExpressionCodeGenerator.IsExtractMethodOnExpression(selectionResult))
                {
                    return(new ExpressionCodeGenerator(insertionPoint, selectionResult, analyzerResult, options, namingPreferences, localFunction));
                }

                if (SingleStatementCodeGenerator.IsExtractMethodOnSingleStatement(selectionResult))
                {
                    return(new SingleStatementCodeGenerator(insertionPoint, selectionResult, analyzerResult, options, namingPreferences, localFunction));
                }

                if (MultipleStatementsCodeGenerator.IsExtractMethodOnMultipleStatements(selectionResult))
                {
                    return(new MultipleStatementsCodeGenerator(insertionPoint, selectionResult, analyzerResult, options, namingPreferences, localFunction));
                }

                throw ExceptionUtilities.UnexpectedValue(selectionResult);
            }
コード例 #2
0
            private static CSharpCodeGenerator Create(
                InsertionPoint insertionPoint,
                SelectionResult selectionResult,
                AnalyzerResult analyzerResult)
            {
                if (ExpressionCodeGenerator.IsExtractMethodOnExpression(selectionResult))
                {
                    return(new ExpressionCodeGenerator(insertionPoint, selectionResult, analyzerResult));
                }

                if (SingleStatementCodeGenerator.IsExtractMethodOnSingleStatement(selectionResult))
                {
                    return(new SingleStatementCodeGenerator(insertionPoint, selectionResult, analyzerResult));
                }

                if (MultipleStatementsCodeGenerator.IsExtractMethodOnMultipleStatements(selectionResult))
                {
                    return(new MultipleStatementsCodeGenerator(insertionPoint, selectionResult, analyzerResult));
                }

                return(Contract.FailWithReturn <CSharpCodeGenerator>("Unknown selection"));
            }