We allow users to add custom meta to our app in the form of key/value
pairs, both key and value are strings. And they access this user meta
data in thier scripts ( VBScript or JScript(, our app is a .NET app
(see http://www.mygenerationsoftware.com if this seems confusing). I
want to allow them to access thier user meta data through my
"UserData" object as if it were concrete, for instance:
(dynamically added by the user)
Key=> "Name"
Name=> "Foo"
So, instead of:
-------------
Dim data
data = UserMeta.Item["Name"];
I want to do this (synthetcally):
-------------------
Dim Data
data = UserMeta.Name
I imagine something like iDispatch, where they as for a property, and
I return the way to invoke it? My code is already C# exposed as COM
through interop, but I need to, at a low level, intercept the call to
UserMeta.Name, which really doesn't exist on my object and make it
appear that it does, remember, this is being done in script and my
object says [dual] so it should be possible.
Mike Griffin
MyGeneration Software
Idael Cardoso - 10 Apr 2004 20:03 GMT
Hi,
There is no way to make a custom implementation of IDispatch in a .NET class
because the COM callable wrapper (CCW) implement IDispatch and IUnknown by
you can take more control about late binding process implementing in your
.NET class IExpando interface. Doing so the CCW implements IDispatchEx. The
problem of implement IExpando is that you must implement IReflect that could
be a little complicated. If you are familiar with IDispatch in the COM world
you can developer a COM wrappers that interface the call for your clients
scripts and do the correct calls to your .NET class. This wrapper could
translate all the call to obj.Name to manObj.Items["Name"]
An easier solution could be use an indexer with string index in your manager
class, so, instead of use obj.Items["Name"] you could use obj["Name"], at
least this syntax look better and there is no complication to implement it.
Good luck
Idael.
> We allow users to add custom meta to our app in the form of key/value
> pairs, both key and value are strings. And they access this user meta
[quoted text clipped - 26 lines]
> Mike Griffin
> MyGeneration Software