473,385 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Expando

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
15 3692
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
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
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
Hi Herfried,

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

Regards,
Fergus
Nov 20 '05 #5
Hi Herfried,

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

Regards,
Fergus
Nov 20 '05 #6
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Derek | last post by:
Hi, I've built a rather large CGI that dumps a lot of data and a fairly complex javascript app out to the client's browser. Granted this may be poor style according to someone web design...
3
by: Richard A. DeVenezia | last post by:
I hope this is the end of my present 'discovery' phase. I've learned alot about JavaScript in a short time and my head hurts. The following is what came out of all my questions and all the...
2
by: John J | last post by:
Hi there I have the following code on a site that works as it should but I'd like to understand how it works (a luxury I realise :). I use it to change the colour of buttons on a menu when a...
5
by: Howard Kaikow | last post by:
I was perusing the book Pure Javascript by Wyke, Gilliam, and Ting and came upon references to String Indexes on pages 32-33 in the discussion of arrays. I then looked for more info in the 3rd...
3
by: ytrewq | last post by:
Should dynamic ("expando") properties be restricted to native and user-defined objects? Or should host objects - such as references to the browser or a plug-in or to the document and its elements -...
12
by: Alex D. | last post by:
How can I stop asp.net from rendering XHTML istead of HTML? My javascripts are rendering wrong because of that. It is rendering &amp; to clients instead of &. Any help? Thanks, Alejandro.
5
by: adh | last post by:
Winforms Datagrid Qoute (MSDN): Expanders are displayed in each parent row that contains a child table. Clicking an expander generates a list of Web-like links to the child tables, which when...
4
by: ICPooreMan | last post by:
I've got some code which works in firefox that's giving me fits in IE7 (maybe other versions too I haven't tested it). What I want to do is get the oncontextmenu attribute of something, change the...
2
by: MOS1 | last post by:
Folks Please help this is driving me insane The + expands but the minus fails Error src is null or not an object function Win_onLoad() { GetNameAndLink(0); } function GetNameAndLink(pkId)
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.