sabato 14 luglio 2012

Kanga api

yup, I'm done with it. The kanga api project has started. It has been quite easy to play with this modeling platform published on CodePlex.
It's a nice project and they also expose an api in order to provide a services based software. But for educational purpose I've been playing around with the code and embedded it in an MVC4 Web Api project.
Also provided a method to visualize the diagram as encoded base64 background image. I'm still working on this. Not sure why the image doesn't show up, it could be a different way to encode it through my c# class

giovedì 12 luglio 2012

RGraphWebApi instructions #1

First of all you should understand two things.
  • we need to automatize the way data ara loaded. Of course you can get your data from a db or any other repository but it was quite natural to me consider csv as the basic structure out of which data could be displayed. (the folder -repository- is App_Data\Series)
  • the structure is this:
    • we do have a header, that is not accounted while the data are loaded by the application
    • and rows of data according to the header
      12,00;;Jan;;notes for january
Now how do we go from this? It's quite simple:
we do have a class that has a property collection of DataPoint;
the property is called public List <DataPoint > SeriesPoints and can you guess what a DataPoint is?
Well, you can judge for yourself:
public class DataPoint
public decimal X { get; set; }
public decimal? Y { get; set; }
public string XLabel { get; set; }
public string YLabel { get; set; }
public string Notes { get; set; }

Elementary my dear Watson!!!

martedì 10 luglio 2012

Web Api default xml formatter.

The default formatter in the Mvc web api is an XML formatter.
To disable it, it's necessary to remove it from the default formatters.
In the Global.asax.cs (if we talk c#) you should add these lines of code:

// The Web API Configuration Object
var config = GlobalConfiguration.Configuration;
// Remove the XML Formatter
var xmlFormatter = config.Formatters
.Where(f =>
return f.SupportedMediaTypes.Any(v => v.MediaType == "text/xml");

if (xmlFormatter != null)