• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Restrict access to a Class

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Restrict access to a Class

    Hey!

    I'm like, trying to don't put all the code together... make it more readable and easy to maintain, etc.

    The thing is, when i type "NinjaTrader.NinjaScript.AddOns." ALL the clases get listed.

    One way to stop this is...
    public class A {

    public class Hide {
    ....
    }

    }
    so... any ideas to put "Hide" out of A, and restrict the access?


    My regards.

    #2
    Don't make it public?

    Comment


      #3
      nope..

      public class A {

      }

      class Hide {
      ....
      }
      It's the same.. it can be accessed

      Comment


        #4
        Hmm, what are you really wanting to achieve?

        Comment


          #5
          I can do..

          Code:
          namespace ...
          {
          
              public partial class DOM ...
              {
          
              }
          
          }
          
          namespace ...
          {
          
              partial class DOM
              {
                  
                  class Row
                  {
                      
                  }
          
              }
          }
          But i don't want to put "class DOM" twice... i just want to restrict the access on its own...
          Attached Files

          Comment


            #6
            Hello Fernand0,

            Making a object such as a class private causes that class to only be accessible from within the parent container. If this is a private class within another class, only the parent class will have access to that child class.

            Below is a public link to a 3rd party educational site on the 'private' access modifier.
            https://www.dotnetperls.com/private

            As well as a public link to a 3rd party educational site on access modifiers in general.
            http://csharp.net-informations.com/l...specifiers.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Making a object such as a class private causes that class to only be accessible from within the parent container
              Yes, but i don't want to put the class inside the parent class.

              This is not ideal:
              Code:
              namespace ...
              {
              
                  public partial class DOM ...
                  {
              
                  }
              
              }
              
              namespace ...
              {
              
                  partial class DOM
                  {
                      
                      class Row
                      {
                          
                      }
              
                  }
              
              }
              This is..
              Code:
              namespace ...
              {
              
                  public class DOM ...
                  {
              
                  }
              
              }
              
              namespace ...
              {
              
                  class Row
                  {
                      
                  }
                  
              }
              internal doesn't work, there is no access keyword(to my knowledge) where Row just works in AddOns
              Last edited by Fernand0; 09-17-2018, 11:55 AM.

              Comment


                #8
                Hello Fernand0,

                I am not aware of a way to prevent a class from showing in the objects of a namespace, if the classes are in the same namespace and use the same access modifier.

                This thread will remain open for any community members that would like to assist.

                You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Ok, thank you Chelsea

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by levikNT, Today, 04:39 AM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by chartish, Today, 08:36 AM
                  2 responses
                  14 views
                  0 likes
                  Last Post chartish  
                  Started by login_dejavu, Yesterday, 04:58 AM
                  1 response
                  14 views
                  0 likes
                  Last Post NinjaTrader_RyanS  
                  Started by NinjaTrader_PaulH, Today, 07:40 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post NinjaTrader_PaulH  
                  Started by awesometrader, Today, 06:59 AM
                  2 responses
                  9 views
                  0 likes
                  Last Post awesometrader  
                  Working...
                  X