elizarovalex / luainterface

Automatically exported from code.google.com/p/luainterface
0 stars 0 forks source link

Cannot expose C# interface reference as a variable to Lua #47

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Using the `lua["obj"] = value;` setter provides no way to force the object 
mapper to use an interface type for exposing methods rather than the concrete 
runtime type of the object.

public interface IMyObject
{
  void Intf1();
  void Intf2();
}

public class MyObject : IMyObject
{
  public void Intf1();
  public void Intf2();
  public void Reg3();
}

// The general idea:
IMyObject x = new MyObject();
lua["obj"] = x;

What is the expected output? What do you see instead?
I only want to expose `Intf1` and `Intf2` methods to Lua via the `IMyObject` 
interface yet I'm exposing `Reg3` as well simply because it is a member of the 
class. There is no apparent way to expose only the interface's methods as 
opposed to all of the runtime type's methods.

IMO there should be an additional way to expose an object to Lua using a 
specific `Type` instance, e.g.:

lua.Expose("obj", new MyObject(), typeof(IMyObject));

What version of the product are you using? On what operating system?
LuaInterface 2.0.3

Original issue reported on code.google.com by james.jdunne@gmail.com on 23 Apr 2012 at 12:14