Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.


            As well as a public link to a 3rd party educational site on access modifiers in general.
            Access Modifiers describes as the scope of accessibility of an Object and its members
            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 DJ888, 04-16-2024, 06:09 PM
                  4 responses
                  12 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by terofs, Today, 04:18 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post terofs
                  by terofs
                   
                  Started by nandhumca, Today, 03:41 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post nandhumca  
                  Started by The_Sec, Today, 03:37 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post The_Sec
                  by The_Sec
                   
                  Started by GwFutures1988, Today, 02:48 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Working...
                  X