By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,689 Members | 1,203 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,689 IT Pros & Developers. It's quick & easy.

Expando

P: n/a
I'm trying to figure out how to use this class/interface to dynamically
create properties. I've looked at all the documentation, but I can't find
any real sample code, and I'm really not sure how to get started. Does
anyone have either a self-written example or a link to one? I'd appreciate
it.

Mike

--

Nov 20 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Hi Mike,

|| I'm trying to figure out how to use this class/interface
|| to dynamically create properties.

Which class ?

In fact, which language? - Expando is JavaScript.

Do you mean that you want the same functionality in VB ?

Regards,
Fergus
Nov 20 '05 #2

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
I'm trying to figure out how to use this class/interface
to dynamically create properties.


Which class ?

In fact, which language? - Expando is JavaScript.

Do you mean that you want the same functionality in VB ?


I think the OP is referring to the 'IExpando' interface in the namespace
'System.Runtime.InteropServices.Expando'.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #3

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
I'm trying to figure out how to use this class/interface
to dynamically create properties.


Which class ?

In fact, which language? - Expando is JavaScript.

Do you mean that you want the same functionality in VB ?


I think the OP is referring to the 'IExpando' interface in the namespace
'System.Runtime.InteropServices.Expando'.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

P: n/a
Hi Herfried,

LOL. Thanks. Never heard of it. But it sounds interesting. On to the list
it goes. :-)

Regards,
Fergus
Nov 20 '05 #5

P: n/a
Hi Herfried,

LOL. Thanks. Never heard of it. But it sounds interesting. On to the list
it goes. :-)

Regards,
Fergus
Nov 20 '05 #6

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
LOL. Thanks. Never heard of it. But it sounds interesting.
On to the list it goes. :-)


Do you have a sample for using this interface?!

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #7

P: n/a
Hi Herfried,

|| > Thanks. Never heard of it.
||
|| Do you have a sample for using this interface?!

Are you asking or offering? I had never heard of Expando in .NET until you
told me about it.

A quick look on Google gives nothing!! (Usage-wise)

Regards,
Fergus
Nov 20 '05 #8

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Are you asking or offering? I had never heard of Expando in
.NET until you told me about it.

A quick look on Google gives nothing!! (Usage-wise)


I have heard about it but I didn't find any samples too.

;-(

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #9

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
LOL. Thanks. Never heard of it. But it sounds interesting.
On to the list it goes. :-)


Do you have a sample for using this interface?!

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #10

P: n/a
Cor
A look in msdn does and when I saw it my first thought were not my stuff
it's Fergus Cooney stuff.
Nov 20 '05 #11

P: n/a
Hi Herfried,

|| > Thanks. Never heard of it.
||
|| Do you have a sample for using this interface?!

Are you asking or offering? I had never heard of Expando in .NET until you
told me about it.

A quick look on Google gives nothing!! (Usage-wise)

Regards,
Fergus
Nov 20 '05 #12

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Are you asking or offering? I had never heard of Expando in
.NET until you told me about it.

A quick look on Google gives nothing!! (Usage-wise)


I have heard about it but I didn't find any samples too.

;-(

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #13

P: n/a
Cor
A look in msdn does and when I saw it my first thought were not my stuff
it's Fergus Cooney stuff.
Nov 20 '05 #14

P: n/a
Mike,
In addition to the others comments. Are you referring to
System.Runtime.InteropServices.Expando.IExpando?

To the best of my knowledge it is there to support 'Dynamic Scripting'
languages such as JScript.NET. It is also used with COM Interop to enable
the IDispatchEx interface (again 'dynamic scripting' languages).

If you look at the Microsoft.JScript assembly there are a number of classes
that implement IExpando.

Also JScript.NET has an expando keyword that 'declares that instances of a
class support expando properties or that a method is an expando object
constructor'.

What specifically are you trying to accomplish?

Remember that VB.NET is a compiled language, in order to use 'dynamic
properties' you will need to use late binding. I hope you realize that late
binding is not always such a good idea.

What I normally do to implement 'dynamic properties' is to have a default
indexer on my class that accepts a string as the key. This enables the !
operator, so the property looks very much dynamic.

Public Class Expando

Private readonly m_properties As New HashTable

Default Public Property Item(key As String) as Object
Get
return m_properties(key)
End Get
Set(value As Object)
m_properties(key) = value
End Set
End Property

End Class

Then when I need to use it:

dim expando as New Expando

expando!Name = "Mike "
expando("Name") = "Mike "
expando.Item("Name") = "Mike "

As you notice all three syntaxes work.

Of course you need to make the property Object to support any type, which
means you need to cast the property when you take it out, if you are using
Option Strict On, you are using Option Strict?

Hope this helps
Jay

"Mike Caputo" <mi************@radarwire.com> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
I'm trying to figure out how to use this class/interface to dynamically
create properties. I've looked at all the documentation, but I can't find
any real sample code, and I'm really not sure how to get started. Does
anyone have either a self-written example or a link to one? I'd appreciate it.

Mike

--

Nov 20 '05 #15

P: n/a
Mike,
In addition to the others comments. Are you referring to
System.Runtime.InteropServices.Expando.IExpando?

To the best of my knowledge it is there to support 'Dynamic Scripting'
languages such as JScript.NET. It is also used with COM Interop to enable
the IDispatchEx interface (again 'dynamic scripting' languages).

If you look at the Microsoft.JScript assembly there are a number of classes
that implement IExpando.

Also JScript.NET has an expando keyword that 'declares that instances of a
class support expando properties or that a method is an expando object
constructor'.

What specifically are you trying to accomplish?

Remember that VB.NET is a compiled language, in order to use 'dynamic
properties' you will need to use late binding. I hope you realize that late
binding is not always such a good idea.

What I normally do to implement 'dynamic properties' is to have a default
indexer on my class that accepts a string as the key. This enables the !
operator, so the property looks very much dynamic.

Public Class Expando

Private readonly m_properties As New HashTable

Default Public Property Item(key As String) as Object
Get
return m_properties(key)
End Get
Set(value As Object)
m_properties(key) = value
End Set
End Property

End Class

Then when I need to use it:

dim expando as New Expando

expando!Name = "Mike "
expando("Name") = "Mike "
expando.Item("Name") = "Mike "

As you notice all three syntaxes work.

Of course you need to make the property Object to support any type, which
means you need to cast the property when you take it out, if you are using
Option Strict On, you are using Option Strict?

Hope this helps
Jay

"Mike Caputo" <mi************@radarwire.com> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
I'm trying to figure out how to use this class/interface to dynamically
create properties. I've looked at all the documentation, but I can't find
any real sample code, and I'm really not sure how to get started. Does
anyone have either a self-written example or a link to one? I'd appreciate it.

Mike

--

Nov 20 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.