Created
July 15, 2016 14:30
-
-
Save masoo/8af86667141c6d944154af79d4cee8f4 to your computer and use it in GitHub Desktop.
ruby-csharp_script sample #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
require 'win32ole' | |
csharp_script = WIN32OLE.new('ruby.csharp_script.CsharpScript') | |
code = <<"EOS" | |
class Sample | |
{ | |
public int x; | |
public Sample(int value) | |
{ | |
x = value; | |
} | |
public int GetX() | |
{ | |
return x; | |
} | |
public void SetX(int value) | |
{ | |
x = value; | |
} | |
} | |
new Sample(5) | |
EOS | |
result = csharp_script.EvaluateAsync(code) | |
pp result.invoke("GetX"); | |
result.invoke("SetX", 33) | |
pp result.invoke("GetX"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment