Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2004

Tip: Looking for answers? Try searching our database.

Is this Possible

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 09 Apr 2004 16:23 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.