Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Created March 22, 2011 14:10
Show Gist options
  • Save shiftkey/881256 to your computer and use it in GitHub Desktop.
Save shiftkey/881256 to your computer and use it in GitHub Desktop.
// here's the C# code we have to use
namespace Application
{
public class Factory
{
public T Get<T>(string parameter) where T : Proxy
{
return default(T);
}
public T Get<T>(Parameter parameter) where T : Proxy
{
return default(T);
}
}
public class Parameter
{
public string Key { get; set; }
}
public class Proxy
{
public Proxy()
{
Value = "ABC";
}
public string Value { get; protected set; }
}
public class AlternativeProxy : Proxy
{
public AlternativeProxy()
{
Value = "DEF";
}
}
}
// and dropping the dll in the same directory as this ruby script
require 'Application.dll'
class Script
def initialize()
@factory = Application::Factory.new
end
def test_with_string()
method = @factory.method(:Get).of(Application::Proxy)
puts method.to_s # method seems to be correct
result = method.call("something")
puts result.class # NilClass here
puts result.Value # null reference exception here
end
def test_with_parameter()
parameter = Parameter.new
parameter.Key = "foo"
result = @factory.method(:Get).of(Application::AlternativeProxy).call(parameter)
puts result.class
puts result.Value
end
end
proxy = Script.new
puts "Run first test"
puts proxy.test_with_string()
# puts "Run second test"
# puts proxy.test_with_parameter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment