Ejemplo n.º 1
0
        ParameterSyntax[] TransformParameters(Method method)
        {
            var list = new List <ParameterSyntax>();

            if (method.Params.Count > 0)
            {
                var arg0 = method.Params[0];

                if (arg0.Name == null)
                {
                    list.Add(Parameter(_names.AnonymousParameter.Identifier)
                             .WithType(_names.MakeTypeSyntax(arg0.Type, method.DeclaringInterface, TypeUsage.DomainClass)));
                }
                else
                {
                    foreach (var arg in method.Params)
                    {
                        list.Add(Parameter(Identifier(IdentifierRenamer.ToNonKeyword(arg.Name)))
                                 .WithType(_names.MakeTypeSyntax(arg.Type, method.DeclaringInterface, TypeUsage.DomainClass)));
                    }
                }
            }

            list.Add(Parameter(_names.CancellationTokenParameter.Identifier)
                     .WithType(IdentifierName(nameof(CancellationToken)))
                     .WithDefault(EqualsValueClause(LiteralExpression(
                                                        SyntaxKind.DefaultLiteralExpression,
                                                        Token(SyntaxKind.DefaultKeyword)))));

            return(list.ToArray());
        }
Ejemplo n.º 2
0
        public string GetCodeIdentifier(TypeDefinition def)
        {
            string id = def.CsName ?? def.Name;

            if (def.Tag == TypeTag.Group) // special treatment for groups: Need to disambiguate between
            {                             // the field name (use original name) and its type (make it start with a lower-case letter)
                id = IdentifierRenamer.ToNonKeyword(SyntaxHelpers.MakeLowerCamel(id));
            }
            return(id);
        }
 IEnumerable <ExpressionSyntax> MakeSkeletonMethodResultStructInitializer(Method method)
 {
     foreach (var arg in method.Results)
     {
         yield return(AssignmentExpression(
                          SyntaxKind.SimpleAssignmentExpression,
                          _names.GetCodeIdentifier(arg).IdentifierName,
                          IdentifierName(IdentifierRenamer.ToNonKeyword(arg.Name))));
     }
 }
Ejemplo n.º 4
0
 IEnumerable <ExpressionSyntax> MakeProxyCallInitializerAssignments(Method method)
 {
     foreach (var methodParam in method.Params)
     {
         yield return(AssignmentExpression(
                          SyntaxKind.SimpleAssignmentExpression,
                          _names.GetCodeIdentifier(methodParam).IdentifierName,
                          IdentifierName(IdentifierRenamer.ToNonKeyword(methodParam.Name))));
     }
 }
Ejemplo n.º 5
0
 string GetCodeIdentifierLowerCamel(Field field) => field.CsName ?? IdentifierRenamer.ToNonKeyword(SyntaxHelpers.MakeLowerCamel(field.Name));
Ejemplo n.º 6
0
 public Name GetCodeIdentifier(Method method)
 {
     return(new Name(method.CsName ?? IdentifierRenamer.ToNonKeyword(SyntaxHelpers.MakeUpperCamel(method.Name))));
 }