Custom attributes to define min, max, ... value on numerical properties

  • Thread starter Thread starter Pol Bawin
  • Start date Start date
P

Pol Bawin

Hi All,

Did somebody already define attributes for numerical properties to define
value : minima, maxima, a number of decimal, ...? This information would be
useful to unify syntax

Polo
 
Polo,

I believe the static property on each numeric type is MinValue and
MaxValue for the min and max values in that range respectively.

Hope this helps.
 
Sorry but It is not my problem.

I woul like to define custom attributes to set min, max, number of digits
by exemple :
[MinValue(0)]
[MaxValue(100)]
...
public int Temperature
{
...
}

Somebody has you it already defined this type of attribute.

Nicholas Paldino said:
Polo,

I believe the static property on each numeric type is MinValue and
MaxValue for the min and max values in that range respectively.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Pol Bawin said:
Hi All,

Did somebody already define attributes for numerical properties to define
value : minima, maxima, a number of decimal, ...? This information
would
be
useful to unify syntax

Polo
 
Pol,

Well, there is no attribute like that, but you can always create your
own. You just have to derive a class from the Attribute class and then add
your properties, and the appropriate constructor syntax.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Pol Bawin said:
Sorry but It is not my problem.

I woul like to define custom attributes to set min, max, number of digits
by exemple :
[MinValue(0)]
[MaxValue(100)]
..
public int Temperature
{
...
}

Somebody has you it already defined this type of attribute.

Nicholas Paldino said:
Polo,

I believe the static property on each numeric type is MinValue and
MaxValue for the min and max values in that range respectively.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Pol Bawin said:
Hi All,

Did somebody already define attributes for numerical properties to define
value : minima, maxima, a number of decimal, ...? This information
would
be
useful to unify syntax

Polo
 
Nicholas,

It would be nice if these attributes could also perform corresponding data
validation. I have seen an article called "Aspect-Oriented Programming" that
explained such tricks. While I find this idea very appealing, its
implementation seems to be too complicated in the .NET Framework.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Nicholas Paldino said:
Pol,

Well, there is no attribute like that, but you can always create your
own. You just have to derive a class from the Attribute class and then add
your properties, and the appropriate constructor syntax.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Pol Bawin said:
Sorry but It is not my problem.

I woul like to define custom attributes to set min, max, number of digits
by exemple :
[MinValue(0)]
[MaxValue(100)]
..
public int Temperature
{
...
}

Somebody has you it already defined this type of attribute.

Nicholas Paldino said:
Polo,

I believe the static property on each numeric type is MinValue and
MaxValue for the min and max values in that range respectively.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Hi All,

Did somebody already define attributes for numerical properties to define
value : minima, maxima, a number of decimal, ...? This information would
be
useful to unify syntax

Polo
 
Dmitry,

They can provide indicators as to what the data validation should be.
Attributes are nothing more than meta-data, and they should have no
executable code in them (at least, when loosely defining "executable"). You
need to have code that performs actions based on the meta-data, which is in
fact what the implementation of Aspect Oriented Programming that you saw (I
believe we saw the same article) does.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Dmitriy Lapshin said:
Nicholas,

It would be nice if these attributes could also perform corresponding data
validation. I have seen an article called "Aspect-Oriented Programming" that
explained such tricks. While I find this idea very appealing, its
implementation seems to be too complicated in the .NET Framework.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

in message news:%[email protected]...
Pol,

Well, there is no attribute like that, but you can always create your
own. You just have to derive a class from the Attribute class and then add
your properties, and the appropriate constructor syntax.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Pol Bawin said:
Sorry but It is not my problem.

I woul like to define custom attributes to set min, max, number of digits
by exemple :
[MinValue(0)]
[MaxValue(100)]
..
public int Temperature
{
...
}

Somebody has you it already defined this type of attribute.

"Nicholas Paldino [.NET/C# MVP]" <[email protected]> a
écrit dans le message de news: (e-mail address removed)...
Polo,

I believe the static property on each numeric type is MinValue and
MaxValue for the min and max values in that range respectively.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Hi All,

Did somebody already define attributes for numerical properties to
define
value : minima, maxima, a number of decimal, ...? This information
would
be
useful to unify syntax

Polo
 
Thank you for this information, but or then I to find this article


Nicholas Paldino said:
Dmitry,

They can provide indicators as to what the data validation should be.
Attributes are nothing more than meta-data, and they should have no
executable code in them (at least, when loosely defining "executable"). You
need to have code that performs actions based on the meta-data, which is in
fact what the implementation of Aspect Oriented Programming that you saw (I
believe we saw the same article) does.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Dmitriy Lapshin said:
Nicholas,

It would be nice if these attributes could also perform corresponding data
validation. I have seen an article called "Aspect-Oriented Programming" that
explained such tricks. While I find this idea very appealing, its
implementation seems to be too complicated in the .NET Framework.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

in message news:%[email protected]...
Pol,

Well, there is no attribute like that, but you can always create your
own. You just have to derive a class from the Attribute class and
then
add
your properties, and the appropriate constructor syntax.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Sorry but It is not my problem.

I woul like to define custom attributes to set min, max, number of digits
by exemple :
[MinValue(0)]
[MaxValue(100)]
..
public int Temperature
{
...
}

Somebody has you it already defined this type of attribute.

"Nicholas Paldino [.NET/C# MVP]"
a
écrit dans le message de news: (e-mail address removed)...
Polo,

I believe the static property on each numeric type is MinValue and
MaxValue for the min and max values in that range respectively.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

Hi All,

Did somebody already define attributes for numerical properties to
define
value : minima, maxima, a number of decimal, ...? This information
would
be
useful to unify syntax

Polo
 
Hi Pol,

I think you can search "Aspect-Oriented Programming" in google.
There are many links in google, related to it.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Pol Bawin" <[email protected]>
| References: <OgW#[email protected]>
<[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
<e#[email protected]>
| Subject: Re: Custom attributes to define min, max, ... value on numerical
properties
| Date: Thu, 25 Sep 2003 09:39:23 +0200
| Lines: 117
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 194.78.114.66
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187226
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thank you for this information, but or then I to find this article
|
|
| "Nicholas Paldino [.NET/C# MVP]" <[email protected]> a
| écrit dans le message de e#[email protected]...
| > Dmitry,
| >
| > They can provide indicators as to what the data validation should
be.
| > Attributes are nothing more than meta-data, and they should have no
| > executable code in them (at least, when loosely defining "executable").
| You
| > need to have code that performs actions based on the meta-data, which is
| in
| > fact what the implementation of Aspect Oriented Programming that you saw
| (I
| > believe we saw the same article) does.
| >
| > --
| > - Nicholas Paldino [.NET/C# MVP]
| > - nick(dot)paldino=at=exisconsulting<dot>com
| >
| > "Dmitriy Lapshin [C# / .NET MVP]" <[email protected]>
wrote
| > in message | > > Nicholas,
| > >
| > > It would be nice if these attributes could also perform corresponding
| data
| > > validation. I have seen an article called "Aspect-Oriented
Programming"
| > that
| > > explained such tricks. While I find this idea very appealing, its
| > > implementation seems to be too complicated in the .NET Framework.
| > >
| > > --
| > > Dmitriy Lapshin [C# / .NET MVP]
| > > X-Unity Test Studio
| > > http://x-unity.miik.com.ua/teststudio.aspx
| > > Bring the power of unit testing to VS .NET IDE
| > >
| > > "Nicholas Paldino [.NET/C# MVP]" <[email protected]>
| > wrote
| > > in message | > > > Pol,
| > > >
| > > > Well, there is no attribute like that, but you can always create
| > your
| > > > own. You just have to derive a class from the Attribute class and
| then
| > > add
| > > > your properties, and the appropriate constructor syntax.
| > > >
| > > >
| > > > --
| > > > - Nicholas Paldino [.NET/C# MVP]
| > > > - nick(dot)paldino=at=exisconsulting<dot>com
| > > >
| > > > | > > > > Sorry but It is not my problem.
| > > > >
| > > > > I woul like to define custom attributes to set min, max, number of
| > > digits
| > > > > by exemple :
| > > > > [MinValue(0)]
| > > > > [MaxValue(100)]
| > > > > ..
| > > > > public int Temperature
| > > > > {
| > > > > ...
| > > > > }
| > > > >
| > > > > Somebody has you it already defined this type of attribute.
| > > > >
| > > > > "Nicholas Paldino [.NET/C# MVP]"
| <[email protected]>
| > a
| > > > > écrit dans le message de | > (e-mail address removed)...
| > > > > > Polo,
| > > > > >
| > > > > > I believe the static property on each numeric type is
MinValue
| > and
| > > > > > MaxValue for the min and max values in that range respectively.
| > > > > >
| > > > > > Hope this helps.
| > > > > >
| > > > > >
| > > > > > --
| > > > > > - Nicholas Paldino [.NET/C# MVP]
| > > > > > - nick(dot)paldino=at=exisconsulting<dot>com
| > > > > >
| > > > > > | > > > > > > Hi All,
| > > > > > >
| > > > > > > Did somebody already define attributes for numerical
properties
| to
| > > > > define
| > > > > > > value : minima, maxima, a number of decimal, ...? This
| > information
| > > > > would
| > > > > > be
| > > > > > > useful to unify syntax
| > > > > > >
| > > > > > > Polo
| > > > > > >
| > > > > > >
| > > > > >
| > > > > >
| > > > >
| > > > >
| > > >
| > > >
| > >
| >
| >
|
|
|
 
Back
Top