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
  1. Home
  2. General Programming
  3. C#
  4. Design question

Design question

Scheduled Pinned Locked Moved C#
designbusinesshelpquestion
4 Posts 4 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.
  • E Offline
    E Offline
    Elina Blank
    wrote on last edited by
    #1

    These are the requirements: Assembly ‘Shared’ defines class named ‘SharedClass’ . SharedClass contains field named ‘Info’. Assembly ‘Runtime’ defines class named ‘Manager’ ‘Manager’ should be allowed to read and change field ‘Info’ on the instance of SharedClass. Assembly ‘GUI’ defines class named ‘Client’. ‘Client’ can only read from field ‘Info’. Can somebody help outline design that supports such requirements. Thanks in advance, Elina

    L N B 3 Replies Last reply
    0
    • E Elina Blank

      These are the requirements: Assembly ‘Shared’ defines class named ‘SharedClass’ . SharedClass contains field named ‘Info’. Assembly ‘Runtime’ defines class named ‘Manager’ ‘Manager’ should be allowed to read and change field ‘Info’ on the instance of SharedClass. Assembly ‘GUI’ defines class named ‘Client’. ‘Client’ can only read from field ‘Info’. Can somebody help outline design that supports such requirements. Thanks in advance, Elina

      L Offline
      L Offline
      LongRange Shooter
      wrote on last edited by
      #2

      I tried writing an answer for this, but there are still some missing pieces. For example does Runtime own SharedClass or is SharedClass a static class that is visible to both Manager and Client? You did not say but imply that SharedClass is an instance class so someone must contain it. Then there is the way it is accessed. If you have a containing class and expose a method to do the read/update, you can alway incorporate a Context class that each caller would implement. The context would help the setter in SharedClass determine if the update is allowed in the given Context. One possibility: SharedClass exposes GetInstance(Context context) context is fed to the instance which is used to determine if the setter should be active. Another possibility: SharedClass is static and the access to info is exposed: public static bool UpdateInfo( object info, ContextClass context ) context contains the AssemblyName of the caller.

      1 Reply Last reply
      0
      • E Elina Blank

        These are the requirements: Assembly ‘Shared’ defines class named ‘SharedClass’ . SharedClass contains field named ‘Info’. Assembly ‘Runtime’ defines class named ‘Manager’ ‘Manager’ should be allowed to read and change field ‘Info’ on the instance of SharedClass. Assembly ‘GUI’ defines class named ‘Client’. ‘Client’ can only read from field ‘Info’. Can somebody help outline design that supports such requirements. Thanks in advance, Elina

        N Offline
        N Offline
        nevezuxa
        wrote on last edited by
        #3

        You can use InternalsVisibleToAttribute to supply access to internal members of assembly A to members od asembly B.

        //Inside Shared Assembly
        [assembly:InternalsVisibleTo("Runtime")]

        public class SharedClass
        {
        private string info;

        public string Info
        {
        get
        {
        return info;
        }
        }

        internal void SetInfo(string info)
        {
        this.info = info;
        }
        }

        Manager defined by Runtime has access to SetInfo and calls it to modify info.

        1 Reply Last reply
        0
        • E Elina Blank

          These are the requirements: Assembly ‘Shared’ defines class named ‘SharedClass’ . SharedClass contains field named ‘Info’. Assembly ‘Runtime’ defines class named ‘Manager’ ‘Manager’ should be allowed to read and change field ‘Info’ on the instance of SharedClass. Assembly ‘GUI’ defines class named ‘Client’. ‘Client’ can only read from field ‘Info’. Can somebody help outline design that supports such requirements. Thanks in advance, Elina

          B Offline
          B Offline
          BoneSoft
          wrote on last edited by
          #4

          Sounds like Model View Controller (or "shared gui manager" if you will) pattern... You'll have three projects 1. Shared project for model classes like SharedClass 2. Runtime project references Shared project so Manager has access to SharedClass 3. GUI project references Runtime and Shared project so Client can access SharedClass and Manager (though your requirments don't mention Manager access, it's part of MVC). So your view and your controller can see and use your model, and your view can also use your controller to act on the model. I'll leave it to you to decide how to restrict Client's write access. Visit BoneSoft.com

          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