문제

I am using XAF,I have an ApplicationSettings class,I create an object of this class in Updater.cs:

ApplicationSettings settings = ObjectSpace.FindObject<ApplicationSettings>(
    new BinaryOperator("Name", "DefaultSettings"));
if (settings == null) {
    settings = ObjectSpace.CreateObject<ApplicationSettings>();
    settings.Name = "DefaultSettings";
    // some code 
}

I want to get this object from another class, How can I do this?

도움이 되었습니까?

해결책

I believe that your ApplicationSettings class should be a singleton. This way, you can easily access it from any part of your application. Refer to the example from the XAF documentation for more details on how to implement this. If you cannot use this option for some reason, you can always access your object using the FindObject method of the ObjectSpace or Session classes (as you already wrote above):

ApplicationSettings settings = ObjectSpace.FindObject( new BinaryOperator("Name", "DefaultSettings"));

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top