Hello,
I have this Field attribut class and a Client class that uses this Attribut
Class
<AttributeUsage (AttributeTarge ts.Property)_
Public Class Field
Inherits Attribute
Private _FieldName As String
Private _Changed As Boolean
Public Sub New(ByVal changed As Boolean, ByVal fieldName As String)
_Changed = changed
_FieldName = fieldName
End Sub
Public Property FieldName() As String
Get
Return _FieldName
End Get
Set(ByVal value As String)
_FieldName = value
End Set
End Property
Public Property Changed() As Boolean
Get
Return _Changed
End Get
Set(ByVal value As Boolean)
_Changed = value
End Set
End Property
End Class
Public Class Client
Private _name As String
<Field(False, "name")_
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
If value <_name Then
Dim oType As Type = Me.GetType
Dim oPropertyInfo As PropertyInfo =
oType.GetProper ty("Name")
Dim oAllAttributes As Field()
oAllAttributes =
oPropertyInfo.G etCustomAttribu tes(GetType(Fie ld), False)
For Each oAttribute As Field In oAllAttributes
oAttribute.Chan ged = True
Exit For
Next
_name = value
End If
End Set
End Property
End Class
In the click event of a button I have this
Dim x as new Client
x.Name = "My name"
x.Name = "Your name"
What I want to do is to use the Changed property of my Field attribut class
to tell me that the Name property has changed or not. With this, I want to
build the SQL update string with only the fields that the Changed attribut
is set to True. It doesn't work :-( The changed property is allways false.
What I do wrong? Is it possible to update the value of a property of an
attribut? if yes, how can I do this?
Thank you and hope that I am clear
Marc R. 3 1046
On 2006-12-06, Marc Robitaille <marc.mariewrot e:
Hello,
I have this Field attribut class and a Client class that uses this Attribut
Class
<AttributeUsag e(AttributeTarg ets.Property)_
Public Class Field
Inherits Attribute
Private _FieldName As String
Private _Changed As Boolean
Public Sub New(ByVal changed As Boolean, ByVal fieldName As String)
_Changed = changed
_FieldName = fieldName
End Sub
Public Property FieldName() As String
Get
Return _FieldName
End Get
Set(ByVal value As String)
_FieldName = value
End Set
End Property
Public Property Changed() As Boolean
Get
Return _Changed
End Get
Set(ByVal value As Boolean)
_Changed = value
End Set
End Property
End Class
Public Class Client
Private _name As String
<Field(False, "name")_
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
If value <_name Then
Dim oType As Type = Me.GetType
Dim oPropertyInfo As PropertyInfo =
oType.GetProper ty("Name")
Dim oAllAttributes As Field()
oAllAttributes =
oPropertyInfo.G etCustomAttribu tes(GetType(Fie ld), False)
For Each oAttribute As Field In oAllAttributes
oAttribute.Chan ged = True
Exit For
Next
_name = value
End If
End Set
End Property
End Class
In the click event of a button I have this
Dim x as new Client
x.Name = "My name"
x.Name = "Your name"
What I want to do is to use the Changed property of my Field attribut class
to tell me that the Name property has changed or not. With this, I want to
build the SQL update string with only the fields that the Changed attribut
is set to True. It doesn't work :-( The changed property is allways false.
What I do wrong? Is it possible to update the value of a property of an
attribut? if yes, how can I do this?
Thank you and hope that I am clear
Marc R.
Marc - I don't really think it is possible to change the value of an attribute
at runtime. I'm pretty sure that attributes are compile time thing and are
embeded in the metadata of the assembly. If someone knows differently, please
jump in and correct me.
Anyway, you most likely will have to implement an internal method of tracking
changes. Maybe an array of flags. You know when a property gets changed,
just hook it in the set method.
By the way - why don't you just use one of the O/R mapper's that are already
out there? NHibernate? WilsonO/R Mapper? LLBGen Pro? Really, you would be
saving your self a heck of a lot of work :)
--
Tom Shelton
I do this because I want to learn :-) What I have done so far, I have
something that work great to
create code but, I want to use every possible things that exist in .NET just
to learn. You can tell that I am creazy but I love to learn.
Thank you for your sugestion.
:-)
"Tom Shelton" <to*********@co mcastXXXXXXX.ne ta écrit dans le message de
news: ef************* *************** **@comcast.com...
On 2006-12-06, Marc Robitaille <marc.mariewrot e:
>Hello,
I have this Field attribut class and a Client class that uses this Attribut Class
<AttributeUsa ge(AttributeTar gets.Property)_ Public Class Field Inherits Attribute Private _FieldName As String Private _Changed As Boolean
Public Sub New(ByVal changed As Boolean, ByVal fieldName As String) _Changed = changed _FieldName = fieldName End Sub
Public Property FieldName() As String Get Return _FieldName End Get Set(ByVal value As String) _FieldName = value End Set End Property Public Property Changed() As Boolean Get Return _Changed End Get Set(ByVal value As Boolean) _Changed = value End Set End Property End Class
Public Class Client Private _name As String <Field(False, "name")_ Public Property Name() As String Get Return _name End Get Set(ByVal value As String) If value <_name Then Dim oType As Type = Me.GetType Dim oPropertyInfo As PropertyInfo = oType.GetPrope rty("Name") Dim oAllAttributes As Field() oAllAttributes = oPropertyInfo. GetCustomAttrib utes(GetType(Fi eld), False) For Each oAttribute As Field In oAllAttributes oAttribute.Chan ged = True Exit For
Next _name = value End If End Set End Property End Class
In the click event of a button I have this
Dim x as new Client
x.Name = "My name" x.Name = "Your name"
What I want to do is to use the Changed property of my Field attribut class to tell me that the Name property has changed or not. With this, I want to build the SQL update string with only the fields that the Changed attribut is set to True. It doesn't work :-( The changed property is allways false. What I do wrong? Is it possible to update the value of a property of an attribut? if yes, how can I do this?
Thank you and hope that I am clear Marc R.
Marc - I don't really think it is possible to change the value of an
attribute
at runtime. I'm pretty sure that attributes are compile time thing and
are
embeded in the metadata of the assembly. If someone knows differently,
please
jump in and correct me.
Anyway, you most likely will have to implement an internal method of
tracking
changes. Maybe an array of flags. You know when a property gets changed,
just hook it in the set method.
By the way - why don't you just use one of the O/R mapper's that are
already
out there? NHibernate? WilsonO/R Mapper? LLBGen Pro? Really, you would
be
saving your self a heck of a lot of work :)
--
Tom Shelton
On 2006-12-07, Marc Robitaille <marc.mariewrot e:
I do this because I want to learn :-) What I have done so far, I have
something that work great to
create code but, I want to use every possible things that exist in .NET just
to learn. You can tell that I am creazy but I love to learn.
Thank you for your sugestion. :-)
Ok, nothing wrong with wanting to learn. Done that many times myself.
Anyway, good luck.
--
Tom Shelton This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: khaled Hajjar |
last post by:
Hello,
I have this template :
<root>
<categorie>
<poste att = 'true'>
.....
</poste>
<poste att = 'false'>
.....
|
by: Michael Schuerig |
last post by:
I'd like to mark input elements with class "invalid" by appending
something, say a "?". My understanding is that it should work like
this:
input.invalid:after {
content:"?";
}
However, at least in Firefox (1.0.4) and Konqueror (3.4.1) it does not
work. Is there something I'm missing here or is this an error in both
|
by: Sky Sigal |
last post by:
(PS: Cross post from microsoft.pulic.dotnet.framework.aspnet.webcontrols)
I've been looking lately for a way to keep the Properties panel for Controls
'clean'...
My goal is to keep similar public properties of a custom Control neatly tied
together -- rather than all over the IDE.
One such set of values that will rarely be changed, so should have little
priority in the IDE Properties panel, and therefore a good candidate for
|
by: |
last post by:
I'm writing web applications. I build and extend a lot of custom objects,
and in the course of debugging my apps I invariably find myself writing a
lot of junky code:
Response.Write("Title: " + uwtm.Title + "<br>");
Response.Write("Pubdate: " + uwtm.Pubdate + "<br>");
Response.Write("Byline String: " + uwtm.Byline + "<br>");
Response.Write("Order (converted): " + uwtm.Order + "<br>");
Response.Write("Body:" + uwtm.Body + "<br>");...
|
by: |
last post by:
Hi all, I have a question on reflection
Lets say I have a custom object called Address. Now, lets say I have a
string variable that holds the name of a variable in the object such as
"State.StateCode". How can I reflect upon the Address object so as to echo
the value contained in the string variable. Something like:-
Dim add as new Address
add.State.StateCode = "TX"
Dim str as string = "State.StateCode"
| |
by: prabhupr |
last post by:
Hi Folks
I was reading this article
(http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on
"Custom Attribute", written by Bipin.
The only thing I did not understand in this article is the usage of
"Custom Attribute" in real life project. Can somebody please help me
understand where are these informations really helpful in Development
Environment; may be a few example(s) will help me understand.
|
by: |
last post by:
I have made some user controls with custom properties. I can set those
properties on instances of my user controls, and I have programmed my user
control to do useful visual things in response to how those properties are
set.
I want to be able to do two other things:
a) add User control instances to my page, filling in the place of
placeholder controls, and
b) programmatically setting custom properties on those dynamically spawned...
|
by: =?Utf-8?B?cGFnYXRlcw==?= |
last post by:
Hello All,
I am sure that I am just overlooking something, but here's something I can't
quite get right...
I want to be able to get the value of a parameter of an unknown custom
attribute at runtime. All of the examples I have seen use casting of known
custom attributes to get these values.
Thanks,
|
by: Smithers |
last post by:
I have a Windows Forms application that implements a plug-in architecture
whereby required assemblies are identified and loaded dynamically.
Here are the relevant classes:
A = application = Windows Forms class
B = a singleton hosted within A. B is responsible for dynamically loading
classes X, Y, and Z.
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |