public static HtmlResult <HElement> HView(object _state, JsonData[] jsons, HContext context)
        {
            var state = _state.As <MonitorState>() ?? new MonitorState();

            state = Execute(jsons, state);

            var result         = ImmutableGenerator.Generate(System.IO.File.ReadAllText(context.HttpContext.Server.MapPath("~/Examples/Main.cs")));
            var originalResult = System.IO.File.ReadAllText(context.HttpContext.Server.MapPath("~/Examples/Main.g.cs"));

            var page = h.Html(
                h.Head
                (
                ),
                h.Body
                (
                    result == originalResult,
                    h.Div(DateTime.UtcNow)
                )
                );

            return(new HtmlResult <HElement>
            {
                Html = page,
                State = state,
            });
        }
Exemple #2
0
        static MemberDeclarationSyntax ToClass(InterfaceDeclarationSyntax @interface)
        {
            var @class = s.ClassDeclaration(@interface.Identifier.Text.Substring(1)).AddModifiers(s.Token(SyntaxKind.PublicKeyword), s.Token(SyntaxKind.PartialKeyword));

            @class = @class.AddBaseListTypes(s.SimpleBaseType(s.IdentifierName(@interface.Identifier)));

            foreach (var property in @interface.Members.OfType <PropertyDeclarationSyntax>())
            {
                @class = @class.AddMembers(s.PropertyDeclaration(property.Type, property.Identifier)
                                           .AddModifiers(s.Token(SyntaxKind.PublicKeyword))
                                           .AddAccessorListAccessors(
                                               s.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration).WithSemicolonToken(s.Token(SyntaxKind.SemicolonToken)),
                                               s.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration).AddModifiers(s.Token(SyntaxKind.PrivateKeyword)).WithSemicolonToken(s.Token(SyntaxKind.SemicolonToken))
                                               ));
            }

            var members = @interface.Members.OfType <PropertyDeclarationSyntax>()
                          .Select(property => ImmutableGenerator.ToMember(property.Identifier, property.Type, null, null))
                          .ToArray();

            //var members = Array<ImmutableGenerator.Member>.Empty;

            @class = @class.AddMembers(ImmutableGenerator.GenerateConstructorAndWithMethod(@class.Identifier.Text, members).Members.ToArray());

            return(@class);
        }
Exemple #3
0
        public static void Execute()
        {
            var code   = File.ReadAllText(@"p:\Projects\NitroBolt.CodeGeneration\NitroBolt.CodeGeneration.Sample\ImmutableR.cs");
            var g_code = ImmutableGenerator.Generate(code);

            File.WriteAllText("q.cs", g_code);
        }