Esempio n. 1
0
        public static IList <ParameterModel> Build(IMethodSymbol methodSymbol,
                                                   GeneratorExecutionContext context)
        {
            var models = new List <ParameterModel>();

            foreach (var parameter in methodSymbol.Parameters)
            {
                models.Add(new ParameterModel
                {
                    Name       = parameter.Name,
                    Type       = TypeModelBuilder.Build(parameter.Type, context),
                    Attributes = parameter.GetAttributes().Select(att => AttributeModelBuilder.Build(att, context)).ToList()
                });
            }

            return(models);
        }
Esempio n. 2
0
        public static LambdaMethodModel Build(IMethodSymbol lambdaMethodSymbol,
                                              IMethodSymbol configureMethodSymbol,
                                              GeneratorExecutionContext context)
        {
            var model = new LambdaMethodModel
            {
                IsAsync                  = lambdaMethodSymbol.IsAsync,
                ReturnType               = TypeModelBuilder.Build(lambdaMethodSymbol.ReturnType, context),
                ReturnsVoid              = lambdaMethodSymbol.ReturnsVoid,
                ReturnsTask              = lambdaMethodSymbol.ReturnType.Equals(context.Compilation.GetTypeByMetadataName("System.Threading.Tasks.Task"), SymbolEqualityComparer.Default),
                Parameters               = ParameterModelBuilder.Build(lambdaMethodSymbol, context),
                Name                     = lambdaMethodSymbol.Name,
                ContainingAssembly       = lambdaMethodSymbol.ContainingAssembly.Name,
                ContainingNamespace      = lambdaMethodSymbol.ContainingNamespace.ToDisplayString(),
                Events                   = EventTypeBuilder.Build(lambdaMethodSymbol, context),
                ContainingType           = TypeModelBuilder.Build(lambdaMethodSymbol.ContainingType, context),
                UsingDependencyInjection = configureMethodSymbol != null,
                Attributes               = lambdaMethodSymbol.GetAttributes().Select(att => AttributeModelBuilder.Build(att, context)).ToList()
            };

            return(model);
        }