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
Cowboy (Gregory A. Beamer) - MVP - 28 Dec 2004 03:21 GMT
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!
***************************
> I would like to know if anyone can suggest how to implement the following:
>
[quoted text clipped - 11 lines]
>
> --Demetri
Daniel Faensen - 28 Dec 2004 08:49 GMT
> I would like to know if anyone can suggest how to implement the
> following:
[quoted text clipped - 14 lines]
>
> --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/WICSA3/ArchitectureOfAOMsWICSA3.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
Bishoy Ghaly - 31 Dec 2004 17:11 GMT
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
>> I would like to know if anyone can suggest how to implement the
>> following:
[quoted text clipped - 25 lines]
>
> Daniel
Cor Ligthert - 28 Dec 2004 09:28 GMT
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
James Curran - 29 Dec 2004 21:05 GMT
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)

Signature
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
> I would like to know if anyone can suggest how to implement the following:
>
[quoted text clipped - 11 lines]
>
> --Demetri