Pregunta

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?

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top