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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pol Bawin

    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


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Custom attributes to define min, max, ... value on numerical properties

    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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > Hi All,
    >
    > Did somebody already define attributes for numerical properties to define
    > value : minima, maxima, a number of decimal, ...? This information would[/color]
    be[color=blue]
    > useful to unify syntax
    >
    > Polo
    >
    >[/color]


    Comment

    • Pol Bawin

      #3
      Re: Custom attributes to define min, max, ... value on numerical properties

      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]" <nicholas.paldi no@exisconsulti ng.com> a
      écrit dans le message de news: OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=blue]
      > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > Hi All,
      > >
      > > Did somebody already define attributes for numerical properties to[/color][/color]
      define[color=blue][color=green]
      > > value : minima, maxima, a number of decimal, ...? This information[/color][/color]
      would[color=blue]
      > be[color=green]
      > > useful to unify syntax
      > >
      > > Polo
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Custom attributes to define min, max, ... value on numerical properties

        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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...[color=blue]
        > 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]" <nicholas.paldi no@exisconsulti ng.com> a
        > écrit dans le message de news: OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=green]
        > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
        > > > Hi All,
        > > >
        > > > Did somebody already define attributes for numerical properties to[/color][/color]
        > define[color=green][color=darkred]
        > > > value : minima, maxima, a number of decimal, ...? This information[/color][/color]
        > would[color=green]
        > > be[color=darkred]
        > > > useful to unify syntax
        > > >
        > > > Polo
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Pol Bawin

          #5
          Re: Custom attributes to define min, max, ... value on numerical properties

          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]" <nicholas.paldi no@exisconsulti ng.com> a
          écrit dans le message de news: OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=blue]
          > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..[color=green]
          > > Hi All,
          > >
          > > Did somebody already define attributes for numerical properties to[/color][/color]
          define[color=blue][color=green]
          > > value : minima, maxima, a number of decimal, ...? This information[/color][/color]
          would[color=blue]
          > be[color=green]
          > > useful to unify syntax
          > >
          > > Polo
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Nicholas Paldino [.NET/C# MVP]

            #6
            Re: Custom attributes to define min, max, ... value on numerical properties

            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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...[color=blue]
            > 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]" <nicholas.paldi no@exisconsulti ng.com> a
            > écrit dans le message de news: OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=green]
            > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
            > > > Hi All,
            > > >
            > > > Did somebody already define attributes for numerical properties to[/color][/color]
            > define[color=green][color=darkred]
            > > > value : minima, maxima, a number of decimal, ...? This information[/color][/color]
            > would[color=green]
            > > be[color=darkred]
            > > > useful to unify syntax
            > > >
            > > > Polo
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Dmitriy Lapshin [C# / .NET MVP]

              #7
              Re: Custom attributes to define min, max, ... value on numerical properties

              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

              Bring the power of unit testing to VS .NET IDE

              "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> wrote
              in message news:%23mOPM9pg DHA.1672@TK2MSF TNGP12.phx.gbl. ..[color=blue]
              > 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[/color]
              add[color=blue]
              > 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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...[color=green]
              > > Sorry but It is not my problem.
              > >
              > > I woul like to define custom attributes to set min, max, number of[/color][/color]
              digits[color=blue][color=green]
              > > by exemple :
              > > [MinValue(0)]
              > > [MaxValue(100)]
              > > ..
              > > public int Temperature
              > > {
              > > ...
              > > }
              > >
              > > Somebody has you it already defined this type of attribute.
              > >
              > > "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> a
              > > écrit dans le message de news: OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=darkred]
              > > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..
              > > > > Hi All,
              > > > >
              > > > > Did somebody already define attributes for numerical properties to[/color]
              > > define[color=darkred]
              > > > > value : minima, maxima, a number of decimal, ...? This information[/color]
              > > would[color=darkred]
              > > > be
              > > > > useful to unify syntax
              > > > >
              > > > > Polo
              > > > >
              > > > >
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]

              Comment

              • Dmitriy Lapshin [C# / .NET MVP]

                #8
                Re: Custom attributes to define min, max, ... value on numerical properties

                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

                Bring the power of unit testing to VS .NET IDE

                "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> wrote
                in message news:%23mOPM9pg DHA.1672@TK2MSF TNGP12.phx.gbl. ..[color=blue]
                > 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[/color]
                add[color=blue]
                > 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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...[color=green]
                > > Sorry but It is not my problem.
                > >
                > > I woul like to define custom attributes to set min, max, number of[/color][/color]
                digits[color=blue][color=green]
                > > by exemple :
                > > [MinValue(0)]
                > > [MaxValue(100)]
                > > ..
                > > public int Temperature
                > > {
                > > ...
                > > }
                > >
                > > Somebody has you it already defined this type of attribute.
                > >
                > > "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> a
                > > écrit dans le message de news: OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=darkred]
                > > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..
                > > > > Hi All,
                > > > >
                > > > > Did somebody already define attributes for numerical properties to[/color]
                > > define[color=darkred]
                > > > > value : minima, maxima, a number of decimal, ...? This information[/color]
                > > would[color=darkred]
                > > > be
                > > > > useful to unify syntax
                > > > >
                > > > > Polo
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]

                Comment

                • Nicholas Paldino [.NET/C# MVP]

                  #9
                  Re: Custom attributes to define min, max, ... value on numerical properties

                  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-code@no-spam-please.hotpop.c om> wrote
                  in message news:eBfabDqgDH A.1684@TK2MSFTN GP10.phx.gbl...[color=blue]
                  > Nicholas,
                  >
                  > It would be nice if these attributes could also perform corresponding data
                  > validation. I have seen an article called "Aspect-Oriented Programming"[/color]
                  that[color=blue]
                  > 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]" <nicholas.paldi no@exisconsulti ng.com>[/color]
                  wrote[color=blue]
                  > in message news:%23mOPM9pg DHA.1672@TK2MSF TNGP12.phx.gbl. ..[color=green]
                  > > Pol,
                  > >
                  > > Well, there is no attribute like that, but you can always create[/color][/color]
                  your[color=blue][color=green]
                  > > own. You just have to derive a class from the Attribute class and then[/color]
                  > add[color=green]
                  > > 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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...[color=darkred]
                  > > > Sorry but It is not my problem.
                  > > >
                  > > > I woul like to define custom attributes to set min, max, number of[/color][/color]
                  > digits[color=green][color=darkred]
                  > > > by exemple :
                  > > > [MinValue(0)]
                  > > > [MaxValue(100)]
                  > > > ..
                  > > > public int Temperature
                  > > > {
                  > > > ...
                  > > > }
                  > > >
                  > > > Somebody has you it already defined this type of attribute.
                  > > >
                  > > > "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com>[/color][/color][/color]
                  a[color=blue][color=green][color=darkred]
                  > > > écrit dans le message de news:[/color][/color][/color]
                  OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=blue][color=green][color=darkred]
                  > > > > Polo,
                  > > > >
                  > > > > I believe the static property on each numeric type is MinValue[/color][/color][/color]
                  and[color=blue][color=green][color=darkred]
                  > > > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..
                  > > > > > Hi All,
                  > > > > >
                  > > > > > Did somebody already define attributes for numerical properties to
                  > > > define
                  > > > > > value : minima, maxima, a number of decimal, ...? This[/color][/color][/color]
                  information[color=blue][color=green][color=darkred]
                  > > > would
                  > > > > be
                  > > > > > useful to unify syntax
                  > > > > >
                  > > > > > Polo
                  > > > > >
                  > > > > >
                  > > > >
                  > > > >
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >[/color]


                  Comment

                  • Nicholas Paldino [.NET/C# MVP]

                    #10
                    Re: Custom attributes to define min, max, ... value on numerical properties

                    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-code@no-spam-please.hotpop.c om> wrote
                    in message news:eBfabDqgDH A.1684@TK2MSFTN GP10.phx.gbl...[color=blue]
                    > Nicholas,
                    >
                    > It would be nice if these attributes could also perform corresponding data
                    > validation. I have seen an article called "Aspect-Oriented Programming"[/color]
                    that[color=blue]
                    > 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]" <nicholas.paldi no@exisconsulti ng.com>[/color]
                    wrote[color=blue]
                    > in message news:%23mOPM9pg DHA.1672@TK2MSF TNGP12.phx.gbl. ..[color=green]
                    > > Pol,
                    > >
                    > > Well, there is no attribute like that, but you can always create[/color][/color]
                    your[color=blue][color=green]
                    > > own. You just have to derive a class from the Attribute class and then[/color]
                    > add[color=green]
                    > > 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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...[color=darkred]
                    > > > Sorry but It is not my problem.
                    > > >
                    > > > I woul like to define custom attributes to set min, max, number of[/color][/color]
                    > digits[color=green][color=darkred]
                    > > > by exemple :
                    > > > [MinValue(0)]
                    > > > [MaxValue(100)]
                    > > > ..
                    > > > public int Temperature
                    > > > {
                    > > > ...
                    > > > }
                    > > >
                    > > > Somebody has you it already defined this type of attribute.
                    > > >
                    > > > "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com>[/color][/color][/color]
                    a[color=blue][color=green][color=darkred]
                    > > > écrit dans le message de news:[/color][/color][/color]
                    OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=blue][color=green][color=darkred]
                    > > > > Polo,
                    > > > >
                    > > > > I believe the static property on each numeric type is MinValue[/color][/color][/color]
                    and[color=blue][color=green][color=darkred]
                    > > > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..
                    > > > > > Hi All,
                    > > > > >
                    > > > > > Did somebody already define attributes for numerical properties to
                    > > > define
                    > > > > > value : minima, maxima, a number of decimal, ...? This[/color][/color][/color]
                    information[color=blue][color=green][color=darkred]
                    > > > would
                    > > > > be
                    > > > > > useful to unify syntax
                    > > > > >
                    > > > > > Polo
                    > > > > >
                    > > > > >
                    > > > >
                    > > > >
                    > > >
                    > > >[/color]
                    > >
                    > >[/color]
                    >[/color]


                    Comment

                    • Pol Bawin

                      #11
                      Re: Custom attributes to define min, max, ... value on numerical properties

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


                      "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> a
                      écrit dans le message de news: e#EgGPsgDHA.212 4@TK2MSFTNGP12. phx.gbl...[color=blue]
                      > 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 ").[/color]
                      You[color=blue]
                      > need to have code that performs actions based on the meta-data, which is[/color]
                      in[color=blue]
                      > fact what the implementation of Aspect Oriented Programming that you saw[/color]
                      (I[color=blue]
                      > 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-code@no-spam-please.hotpop.c om> wrote
                      > in message news:eBfabDqgDH A.1684@TK2MSFTN GP10.phx.gbl...[color=green]
                      > > Nicholas,
                      > >
                      > > It would be nice if these attributes could also perform corresponding[/color][/color]
                      data[color=blue][color=green]
                      > > validation. I have seen an article called "Aspect-Oriented Programming"[/color]
                      > that[color=green]
                      > > 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]" <nicholas.paldi no@exisconsulti ng.com>[/color]
                      > wrote[color=green]
                      > > in message news:%23mOPM9pg DHA.1672@TK2MSF TNGP12.phx.gbl. ..[color=darkred]
                      > > > Pol,
                      > > >
                      > > > Well, there is no attribute like that, but you can always create[/color][/color]
                      > your[color=green][color=darkred]
                      > > > own. You just have to derive a class from the Attribute class and[/color][/color][/color]
                      then[color=blue][color=green]
                      > > add[color=darkred]
                      > > > 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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...
                      > > > > Sorry but It is not my problem.
                      > > > >
                      > > > > I woul like to define custom attributes to set min, max, number of[/color]
                      > > digits[color=darkred]
                      > > > > by exemple :
                      > > > > [MinValue(0)]
                      > > > > [MaxValue(100)]
                      > > > > ..
                      > > > > public int Temperature
                      > > > > {
                      > > > > ...
                      > > > > }
                      > > > >
                      > > > > Somebody has you it already defined this type of attribute.
                      > > > >
                      > > > > "Nicholas Paldino [.NET/C# MVP]"[/color][/color][/color]
                      <nicholas.paldi no@exisconsulti ng.com>[color=blue]
                      > a[color=green][color=darkred]
                      > > > > écrit dans le message de news:[/color][/color]
                      > OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=green][color=darkred]
                      > > > > > Polo,
                      > > > > >
                      > > > > > I believe the static property on each numeric type is MinValue[/color][/color]
                      > and[color=green][color=darkred]
                      > > > > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..
                      > > > > > > Hi All,
                      > > > > > >
                      > > > > > > Did somebody already define attributes for numerical properties[/color][/color][/color]
                      to[color=blue][color=green][color=darkred]
                      > > > > define
                      > > > > > > value : minima, maxima, a number of decimal, ...? This[/color][/color]
                      > information[color=green][color=darkred]
                      > > > > would
                      > > > > > be
                      > > > > > > useful to unify syntax
                      > > > > > >
                      > > > > > > Polo
                      > > > > > >
                      > > > > > >
                      > > > > >
                      > > > > >
                      > > > >
                      > > > >
                      > > >
                      > > >[/color]
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • Pol Bawin

                        #12
                        Re: Custom attributes to define min, max, ... value on numerical properties

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


                        "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> a
                        écrit dans le message de news: e#EgGPsgDHA.212 4@TK2MSFTNGP12. phx.gbl...[color=blue]
                        > 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 ").[/color]
                        You[color=blue]
                        > need to have code that performs actions based on the meta-data, which is[/color]
                        in[color=blue]
                        > fact what the implementation of Aspect Oriented Programming that you saw[/color]
                        (I[color=blue]
                        > 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-code@no-spam-please.hotpop.c om> wrote
                        > in message news:eBfabDqgDH A.1684@TK2MSFTN GP10.phx.gbl...[color=green]
                        > > Nicholas,
                        > >
                        > > It would be nice if these attributes could also perform corresponding[/color][/color]
                        data[color=blue][color=green]
                        > > validation. I have seen an article called "Aspect-Oriented Programming"[/color]
                        > that[color=green]
                        > > 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]" <nicholas.paldi no@exisconsulti ng.com>[/color]
                        > wrote[color=green]
                        > > in message news:%23mOPM9pg DHA.1672@TK2MSF TNGP12.phx.gbl. ..[color=darkred]
                        > > > Pol,
                        > > >
                        > > > Well, there is no attribute like that, but you can always create[/color][/color]
                        > your[color=green][color=darkred]
                        > > > own. You just have to derive a class from the Attribute class and[/color][/color][/color]
                        then[color=blue][color=green]
                        > > add[color=darkred]
                        > > > 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:e15r41pgDH A.2748@TK2MSFTN GP11.phx.gbl...
                        > > > > Sorry but It is not my problem.
                        > > > >
                        > > > > I woul like to define custom attributes to set min, max, number of[/color]
                        > > digits[color=darkred]
                        > > > > by exemple :
                        > > > > [MinValue(0)]
                        > > > > [MaxValue(100)]
                        > > > > ..
                        > > > > public int Temperature
                        > > > > {
                        > > > > ...
                        > > > > }
                        > > > >
                        > > > > Somebody has you it already defined this type of attribute.
                        > > > >
                        > > > > "Nicholas Paldino [.NET/C# MVP]"[/color][/color][/color]
                        <nicholas.paldi no@exisconsulti ng.com>[color=blue]
                        > a[color=green][color=darkred]
                        > > > > écrit dans le message de news:[/color][/color]
                        > OnHh5qpgDHA.230 0@TK2MSFTNGP10. phx.gbl...[color=green][color=darkred]
                        > > > > > Polo,
                        > > > > >
                        > > > > > I believe the static property on each numeric type is MinValue[/color][/color]
                        > and[color=green][color=darkred]
                        > > > > > 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:OgW%23vZpg DHA.1932@TK2MSF TNGP11.phx.gbl. ..
                        > > > > > > Hi All,
                        > > > > > >
                        > > > > > > Did somebody already define attributes for numerical properties[/color][/color][/color]
                        to[color=blue][color=green][color=darkred]
                        > > > > define
                        > > > > > > value : minima, maxima, a number of decimal, ...? This[/color][/color]
                        > information[color=green][color=darkred]
                        > > > > would
                        > > > > > be
                        > > > > > > useful to unify syntax
                        > > > > > >
                        > > > > > > Polo
                        > > > > > >
                        > > > > > >
                        > > > > >
                        > > > > >
                        > > > >
                        > > > >
                        > > >
                        > > >[/color]
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        • Jeffrey Tan[MSFT]

                          #13
                          Re: Custom attributes to define min, max, ... value on numerical properties


                          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" <pb@rtech.be>
                          | References: <OgW#vZpgDHA.19 32@TK2MSFTNGP11 .phx.gbl>
                          <OnHh5qpgDHA.23 00@TK2MSFTNGP10 .phx.gbl>
                          <e15r41pgDHA.27 48@TK2MSFTNGP11 .phx.gbl>
                          <#mOPM9pgDHA.16 72@TK2MSFTNGP12 .phx.gbl>
                          <eBfabDqgDHA.16 84@TK2MSFTNGP10 .phx.gbl>
                          <e#EgGPsgDHA.21 24@TK2MSFTNGP12 .phx.gbl>
                          | 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: <#QDlngzgDHA.18 32@TK2MSFTNGP09 .phx.gbl>
                          | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
                          | NNTP-Posting-Host: 194.78.114.66
                          | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP09.phx.g bl
                          | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1872 26
                          | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
                          |
                          | Thank you for this information, but or then I to find this article
                          |
                          |
                          | "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> a
                          | écrit dans le message de news: e#EgGPsgDHA.212 4@TK2MSFTNGP12. phx.gbl...
                          | > 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-code@no-spam-please.hotpop.c om>
                          wrote
                          | > in message news:eBfabDqgDH A.1684@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]" <nicholas.paldi no@exisconsulti ng.com>
                          | > wrote
                          | > > in message news:%23mOPM9pg DHA.1672@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:e15r41pgDH A.2748@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]"
                          | <nicholas.paldi no@exisconsulti ng.com>
                          | > a
                          | > > > > écrit dans le message de news:
                          | > OnHh5qpgDHA.230 0@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:OgW%23vZpg DHA.1932@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
                          | > > > > > >
                          | > > > > > >
                          | > > > > >
                          | > > > > >
                          | > > > >
                          | > > > >
                          | > > >
                          | > > >
                          | > >
                          | >
                          | >
                          |
                          |
                          |

                          Comment

                          Working...