public class Test
{
public TimeSpan One {
[Template("System.TimeSpan.parse({this}.One)")]
get;
[Template("{this}.One = Bridge.toString({value})")]
set;
}
public TimeSpan Two {
[Template("System.TimeSpan.parse({this}.Two)")]
get;
[Template("{this}.Two = Bridge.toString({value})")]
set;
}
public TimeSpan Three {
[Template("System.TimeSpan.parse({this}.Three)")]
get;
[Template("{this}.Three = Bridge.toString({value})")]
set;
}
}
then, this var test = new Test()
{
One = TimeSpan.FromDays(1),
Two = TimeSpan.FromDays(2),
Three = TimeSpan.FromDays(3)
};
the generated code is thistest = ($t = new PortalScript.Components.Ring.Test()$t.One = Bridge.toString(System.TimeSpan.fromDays(1))$t.Two = Bridge.toString(System.TimeSpan.fromDays(2))$t.Three = Bridge.toString(System.TimeSpan.fromDays(3)), $t);
It is missing commas between property initialization.However if I do this
test.One = TimeSpan.FromDays(1);
test.Two = TimeSpan.FromDays(2);
test.Three = TimeSpan.FromDays(3);
Everything looks fine, semi-colons are there test.One = Bridge.toString(System.TimeSpan.fromDays(1));
test.Two = Bridge.toString(System.TimeSpan.fromDays(2));
test.Three = Bridge.toString(System.TimeSpan.fromDays(3));
The goal of using those Template attributes is to use TimeSpan property type in the C# code but string type in the JavaScript code. It is needed for a third-party library which expects these properties to be string representations of TimeSpan, such as "1.00:00:00". Please, let me know if there is a workaround besides using non-class initializer initialization.Thank you
Leave a comment: