예제 #1
0
        private static AccessorDeclarationSyntax GenerateGetter(CsField csElement,
                                                                PropertyValueGetTransform valueTransformation)
        {
            ExpressionSyntax valueExpression = ParseName(csElement.IntermediateMarshalName);

            return(AccessorDeclaration(SyntaxKind.GetAccessorDeclaration)
                   .WithExpressionBody(
                       ArrowExpressionClause(
                           valueTransformation != null
                               ? valueTransformation(GeneratorHelpers.WrapInParentheses(valueExpression))
                               : valueExpression
                           )
                       )
                   .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)));
        }
예제 #2
0
        private static PropertyValueGetTransform Compose(PropertyValueGetTransform second,
                                                         PropertyValueGetTransform first)
        {
            if (second == null)
            {
                return(first);
            }
            if (first == null)
            {
                return(second);
            }

            return(x =>
            {
                var value = first(x);
                return second(GeneratorHelpers.WrapInParentheses(value));
            });
        }
예제 #3
0
 private PropertyDeclarationSyntax GenerateProperty(CsField csElement, TypeSyntax propertyType,
                                                    PropertyValueGetTransform getterTransform,
                                                    PropertyValueSetTransform setterTransform) =>
 AddDocumentationTrivia(
     PropertyDeclaration(propertyType, csElement.Name)
     .WithAccessorList(
         AccessorList(
             List(
                 new[]
 {
     GenerateGetter(csElement, getterTransform),
     GenerateSetter(csElement, setterTransform)
 }
                 )
             )
         )
     .WithModifiers(csElement.VisibilityTokenList),
     csElement
     );