Question

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?

Was it helpful?

Solution

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"));

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top