How to import properties of an external API into Script#
- by AndrewDotHay
I'm using Script# inside Visual Studio 2010 to import the API for the HTML5 Canvas element.
Its working great for things like FillRect(), MoveTo(), LineTo() and so on. I've declared the following interface and then I can code against it in C#. Then, Script# converts it to JavaScript nicely.
public interface CanvasContext
{
void FillRect(int x, int y, int width, int height);
void BeginPath();
void MoveTo(int x, int y);
void LineTo(int x, int y);
void Stroke();
void FillText(string text, int x, int y);
}
I want to include the StrokeStyle property that takes a simple string. The following interface definition produces a prefix in the JavaScript, which causes it to fail.
string StrokeStyle { get; set; }
string Font { get; set; }
The previous property will create this JavaScript:
ctx.set_strokeStyle('#FF0');
How can I get Script# to generate the simple assignment properties of the canvas context without the get_/set_ prefix?