How to import properties of an external API into Script#
Posted
by AndrewDotHay
on Stack Overflow
See other posts from Stack Overflow
or by AndrewDotHay
Published on 2010-05-18T18:17:29Z
Indexed on
2010/05/18
18:20 UTC
Read the original article
Hit count: 163
script#
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?
© Stack Overflow or respective owner