Files
ntpa/Ntp.Analyzer/Page/GraphPageBuilder.cs
T

91 lines
3.0 KiB
C#
Raw Normal View History

2016-03-05 14:06:38 +01:00
//
// GraphPageBuilder.cs
//
// Author:
2016-03-05 15:25:01 +01:00
// Carsten Sonne Larsen <cs@innolan.net>
2016-03-05 14:06:38 +01:00
//
2016-03-05 15:25:01 +01:00
// Copyright (c) 2014 Carsten Sonne Larsen
2016-03-05 14:06:38 +01:00
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
2016-03-05 15:25:01 +01:00
2016-03-05 14:06:38 +01:00
using System.Collections.Generic;
2016-03-05 15:25:01 +01:00
using System.IO;
using Ntp.Analyzer.Config.Destination;
2016-03-05 14:06:38 +01:00
using Ntp.Analyzer.Config.Graph;
2016-03-05 15:25:01 +01:00
using Ntp.Analyzer.Config.Page;
using Ntp.Analyzer.Export;
2016-03-05 14:06:38 +01:00
using Ntp.Analyzer.Objects;
2016-03-05 15:25:01 +01:00
using Ntp.Analyzer.Render;
using Ntp.Analyzer.Render.Graph;
2016-03-05 14:06:38 +01:00
namespace Ntp.Analyzer.Page
{
public sealed class GraphPageBuilder : PageBuilderBase
{
2016-03-05 15:25:01 +01:00
public GraphPageBuilder(
2016-03-05 14:06:38 +01:00
GraphPageConfiguration config,
NamedObject namedObject,
string prefix,
GraphSetConfiguration graphSet,
2016-03-05 15:25:01 +01:00
GraphBaseConfiguration graph,
string file)
2016-03-05 14:06:38 +01:00
{
this.config = config;
this.namedObject = namedObject;
this.prefix = prefix;
this.graphSet = graphSet;
this.graph = graph;
2016-03-05 15:25:01 +01:00
this.file = file;
2016-03-05 14:06:38 +01:00
}
private readonly GraphPageConfiguration config;
2016-03-05 15:25:01 +01:00
private readonly GraphBaseConfiguration graph;
private readonly GraphSetConfiguration graphSet;
2016-03-05 14:06:38 +01:00
private readonly NamedObject namedObject;
private readonly string prefix;
2016-03-05 15:25:01 +01:00
private readonly string file;
public override IEnumerable<StreamDestination> Destinations
{
get { return config.Destinations.Destinations; }
2016-03-05 14:06:38 +01:00
}
2016-03-05 15:25:01 +01:00
public string File {
get { return file; }
}
public override Stream Generate()
2016-03-05 14:06:38 +01:00
{
2016-03-05 15:25:01 +01:00
BootstrapGrapPageRender page = new BootstrapGrapPageRender(
2016-03-05 14:06:38 +01:00
config.WebPath,
namedObject,
config.Title,
2016-03-05 15:25:01 +01:00
prefix,
2016-03-05 14:06:38 +01:00
graphSet,
graph);
// Generate HTML
2016-03-05 15:25:01 +01:00
HtmlRenderer htmlRender = new HtmlRenderer(page);
string html = htmlRender.Render();
2016-03-05 14:06:38 +01:00
2016-03-05 15:25:01 +01:00
return ToStream(html);
2016-03-05 14:06:38 +01:00
}
}
}