예제 #1
0
        private static string concurrentBody(ClassDeclarationSyntax @class, IServerConfiguration config, SemanticModel model)
        {
            var result = new StringBuilder();

            ConcurrentExtension.Visit(@class,
                                      methods: (name, type, parameters) =>
            {
                result.AppendLine(Templates
                                  .jsMethod(new
                {
                    MethodName = name.ToString(),
                    Arguments  = argumentsFromParameters(parameters),
                    Data       = objectFromParameters(parameters),
                    Path       = "'/' + this.__ID + '/" + name.ToString() + "'",
                    Response   = calculateResponse(type, model),
                }));
            },
                                      fields: (name, type, value) =>
            {
                //td: shall we transmit properties?
                //result.AppendLine(Templates
                //    .jsProperty
                //    .Render(new
                //    {
                //        Name = name.ToString(),
                //        Value = valueString(value, type, model)
                //    }));
            });

            return(result.ToString());
        }
예제 #2
0
        private static void jsConcurrentClass(SyntaxNode node, Compilation compilation, Scope scope)
        {
            Debug.Assert(node is ClassDeclarationSyntax);
            var @class = node as ClassDeclarationSyntax;

            var config = scope.GetServerConfiguration();

            Debug.Assert(config != null);

            var body  = new StringBuilder();
            var model = compilation.getSemanticModel(node.SyntaxTree);

            ConcurrentExtension.Visit(@class,
                                      methods: (name, type, parameters) =>
            {
                body.AppendLine(Templates
                                .jsMethod
                                .Render(new
                {
                    Name      = name.ToString(),
                    Arguments = argumentsFromParameters(parameters),
                    Data      = objectFromParameters(parameters),
                    Response  = calculateResponse(type, model),
                }));
            },
                                      fields: (name, type, value) =>
            {
                body.AppendLine(Templates
                                .jsProperty
                                .Render(new
                {
                    Name  = name.ToString(),
                    Value = valueString(value, type, model)
                }));
            });

            config.AddClientInterface(node.SyntaxTree, Templates
                                      .jsConcurrentClass
                                      .Render(new
            {
                Name = @class.Identifier.ToString(),
                Body = body.ToString()
            }));
        }