Integer Resources

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Esres

    Integer Resources

    I want to have a resource file with integers, rather than strings, and
    have VS 2008 generate a global object with integer properties, rather
    than string properties. Is this possible?

    (I know I can convert the values to strings, but I'd like to know if
    there's a cleaner solution.)

    Thanks

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Integer Resources

    Greg,

    Add a settings file instead. In that, you can specify the type of the
    setting and it will generate the type-safe properties to access the
    settings.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Greg Esres" <gesres@boundvo rtex.comwrote in message
    news:915f5653-f398-48e3-a88b-1c4abde5e83e@b1 g2000hsg.google groups.com...
    >I want to have a resource file with integers, rather than strings, and
    have VS 2008 generate a global object with integer properties, rather
    than string properties. Is this possible?
    >
    (I know I can convert the values to strings, but I'd like to know if
    there's a cleaner solution.)
    >
    Thanks
    >

    Comment

    • Greg Esres

      #3
      Re: Integer Resources

      Nicholas wrote:

      <<Add a settings file instead.  In that, you can specify the type of
      the setting and it will generate the type-safe properties to access
      the settings.>>

      Interesting...I wasn't familiar with this feature. Do you feel this
      is an appropriate way to define constants, such as data input field
      lengths?

      Thanks

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Integer Resources

        Greg,

        Well, if they are truly constants, then the value would never change and
        you should be defining them in code with const.

        For something like data input field lengths, I would think that there is
        a better way to do this. I would think that the underlying data store would
        have information on the field length which you can query, and not have to
        replicate the data (a DB will expose this information, if it is XML, then
        you should be able to get it from the schema).


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Greg Esres" <gesres@boundvo rtex.comwrote in message
        news:f79c18e2-6615-426a-84de-e56256694bde@a7 0g2000hsh.googl egroups.com...
        Nicholas wrote:

        <<Add a settings file instead. In that, you can specify the type of
        the setting and it will generate the type-safe properties to access
        the settings.>>

        Interesting...I wasn't familiar with this feature. Do you feel this
        is an appropriate way to define constants, such as data input field
        lengths?

        Thanks


        Comment

        • Greg Esres

          #5
          Re: Integer Resources

          Nicholas wrote:

          <<Well, if they are truly constants, then the value would never change
          and
          you should be defining them in code with const.>>

          Most things in life are constant in the short term, but variable in
          the long term. :-)

          <<For something like data input field lengths, I would think that
          there is
          a better way to do this. I would think that the underlying data store
          would
          have information on the field length which you can query>>

          Yes, that can be done, but presents somewhat of an organizational
          challenge for a large database. I don't have a paradigm in place for
          that. Might be able to use reflection to somewhat automate it, but
          I'll have to give it some thought.

          Preferable to have the code AND database pull from the same data
          dictionary.

          Thanks

          Comment

          • Pavel Minaev

            #6
            Re: Integer Resources

            On Jul 10, 12:19 am, Greg Esres <ges...@boundvo rtex.comwrote:
            Nicholas wrote:
            >
            <<Add a settings file instead.  In that, you can specify the type of
            the setting and it will generate the type-safe properties to access
            the settings.>>
            >
            Interesting...I wasn't familiar with this feature.  Do you feel this
            is an appropriate way to define constants, such as data input field
            lengths?
            If they are not truly constants, but rather tweakable parameters,
            then, yes, an application-wide settings file is the way to go.
            Just keep in mind that user will sufficient privileges to edit
            your .config will then be able to change them on his system...

            Comment

            • Greg Esres

              #7
              Re: Integer Resources

              Pavel wrote;
              <<If they are not truly constants, but rather tweakable parameters,
              then, >>

              Field lengths are probably something that no user should be able to
              modify. I'd rather have some way to periodically ensure there was a
              match between the database and what the application thought the field
              length were. I don't like the idea of the program checking on every
              execution, but having to change the source code and recompile is a bit
              inflexible. Resource files seem to be a good compromise, but the .Net
              environment seems to support only strings.

              Thanks

              Comment

              Working...