Data query file settings

0

I have some projects in my solution and in one of them I will have the settings configured with some parameters.

My question is: If you referenced this project in others, can I read these parameters in each project?

    
asked by anonymous 12.03.2017 / 18:22

2 answers

1

You basically have two options:

  • If you want to expose all properties set in settings , you can change the modifier of class Settings from internal to public
  • If you do not want to expose all properties set in settings , you can create a class to implement encapsulation. Ex:

    public class AcessoAoSettings 
    {
        public Propriedade1 
        { 
            get 
            {
                return Properties.Settings.Default.Propriedade1;
            }
            set
            {
                Properties.Settings.Default.Propriedade1 = value;
            }
        }
    
        public Propriedade2 
        { 
            get 
            {
                return Properties.Settings.Default.Propriedade2;
            }
            private set;
        }
    }
    

I particularly prefer the second option because if you want, you can control write access (in this code, Propriedade2 does this by leaving set as private ).

    
14.03.2017 / 16:22
1

You can use the Copy As Link feature. In your project B, go to the option to add an existing item, and choose the project configuration file A and add it as a link. See the pictures:

See Also.

    
13.03.2017 / 16:59