473,624 Members | 2,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
Nov 15 '05 #1
12 5789
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
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

Nov 15 '05 #2
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]" <ni************ **@exisconsulti ng.com> a
écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl...
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
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


Nov 15 '05 #3
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:e1******** ******@TK2MSFTN GP11.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> a
écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl...
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
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



Nov 15 '05 #4
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]" <ni************ **@exisconsulti ng.com> a
écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl...
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
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


Nov 15 '05 #5
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:e1******** ******@TK2MSFTN GP11.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> a
écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl...
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
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



Nov 15 '05 #6
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]" <ni************ **@exisconsulti ng.com> wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:e1******** ******@TK2MSFTN GP11.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> a
écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl...
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
> 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
>
>




Nov 15 '05 #7
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]" <ni************ **@exisconsulti ng.com> wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:e1******** ******@TK2MSFTN GP11.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> a
écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl...
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
> 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
>
>




Nov 15 '05 #8
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)paldin o=at=exisconsul ting<dot>com

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:eB******** ******@TK2MSFTN GP10.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:e1******** ******@TK2MSFTN GP11.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> a écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl... > 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)paldin o=at=exisconsul ting<dot>com
>
> "Pol Bawin" <pb@rtech.be> wrote in message
> news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
> > 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
> >
> >
>
>


Nov 15 '05 #9
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)paldin o=at=exisconsul ting<dot>com

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:eB******** ******@TK2MSFTN GP10.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
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)paldin o=at=exisconsul ting<dot>com

"Pol Bawin" <pb@rtech.be> wrote in message
news:e1******** ******@TK2MSFTN GP11.phx.gbl...
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]" <ni************ **@exisconsulti ng.com> a écrit dans le message de news: On************* *@TK2MSFTNGP10. phx.gbl... > 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)paldin o=at=exisconsul ting<dot>com
>
> "Pol Bawin" <pb@rtech.be> wrote in message
> news:Og******** ********@TK2MSF TNGP11.phx.gbl. ..
> > 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
> >
> >
>
>


Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1819
by: F. Da Costa | last post by:
Hi, I was wondering *why* there is a difference between the results of the following two statements. On the suface they seem to do the same (or do they?) frm => returns void frm.getAttribute("custom") => returns the value of the attribute
3
2880
by: xAvailx | last post by:
I apologize ahead of time for the long post... Background: Working on a CRM type custom application. The application is for an event management company. The company will provide the application for other organizations to manage their own events. The events include conferences, corp meetings, sales meetings, etc... An event planner will define what information is needed for an attendee to register for an event. We will be providing a...
1
1527
by: Pol Bawin | last post by:
Hi All, Did somebody already define attributes for numerical properties to define values : minima, maxima, a number of décimals, ...? This information would be useful to unify syntax Polo
1
8483
by: Microsoft | last post by:
Hello there, I have following situation , how can I solve this puzzle in C#. I have interface called IVendor with some custom attributes applied to it interface IVendor {
2
3186
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
3
1493
by: Gigi | last post by:
I'm trying to add a custom property to each row of a table. So I created an HtmlTable called tblClass, I created a new class myRow inherited from HtmlTableRow, to which I added a new member myRow public class myRow : System.Web.UI.HtmlControls.HtmlTableRow private string _myCustomProp public myRow() : base() _myCustomProp="" public string myCustomProp get {return _myCustomProp;
3
1228
by: Dan | last post by:
Hi, I am messing around with custom attributes and may have understood the concept a bit wrong:- I have a simple class that has a few public properties that individually have custom attributes. For example, each property has a custom attribute class with one property defined, that of IsChanged. I know how to initialise the attribute class with a value (i.e. define a
15
2143
by: Jeff Mason | last post by:
Hi, I'm having a reflection brain fog here, perhaps someone can set me on the right track. I'd like to define a custom attribute to be used in a class hierarchy. What I want to do is to have an attribute which can be applied to a class definition of a class which inherits from a base, mustinherit class. I want to define methods in the base class which will access the contents of the attribute as it is applied to
2
13859
by: P4trykx | last post by:
Hello I'm want to add some custom attributes to WebControls using WebControl.Attributes.Add("abc","234"); So the html output will look like this, <input type="hidden" abc="123" /etc. I know that I need to modify .dtd file and tell the browser that abc i legal attribute. But I have another problem, I can't change the abc attribute using
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
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...
0
8629
jinu1996
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...
0
8488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
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();...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.