This project has moved. For the latest updates, please go here.
1
Vote

Full static c# classes

description

Is there any way to expose a full static c# class to ReoScript?

comments

unvell wrote Aug 15, 2014 at 12:38 AM

Make c# static methods visible to script

If you use ScriptVisible attribute to expose a class, it is necessary to mark its all static members have ScriptVisible attribue.
class TestA
{
    [ScriptVisible]
    public static string Pro1 { get; set; }
}
If you are using DirectAccess mode, there is nothing need to do.

Import C# type
srm.ImportType(typeof(TestA));
Use static type
TestA.Pro1 = 'hello';
alert(TestA.Pro1);
More example: Import system classes
// Enable DirectAccess
srm.WorkMode |= MachineWorkMode.AllowDirectAccess;

// Expose a static class
srm.ImportType(typeof(System.Drawing.Color));

// Run script
srm.Run(@"
  debug.assert(Color.Yellow, 'Color [Yellow]');
  debug.assert(System.Drawing.SystemColors.Control != null);
  debug.assert(Color.Yellow, System.Drawing.Color.Yellow);
");

kkyy wrote Mar 17, 2016 at 2:06 PM

看到有人用中文,我也就毫不客气使用中文了,我想说,我导入了IO.File类型,但是并不能使用,比如File.Delete("...")会报告File没有Delete这个方法.是我使用的方式不对吗?