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

Dynamic Properties

P: n/a
I would like to know if anyone can suggest how to implement the following:

We need to have classes who's properties are defined by a database. The
properties can not be hard coded. In addition properties datatype will also
be defined by the database and are subject to change in the future. So a
property that may return an int could in the future return a bool value.

Two questions:

1. How do you implement said senerio?

2. How do you implement it in a such a way that if the return value changes
your application can roll with it rather than causing an exception?

--Demetri
Jul 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Using standard coding techniques, you are pretty much lost. In .NET, however,
you do have a very real option using Reflection and code generation.
Reflection.Emit is what you want to examine. It allows you to take code
created on the fly and compile in memory and use in your process. If the
dynamic classes are called again, you do have the option of saving off the
code. Not the easiest to implement, but flexibility is always a bit more time
consuming.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Demetri" wrote:
I would like to know if anyone can suggest how to implement the following:

We need to have classes who's properties are defined by a database. The
properties can not be hard coded. In addition properties datatype will also
be defined by the database and are subject to change in the future. So a
property that may return an int could in the future return a bool value.

Two questions:

1. How do you implement said senerio?

2. How do you implement it in a such a way that if the return value changes
your application can roll with it rather than causing an exception?

--Demetri

Jul 21 '05 #2

P: n/a
"=?Utf-8?B?RGVtZXRyaQ==?=" <De*****@discussions.microsoft.com> wrote in
news:C9**********************************@microsof t.com:
I would like to know if anyone can suggest how to implement the
following:

We need to have classes who's properties are defined by a database.
The properties can not be hard coded. In addition properties datatype
will also be defined by the database and are subject to change in the
future. So a property that may return an int could in the future
return a bool value.

Two questions:

1. How do you implement said senerio?

2. How do you implement it in a such a way that if the return value
changes your application can roll with it rather than causing an
exception?

--Demetri


There are some publications that could be helpful for you:

Yoder J.W.; Johnson, R.: The adaptive object-model architectural style.
http://www.adaptiveobjectmodel.com/W...AOMsWICSA3.htm

Riehle, D.; Tilman, M.; Johnson, R.: Dynamic Object Model. PLoP 2000

At least you should have a look at http://www.adaptiveobjectmodel.com/

Daniel
Jul 21 '05 #3

P: n/a
Demetri,

What you want is in my opinion late binding. You can do that using Option
Strict Of in VBNet or reflection in another program language. However keep
in mind that both will decrease your performance.

Cor
Jul 21 '05 #4

P: n/a
Define what you mean by "Properties"..

What you describe differs in many respects from "Properties" as defined
in C#. Before we can give you any meaningful answer, we need to know what
features of C# properties are needed in these "Properties". (Notably, we'd
need to know how & where you plan as access these properties)

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"Demetri" <De*****@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
I would like to know if anyone can suggest how to implement the following:

We need to have classes who's properties are defined by a database. The
properties can not be hard coded. In addition properties datatype will also be defined by the database and are subject to change in the future. So a
property that may return an int could in the future return a bool value.

Two questions:

1. How do you implement said senerio?

2. How do you implement it in a such a way that if the return value changes your application can roll with it rather than causing an exception?

--Demetri

Jul 21 '05 #5

P: n/a
From what you said i suppose you need variant datatype which in .NET is the
object class which is able to store (box) any datatype .
please give more details in order to help in the design

"Daniel Faensen" <Fa******@NOSPAM.rki.de> wrote in message
news:33*************@individual.net...
"=?Utf-8?B?RGVtZXRyaQ==?=" <De*****@discussions.microsoft.com> wrote in
news:C9**********************************@microsof t.com:
I would like to know if anyone can suggest how to implement the
following:

We need to have classes who's properties are defined by a database.
The properties can not be hard coded. In addition properties datatype
will also be defined by the database and are subject to change in the
future. So a property that may return an int could in the future
return a bool value.

Two questions:

1. How do you implement said senerio?

2. How do you implement it in a such a way that if the return value
changes your application can roll with it rather than causing an
exception?

--Demetri


There are some publications that could be helpful for you:

Yoder J.W.; Johnson, R.: The adaptive object-model architectural style.
http://www.adaptiveobjectmodel.com/W...AOMsWICSA3.htm

Riehle, D.; Tilman, M.; Johnson, R.: Dynamic Object Model. PLoP 2000

At least you should have a look at http://www.adaptiveobjectmodel.com/

Daniel

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.