mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-15 14:15:54 -06:00
Fixed issue with dynamic method invocations on QObjects not working.
This commit is contained in:
parent
ff203ceb3e
commit
62c8b9f47b
2 changed files with 32 additions and 14 deletions
|
|
@ -130,6 +130,17 @@ namespace Qml.Net.Tests.Qml
|
|||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_invoke_method_on_qobject_as_dynamic()
|
||||
{
|
||||
AssertQObject(qObject =>
|
||||
{
|
||||
var d = (dynamic)qObject;
|
||||
var result = (int)d.testSlotInt(23);
|
||||
result.Should().Be(23);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_set_random_types_on_property()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -113,20 +113,6 @@ namespace Qml.Net.Internal.Qml
|
|||
|
||||
public NetQObject QObject => _qObject;
|
||||
|
||||
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
||||
{
|
||||
result = GetProperty(binder.Name);
|
||||
// TODO: Check if this was actually a property
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TrySetMember(SetMemberBinder binder, object value)
|
||||
{
|
||||
SetProperty(binder.Name, value);
|
||||
// TODO: Check if this was actually a property
|
||||
return true;
|
||||
}
|
||||
|
||||
public object GetProperty(string propertyName)
|
||||
{
|
||||
var property = _qObject.GetProperty(propertyName);
|
||||
|
|
@ -232,6 +218,27 @@ namespace Qml.Net.Internal.Qml
|
|||
|
||||
return _qObject.AttachNotifySignal(propertyName, del);
|
||||
}
|
||||
|
||||
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
||||
{
|
||||
result = GetProperty(binder.Name);
|
||||
// TODO: Check if this was actually a property
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TrySetMember(SetMemberBinder binder, object value)
|
||||
{
|
||||
SetProperty(binder.Name, value);
|
||||
// TODO: Check if this was actually a property
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
|
||||
{
|
||||
result = InvokeMethod(binder.Name, args);
|
||||
// TODO: Check if this was actually a method.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue