Business entity with additional properties

  • Thread starter Thread starter Stefano
  • Start date Start date
S

Stefano

Hi all,

I'm designing classes for my application.

I'd like to create a business entity that could be expanded with other properties
when needed.

For example, this could be my entity:

MyBusinessClass
-> Property1
-> Property2
-> ...
-> OtherProperties

The "OtherProperties" property of the class could expose a name value collection
with the other properties associated to the entity.

Now, the question is:
can I use System.Configuration.SettingsProperty class to define the additional
property, and so declare the "OtherProperty" as SettingsPropertyCollection?

I mean: has someone used this before? Are this classes designed for this
purpose?

Thanks

Bye

Stefan
 
Stefano,

You ^could^, but I don't think that this would be a good idea. The
reason for this is that every instance of your object (with each instance
representing separate entities) would share the same values, which is what I
am sure you don't want.

Hope this helps.
 
Hello Nicholas Paldino [.NET/C# MVP],
You ^could^, but I don't think that this would be a good idea.
The reason for this is that every instance of your object (with each
instance representing separate entities) would share the same values,
which is what I am sure you don't want.

I'm not sure that values will be shared.
Why did you say that?

I'm looking inside, using a reflector... that classes (SettingsProperty and
SettingsPropertyValue) doesn't have static members.

So, what is the correct use that we can do about this classes?

Thanks

By
 
Stefano,

It doesn't have static members, but the classes are meant to store
values that are used application-wide, not instance-wide.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Stefano said:
Hello Nicholas Paldino [.NET/C# MVP],
You ^could^, but I don't think that this would be a good idea.
The reason for this is that every instance of your object (with each
instance representing separate entities) would share the same values,
which is what I am sure you don't want.

I'm not sure that values will be shared.
Why did you say that?

I'm looking inside, using a reflector... that classes (SettingsProperty
and SettingsPropertyValue) doesn't have static members.

So, what is the correct use that we can do about this classes?

Thanks

Bye
 
Hello Nicholas Paldino [.NET/C# MVP],

thanks for the answer. You're right.

Anyway...

It could be great if the BCL had supplied a class that we could have used
in order to define a property, like the one that Vadym suggests:

public class CustomProperty
{
Name
PropertyType
Value
SerializedValue
....
}

Stefano,

It doesn't have static members, but the classes are meant to store
values that are used application-wide, not instance-wide.

Hello Nicholas Paldino [.NET/C# MVP],
You ^could^, but I don't think that this would be a good idea.
The reason for this is that every instance of your object (with each
instance representing separate entities) would share the same
values,
which is what I am sure you don't want.
I'm not sure that values will be shared.
Why did you say that?
I'm looking inside, using a reflector... that classes
(SettingsProperty and SettingsPropertyValue) doesn't have static
members.

So, what is the correct use that we can do about this classes?

Thanks

Bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top