Im writing a .net Standard class library and I want to publish it as an internal package,so i have two classes in same project let say as below :
public class classOne{ public void SomeMethod() { }} public class classTwo{ private ClassOne _classOne; public classOne clsOne { get { lock (padlock) { if (_classOne== null) _classOne= new ClassOne (); return _classOne; } } }}
As you seen above I want the developers to use class one as a property inside classTwo Also I want to prevent the instantiation of classOne. just the only way to call classOne methods is through classTwo "clsOne" property.
//I want this codeclassTwo clsTwo = new classTwo();clsTwo.clsOne.someMethod();//And Prevent to do this codeclassOne clsOnew= new classOne();clsOne.someMethod();
how do i implement that ?