Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Reuseability of controls

Reuseability of controls

Scheduled Pinned Locked Moved C#
questiondata-structureshelpdiscussion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rafone
    wrote on last edited by
    #1

    Good Morning Fellow Coders; I have a treeView that I have developed over the years. It has all the things that I need it to do in most of my apps including the ability for the user to persist it to a file on the hard drive. The problem is that I use it in many apps that I write but, as I adapt it to different apps it can only open files for a the app it was compiled in. My questions is this. How do I re-use it and keep the ability to open any of these files from any app I use it in? Do I create a stand-alone project for just the tree then change the namespace or do I have to make a control out of it? Any thoughts will be appreciated... tia rafone

    Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

    C 1 Reply Last reply
    0
    • R Rafone

      Good Morning Fellow Coders; I have a treeView that I have developed over the years. It has all the things that I need it to do in most of my apps including the ability for the user to persist it to a file on the hard drive. The problem is that I use it in many apps that I write but, as I adapt it to different apps it can only open files for a the app it was compiled in. My questions is this. How do I re-use it and keep the ability to open any of these files from any app I use it in? Do I create a stand-alone project for just the tree then change the namespace or do I have to make a control out of it? Any thoughts will be appreciated... tia rafone

      Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Rafone wrote:

      How do I re-use it and keep the ability to open any of these files from any app I use it in?

      You redesign it with extensibility points. In your example, saving and retrieving the tree state from a file and you having different file formats for various applications, you would add the ability of being able to query in all ways necessary the state and structure of the tree. Another class is responsible for persisting this to where ever you need it (file, database, whereever). If you have multiple ways of storing it you have multiple classes responsible for persisting the information. Single responsiblity principle.

      R 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Rafone wrote:

        How do I re-use it and keep the ability to open any of these files from any app I use it in?

        You redesign it with extensibility points. In your example, saving and retrieving the tree state from a file and you having different file formats for various applications, you would add the ability of being able to query in all ways necessary the state and structure of the tree. Another class is responsible for persisting this to where ever you need it (file, database, whereever). If you have multiple ways of storing it you have multiple classes responsible for persisting the information. Single responsiblity principle.

        R Offline
        R Offline
        Rafone
        wrote on last edited by
        #3

        Let me see if I can clarify. Right now I use it in a couple of apps. If I try to open one of the files made from myApp in myApp2 I get an exception... "Unable to find assembly 'myApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."} All I have done was to copy my tree.cs file from myApp to myApp2 and changed the namespace so it will work in myApp2. So...is this because the namespace's are different? If so can I just reference the myApp namespace in myApp2 and use the tree components from myApp? tia rafone

        Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

        L 1 Reply Last reply
        0
        • R Rafone

          Let me see if I can clarify. Right now I use it in a couple of apps. If I try to open one of the files made from myApp in myApp2 I get an exception... "Unable to find assembly 'myApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."} All I have done was to copy my tree.cs file from myApp to myApp2 and changed the namespace so it will work in myApp2. So...is this because the namespace's are different? If so can I just reference the myApp namespace in myApp2 and use the tree components from myApp? tia rafone

          Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, as long as you included a reference to your DLL, you can refer to its public types, either using the full name (mySpace.mySubspace...MyClass) or using a using statement (using mySpace.mySubspace; ) and a short name (MyClass instance=new MyClass()). There is no need to modify namespace names, they exist to help you keep things apart (avoid name clashes), not to make your job more difficult. PS: the types need to be public, VS often creates classes without attributes, just prefix "public". :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


          R 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, as long as you included a reference to your DLL, you can refer to its public types, either using the full name (mySpace.mySubspace...MyClass) or using a using statement (using mySpace.mySubspace; ) and a short name (MyClass instance=new MyClass()). There is no need to modify namespace names, they exist to help you keep things apart (avoid name clashes), not to make your job more difficult. PS: the types need to be public, VS often creates classes without attributes, just prefix "public". :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


            R Offline
            R Offline
            Rafone
            wrote on last edited by
            #5

            Excellent! Exactly what I needed. Thanks Luc rafone

            Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

            L 1 Reply Last reply
            0
            • R Rafone

              Excellent! Exactly what I needed. Thanks Luc rafone

              Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              You're welcome. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups