コード例 #1
0
ファイル: MainWindow.cs プロジェクト: dgu123/crown
        public MainWindow() :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();

            //Set the ViewModels for each widget
            var crownTestsViewModel = new CrownTestsViewModel();

            BindingEngine.SetViewModel(this, crownTestsViewModel);
            //txtTestFolder and txtCrownTestsExe automatically inherit the view model of the MainWindow because it has not been not specified

            //Create and Apply templates for each widget
            Templating.ApplyTemplate(twTests,
                                     new TreeViewTemplate()
                                     .AddColumn("Name", new Gtk.CellRendererText())
                                     .AddColumn("State", new Gtk.CellRendererText())
                                     .AddRowTemplate(TreeViewRowTemplate.Create(typeof(TestCategory))
                                                     .SetBinding("Name", "Name"))
                                     .AddRowTemplate(TreeViewRowTemplate.Create(typeof(Test))
                                                     .SetBinding("Name", "Name")
                                                     .SetBinding("State", "LastResult")));

            Templating.ApplyTemplate(txtTestFolder,
                                     new EntryTemplate().SetTextBinding("TestFolder"));

            Templating.ApplyTemplate(txtCrownTestsExe,
                                     new EntryTemplate().SetTextBinding("CrownTestsExe"));

            LoadTestsData();
        }
コード例 #2
0
ファイル: TemplatingTester.cs プロジェクト: JackGilliam1/fubu
        public void should_add_a_bundler_step_if_there_are_any_gem_references()
        {
            var request = new TemplateRequest
            {
                SolutionName  = "Foo",
                RootDirectory = "Foo"
            };

            request.AddTemplate("baseline");

            Templating.BuildPlan(request)
            .Steps.OfType <BundlerStep>()
            .Count().ShouldEqual(1);
        }
コード例 #3
0
        static void Main()
        {
            string webDir = Path.Combine(Directory.GetCurrentDirectory(), "Site");

            //------------------- define routes -------------------
            Route.Before = (rq, rp) => { Console.WriteLine($"Requested: {rq.Url.PathAndQuery}"); return(false); };

            //home page
            Route.Add("/", (rq, rp, args) =>
            {
                rp.AsFile(rq, Path.Combine(webDir, "Index.html"));
            });

            //1) URL parsing demo
            Route.Add("/{action}/{paramA}-{paramB}", (rq, rp, args) =>
            {
                var txt = Templating.RenderFile(Path.Combine(webDir, "UrlParsingResponse.thtml"), args); //populate template
                rp.AsText(txt);
            });

            //2) serve file (and video streaming)
            Route.Add((rq, args) =>
            {
                args["file"] = Path.Combine(webDir, rq.Url.LocalPath.TrimStart('/'));
                return(Path.HasExtension(args["file"]));
            },
                      (rq, rp, args) => rp.AsFile(rq, args["file"]));

            //3) form parsing demo
            Route.Add("/upload/", (rq, rp, args) =>
            {
                var files = rq.ParseBody(args);

                foreach (var f in files.Values)
                {
                    f.Save(Path.Combine(webDir, f.FileName), true);
                }


                var txtRp = "Form fields: " + String.Join(";  ", args.Select(x => $"'{x.Key}: {x.Value}'")) + "\n" +
                            "Files:       " + String.Join(";  ", files.Select(x => $"'{x.Key}: {x.Value.FileName}, {x.Value.ContentType}'"));

                rp.AsText($"<pre>{txtRp}</pre>");
            },
                      "POST");

            //4) handle exception demo
            Route.Add("/handleException/", (rq, rp, args) =>
            {
                //to override/stylize default error response define a custom error function: Route.Error = (rq, rp, ex) => { };
                throw new NotImplementedException("My not implemented exception.");
            });


            //------------------- start server -------------------
            var port = 4443;

            Console.WriteLine("Running HTTP server on: " + port);

            var cts = new CancellationTokenSource();
            var ts  = HttpServer.ListenAsync(port, cts.Token, Route.OnHttpRequestAsync, useHttps: true);

            AppExit.WaitFor(cts, ts);
        }
コード例 #4
0
        private void Reload()
        {
            var repoType  = RepositoryTypeResolver.ResolveTypeByApiId(RepositoryId);
            var repo      = (IVersionedContentRepository)Activator.CreateInstance(repoType);
            var allDrafts = repo.FindContentVersions(BooleanExpression.None, ContentEnvironment.Draft).ToList();

            List <object> ds     = new List <object>();
            var           fields = Config.Fields;

            if (!Config.Fields.Any())
            {
                Config.Fields = new List <ContentListField>();

                var titleField = new ContentListField
                {
                    Header   = "Title",
                    Template = Templating.CreateToStringExpression(nameof(WarpCoreEntity.Title))
                };
                Config.Fields.Add(titleField);
            }

            foreach (var d in allDrafts)
            {
                var row   = new List <string>();
                var dict1 = d.GetPropertyValues(x => true);
                foreach (var f in fields)
                {
                    var val = Templating.Interpolate(f.Template, dict1);
                    row.Add(val);
                }

                ds.Add(row);
            }

            var fieldConfigurations = new List <object>();

            foreach (var f in fields)
            {
                fieldConfigurations.Add(new { title = f.Header });
            }


            var js = new JavaScriptSerializer();

            Data.Value   = js.Serialize(ds);
            Fields.Value = js.Serialize(fieldConfigurations);
            DataBind();

            //this.ContentListDataGrid.DataSource = ds;



            //this.ContentListDataGrid.AutoGenerateColumns = false;
            //foreach (var field in fields)
            //{
            //    this.ContentListDataGrid.Columns.Add(new BoundColumn { DataField = field, HeaderText = field });
            //}

            //this.ContentListDataGrid.DataBind();

            //var configFieldLookup = Configuration.Fields
            //    .Select(x => x.PropertyName)
            //    .ToDictionary(x => x, x => x);

            //foreach (var draft in allDrafts)
            //{
            //    var li = new ContentListItem
            //    {
            //        Values = draft.GetPropertyValues(x => configFieldLookup.ContainsKey(x.Name))
            //    };
            //    _controlState.Items.Add(li);
            //}
        }