private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.cboFormatter.SelectedIndex > -1) { switch (this.cboFormatter.SelectedIndex) { case 0: this._formatter = new NTriplesFormatter(); break; case 1: this._formatter = new TurtleFormatter(this._g); break; case 2: this._formatter = new UncompressedTurtleFormatter(); break; case 3: this._formatter = new Notation3Formatter(this._g); break; case 4: this._formatter = new UncompressedNotation3Formatter(); break; case 5: this._formatter = new CsvFormatter(); break; case 6: this._formatter = new TsvFormatter(); break; } this.RenderTriples(); } }
/// <summary> /// Displays the Result as a comma separated string of paris of the form ?var = value where values are formatted using the given Node Formatter /// </summary> /// <param name="formatter">Node Formatter</param> /// <returns></returns> public String ToString(INodeFormatter formatter) { StringBuilder output = new StringBuilder(); if (this._resultValues.Count == 0) { return("<Empty Result>"); } foreach (String var in this._variables) { output.Append("?"); output.Append(var); output.Append(" = "); INode value; if (this._resultValues.TryGetValue(var, out value) && value != null) { output.Append(value.ToString(formatter)); } output.Append(" , "); } String outString = output.ToString(); if (outString.Length > 3) { return(outString.Substring(0, outString.Length - 3)); } else { return(String.Empty); } }
/// <summary> /// Creates an instance of the given formatter using the namespaces provided if possible /// </summary> /// <param name="namespaces">Namespaces</param> /// <returns></returns> public INodeFormatter CreateInstance(INamespaceMapper namespaces) { if (namespaces != null) { try { INodeFormatter formatter = (INodeFormatter)Activator.CreateInstance(this.Type, new object[] { namespaces }); return(formatter); } catch { // Ignore } } try { INodeFormatter formatter = (INodeFormatter)Activator.CreateInstance(this.Type); return(formatter); } catch (Exception) { // Fallback to default formatter return(new SparqlFormatter()); } }
public UriNodeControl(IUriNode u, INodeFormatter formatter) { InitializeComponent(); this.lnkUri.Text = formatter.Format(u); this._u = u.Uri; }
public ResultSetWindow(SparqlResultSet results) { InitializeComponent(); this._formatter = new SparqlFormatter(); this._grid = this.gridResults; this.RenderResultSet(results); }
public RdfFileGenerator(IResourceFileMapper resourceMap, IEnumerable <Uri> graphFilter, IProgressLog progressLog, int reportInterval) { _resourceMap = resourceMap; _graphFilter = graphFilter?.ToList() ?? new List <Uri>(0); _noFilter = _graphFilter.Count == 0; _nquadsFormatter = new NQuads11Formatter(); _progressLog = progressLog; _reportInterval = reportInterval; }
public ResultSetViewerForm(SparqlResultSet results, String title, INamespaceMapper nsmap) : this(results, title) { this._nsmap = nsmap; if (nsmap != null) { this._formatter = new SparqlFormatter(nsmap); } }
public TriplesWindow(IGraph g, INodeFormatter formatter) { InitializeComponent(); this._formatter = formatter; this._g = g; this._grid = this.gridTriples; this.RenderTriples(); }
/// <summary> /// Displays the given Graph /// </summary> /// <param name="g">Graph to display</param> public GraphViewerForm(IGraph g) { InitializeComponent(); if (Constants.WindowIcon != null) { this.Icon = Constants.WindowIcon; } //Load Formatters List <INodeFormatter> formatters = new List <INodeFormatter>(); Type targetType = typeof(INodeFormatter); foreach (Type t in Assembly.GetAssembly(targetType).GetTypes()) { if (t.Namespace == null) { continue; } if (t.Namespace.Equals("VDS.RDF.Writing.Formatting")) { if (t.GetInterfaces().Contains(targetType)) { try { INodeFormatter formatter = (INodeFormatter)Activator.CreateInstance(t); formatters.Add(formatter); if (formatter.GetType().Equals(this._formatter.GetType())) { this._formatter = formatter; } } catch { //Ignore this Formatter } } } } formatters.Sort(new ToStringComparer <INodeFormatter>()); this.cboFormat.DataSource = formatters; this.cboFormat.SelectedItem = this._formatter; this.cboFormat.SelectedIndexChanged += new System.EventHandler(this.cboFormat_SelectedIndexChanged); this.dgvTriples.CellFormatting += new DataGridViewCellFormattingEventHandler(dgvTriples_CellFormatting); this.dgvTriples.CellContentClick += new DataGridViewCellEventHandler(dgvTriples_CellClick); if (g.BaseUri != null) { this.lnkBaseURI.Text = g.BaseUri.ToString(); } this._g = g; this.Text = String.Format("Graph Viewer - {0} Triple(s)", g.Triples.Count); }
/// <summary> /// Creates a new Result Set viewer form /// </summary> /// <param name="results">Result Set</param> /// <param name="nsmap">Namespace Map to use for display</param> public void DisplayResultSet(SparqlResultSet results, INamespaceMapper nsmap) { this._nsmap = nsmap; if (nsmap != null) { this._formatter = new SparqlFormatter(nsmap); } DisplayResultSet(results); }
private void SetNewFormatter(string formatter) { INodeFormatter f = TypeReflectorApp.CreateFormatter(formatter, Options); if (f != null) { Formatter = f; // Cause TreeView to refresh treeView.QueueDraw(); } }
public static INodeFormatter CreateFormatter(string formatter, TypeReflectorOptions options) { INodeFormatter nformatter = Factories.Formatter.Create(formatter); NodeFormatter f = nformatter as NodeFormatter; if (f != null) { f.InvokeMethods = options.InvokeMethods; } return(nformatter); }
private static string FormatQuad(INodeFormatter formatter, Triple t) { var line = new StringBuilder(); line.Append(formatter.Format(t.Subject)); line.Append(' '); line.Append(formatter.Format(t.Predicate)); line.Append(' '); line.Append(formatter.Format(t.Object)); line.Append(" <"); line.Append(t.GraphUri); line.Append(">."); return(line.ToString()); }
/// <summary> /// Displays the given Graph /// </summary> /// <param name="g">Graph to display</param> public GraphViewerForm(IGraph g) { InitializeComponent(); if (Constants.WindowIcon != null) { this.Icon = Constants.WindowIcon; } //Load Formatters List<INodeFormatter> formatters = new List<INodeFormatter>(); Type targetType = typeof(INodeFormatter); foreach (Type t in Assembly.GetAssembly(targetType).GetTypes()) { if (t.Namespace == null) continue; if (t.Namespace.Equals("VDS.RDF.Writing.Formatting")) { if (t.GetInterfaces().Contains(targetType)) { try { INodeFormatter formatter = (INodeFormatter)Activator.CreateInstance(t); formatters.Add(formatter); if (formatter.GetType().Equals(this._formatter.GetType())) this._formatter = formatter; } catch { //Ignore this Formatter } } } } formatters.Sort(new ToStringComparer<INodeFormatter>()); this.cboFormat.DataSource = formatters; this.cboFormat.SelectedItem = this._formatter; this.cboFormat.SelectedIndexChanged += new System.EventHandler(this.cboFormat_SelectedIndexChanged); this.dgvTriples.CellFormatting += new DataGridViewCellFormattingEventHandler(dgvTriples_CellFormatting); this.dgvTriples.CellContentClick += new DataGridViewCellEventHandler(dgvTriples_CellClick); if (g.BaseUri != null) { this.lnkBaseURI.Text = g.BaseUri.ToString(); } this._g = g; this.Text = String.Format("Graph Viewer - {0} Triple(s)", g.Triples.Count); }
public LiteralNodeControl(ILiteralNode n, INodeFormatter formatter) { InitializeComponent(); String data = formatter.Format(n); if (data.Contains("\"^^")) { String value = data.Substring(0, data.IndexOf("\"^^") + 3); String dt = data.Substring(data.IndexOf("\"^^") + 4); this.txtValue.Content = value; this.lnkDatatypeUri.Text = dt; this._u = n.DataType; } else { this.txtValue.Content = data; } }
private void Reformat() { if (ReferenceEquals(this._lastFormatter, null)) { return; } this._formatter = this._lastFormatter.CreateInstance(this._g.NamespaceMap); if (this.dgvTriples.DataSource == null) { return; } DataTable tbl = (DataTable)this.dgvTriples.DataSource; this.dgvTriples.DataSource = null; this.dgvTriples.Refresh(); this.dgvTriples.DataSource = tbl; }
private void cboFormat_SelectedIndexChanged(object sender, EventArgs e) { if (this.cboFormat.SelectedItem != null) { INodeFormatter formatter = this.cboFormat.SelectedItem as INodeFormatter; if (formatter != null) { INodeFormatter currFormatter = this._formatter; Type t = formatter.GetType(); if (this._nsmap != null) { Type nsmapType = typeof(INamespaceMapper); if (t.GetConstructors().Any(c => c.IsPublic && c.GetParameters().Any() && c.GetParameters().All(p => p.ParameterType.Equals(nsmapType)))) { try { this._formatter = (INodeFormatter)Activator.CreateInstance(t, new object[] { this._nsmap }); } catch { this._formatter = formatter; } } else { this._formatter = formatter; } } else { this._formatter = formatter; } if (!ReferenceEquals(currFormatter, this._formatter) || !currFormatter.GetType().Equals(this._formatter.GetType())) { DataTable tbl = (DataTable)this.dgvResults.DataSource; this.dgvResults.DataSource = null; this.dgvResults.Refresh(); this.dgvResults.DataSource = tbl; } } } }
/// <summary> /// Creates a new formatter control /// </summary> public FormatterControl() { InitializeComponent(); //Load Formatters Type targetType = typeof(INodeFormatter); foreach (Type t in Assembly.GetAssembly(targetType).GetTypes()) { if (t.Namespace == null) { continue; } if (!t.Namespace.Equals("VDS.RDF.Writing.Formatting")) { continue; } if (!t.GetInterfaces().Contains(targetType)) { continue; } try { INodeFormatter formatter = (INodeFormatter)Activator.CreateInstance(t); this._formatters.Add(new Formatter(formatter.GetType(), formatter.ToString())); } catch { //Ignore this Formatter } } this._formatters.Sort(); this.cboFormat.DataSource = this._formatters; this.cboFormat.SelectedItem = this._defaultFormatter ?? this._formatters.First(); this.cboFormat.SelectedIndexChanged += cboFormat_SelectedIndexChanged; this.RaiseFormatterChanged(); }
public string ToString(INodeFormatter formatter, TripleSegment segment) { return(formatter.Format(this, segment)); }
public string ToString(INodeFormatter formatter) { return(formatter.Format(this)); }
public Node (INodeFormatter formatter, INodeFinder finder) { this.formatter = formatter; this.finder = finder; }
public NQuadFormatter() { _formatter = new NQuads11Formatter(); }
private void TestBNodeFormatting(IBlankNode b, INodeFormatter formatter, String expected) { String actual = formatter.Format(b); Assert.AreEqual(expected, actual); }
private void cboFormat_SelectedIndexChanged(object sender, EventArgs e) { if (this.cboFormat.SelectedItem != null) { INodeFormatter formatter = this.cboFormat.SelectedItem as INodeFormatter; if (formatter != null) { INodeFormatter currFormatter = this._formatter; Type t = formatter.GetType(); this._formatter = formatter; if (!ReferenceEquals(currFormatter, this._formatter) || !currFormatter.GetType().Equals(this._formatter.GetType())) { DataTable tbl = (DataTable)this.dgvResults.DataSource; this.dgvResults.DataSource = null; this.dgvResults.Refresh(); this.dgvResults.DataSource = tbl; } } } }
/// <summary> /// Gets the String representation of the Node formatted with the given Node formatter /// </summary> /// <param name="formatter">Formatter</param> /// <param name="segment">Triple Segment</param> /// <returns></returns> public virtual String ToString(INodeFormatter formatter, TripleSegment segment) { return formatter.Format(this, segment); }
public static void Execute(string[] args) { InitFactories(); TypeReflectorOptions options = new TypeReflectorOptions(); bool quit = false; try { options.ParseOptions(args); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("See `{0} --help' for more information", ProgramOptions.ProgramName); return; } foreach (DictionaryEntry de in Factories.Displayer) { Trace.WriteLine( string.Format("registered displayer: {0}={1}", de.Key, ((TypeFactoryEntry)de.Value).Type)); } if (options.FoundHelp) { Console.WriteLine(options.OptionsHelp); quit = true; } if (options.DefaultAssemblies) { Console.WriteLine("The default search assemblies are:"); foreach (string s in TypeReflectorOptions.GetDefaultAssemblies()) { Console.WriteLine(" {0}", s); } quit = true; } if (options.Version) { PrintVersion(); quit = true; } if (quit) { return; } TraceArray("Explicit Assemblies: ", options.Assemblies); TraceArray("Referenced Assemblies: ", options.References); TraceArray("Search for Types: ", options.Types); TypeLoader loader = CreateLoader(options); TraceArray("Actual Search Assemblies: ", loader.Assemblies); TraceArray("Actual Search Assemblies: ", loader.References); ITypeDisplayer displayer = CreateDisplayer(options); if (displayer == null) { Console.WriteLine("Error: invalid displayer: " + options.Displayer); return; } if (loader.Assemblies.Count == 0 && loader.References.Count == 0 && displayer.AssembliesRequired) { Console.WriteLine("Error: no assemblies specified."); Console.WriteLine("See `{0} --help' for more information", ProgramOptions.ProgramName); return; } INodeFormatter formatter = CreateFormatter(options); if (formatter == null) { Console.WriteLine("Error: invalid formatter: " + options.Formatter); return; } INodeFinder finder = CreateFinder(options); if (finder == null) { Console.WriteLine("Error: invalid finder: " + options.Finder); return; } displayer.Finder = finder; displayer.Formatter = formatter; displayer.Options = options; displayer.InitializeInterface(); IList types = options.Types; if (types.Count == 0) { types = new string[] { "." } } ; // Find the requested types and display them. if (loader.Assemblies.Count != 0 || loader.References.Count != 0) { FindTypes(displayer, loader, types); } displayer.Run(); }
/// <inheritdoc/> public string ToString(INodeFormatter formatter, TripleSegment segment) { return(Node.ToString(formatter, segment)); }
/// <inheritdoc/> public string ToString(INodeFormatter formatter) { return(Node.ToString(formatter)); }
private void cboFormat_SelectedIndexChanged(object sender, EventArgs e) { if (this.cboFormat.SelectedItem != null) { INodeFormatter formatter = this.cboFormat.SelectedItem as INodeFormatter; if (formatter != null) { INodeFormatter currFormatter = this._formatter; Type t = formatter.GetType(); Type graphType = typeof(IGraph); if (t.GetConstructors().Any(c => c.IsPublic && c.GetParameters().Any() && c.GetParameters().All(p => p.ParameterType.Equals(graphType)))) { try { this._formatter = (INodeFormatter)Activator.CreateInstance(t, new object[] { this._g }); } catch { this._formatter = formatter; } } else { this._formatter = formatter; } if (!ReferenceEquals(currFormatter, this._formatter) || !currFormatter.GetType().Equals(this._formatter.GetType())) { DataTable tbl = (DataTable)this.dgvTriples.DataSource; this.dgvTriples.DataSource = null; this.dgvTriples.Refresh(); this.dgvTriples.DataSource = tbl; } } } }
public ResultSetViewerForm(SparqlResultSet results, String title, INamespaceMapper nsmap) : this(results, title) { this._nsmap = nsmap; if (nsmap != null) this._formatter = new SparqlFormatter(nsmap); }
/// <summary> /// Gets the String representation of the Node formatted with the given Node formatter /// </summary> /// <param name="formatter">Formatter</param> /// <returns></returns> public virtual String ToString(INodeFormatter formatter) { return formatter.Format(this); }
public Node(INodeFormatter formatter, INodeFinder finder) { this.formatter = formatter; this.finder = finder; }