Ejemplo n.º 1
0
        public HttpResponseMessage GetByCode(string code)
        {
            var settings = this.Configuration.GetJsServerSettings();

            if (settings == null)
            {
                throw new InvalidOperationException("Js server settings must be set to use js server");
            }

            if (settings.Builder == null)
            {
                throw new InvalidOperationException("Page builder must be set to use js server");
            }

            var builder = new HtmlPageBuilder(settings.Builder);

            if (!string.IsNullOrEmpty(code))
            {
                builder.ScriptCode.Add(Encoding.UTF8.GetString(Convert.FromBase64String(code)));
            }
            string content = builder.Build(settings.Root);

            HttpResponseMessage response = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            response.Content = new StringContent(content, Encoding.UTF8, "text/html");
            return(response);
        }
Ejemplo n.º 2
0
 public HtmlPageBuilder(HtmlPageBuilder builder) : this()
 {
     ScriptReferences.AddRange(builder.ScriptReferences);
     ScriptCode.AddRange(builder.ScriptCode);
     CssReferences.AddRange(builder.CssReferences);
     CssCode.AddRange(builder.CssCode);
     Title         = builder.Title;
     BodyContent   = builder.BodyContent;
     HeaderContent = builder.HeaderContent;
 }
Ejemplo n.º 3
0
 public HtmlPageBuilder(HtmlPageBuilder builder) : this()
 {
     ScriptReferences.AddRange(builder.ScriptReferences);
     ScriptCode.AddRange(builder.ScriptCode);
     CssReferences.AddRange(builder.CssReferences);
     CssCode.AddRange(builder.CssCode);
     Title = builder.Title;
     BodyContent = builder.BodyContent;
     HeaderContent = builder.HeaderContent;
 }
Ejemplo n.º 4
0
        public HttpResponseMessage GetByCode(string code)
        {
            var settings = this.Configuration.GetJsServerSettings();
            if (settings == null)
            {
                throw new InvalidOperationException("Js server settings must be set to use js server");
            }

            if (settings.Builder == null)
            {
                throw new InvalidOperationException("Page builder must be set to use js server");
            }

            var builder = new HtmlPageBuilder(settings.Builder);
            if (!string.IsNullOrEmpty(code))
            {
                builder.ScriptCode.Add(Encoding.UTF8.GetString(Convert.FromBase64String(code)));
            }
            string content = builder.Build(settings.Root);

            HttpResponseMessage response = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
            response.Content = new StringContent(content, Encoding.UTF8, "text/html");
            return response;
        }
Ejemplo n.º 5
0
 public JsServerSettings()
 {
     ResourceLoadFrom = new List <Assembly>();
     ResourceLoadFrom.Add(this.GetType().Assembly);
     Builder = new HtmlPageBuilder();
 }
Ejemplo n.º 6
0
 public JsServerSettings()
 {
     ResourceLoadFrom = new List<Assembly>();
     ResourceLoadFrom.Add(this.GetType().Assembly);
     Builder = new HtmlPageBuilder();
 }