Skip to main content

ICustomObjectSerialize Interface

Declares methods implemented by classes that interact with the settings storage.

Namespace: DevExpress.ExpressApp.Utils

Assembly: DevExpress.ExpressApp.v25.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public interface ICustomObjectSerialize

Remarks

The ICustomObjectSerialize interface exposes two methods.

The ICustomObjectSerialize.ReadPropertyValues method handles loading the values from the settings storage.

You can implement the ICustomObjectSerialize interface in an AuthenticationStandardLogonParameters descendant, to customize the process of loading and saving logon parameters. The code below enables users to choose whether to input a password each time the Logon Window is displayed or input a password once and remember it in the logon parameters storage.

using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Security;
using DevExpress.ExpressApp.Utils;
// ...
[DomainComponent]
public class MyLogonParameters : AuthenticationStandardLogonParameters, ICustomObjectSerialize {
    private bool rememberPassword;
    public bool RememberPassword {
        get { 
           return rememberPassword; 
        }
        set { 
            rememberPassword = value;
        }
    }
    public void ReadPropertyValues(SettingsStorage storage) {
        UserName = storage.LoadOption("", "UserName");
        Password = storage.LoadOption("", "Password");
        RememberPassword = storage.LoadBoolOption("", "RememberPassword", false);
    }
    public void WritePropertyValues(SettingsStorage storage) {
        storage.SaveOption("", "UserName", UserName);
        storage.SaveOption("", "Password", RememberPassword ? Password : "");
        storage.SaveOption("", "RememberPassword", RememberPassword.ToString());
    }
}

Note

You may need to add a reference to the DevExpress.ExpressApp.Security.25.2.dll assembly.

Take note of the ICustomObjectSerialize.ReadPropertyValues and ICustomObjectSerialize.WritePropertyValues methods implementation. In the ReadPropertyValues method, the logon parameter values are loaded via the SettingsStorage.LoadOption and SettingsStorage.LoadBoolOption methods. In the WritePropertyValues method, the logon parameter values are saved via the SettingsStorage.SaveOption method. Non-string values should be converted to strings before saving. The RememberPassword property will be displayed in the Logon Window, together with the UserName and Password properties exposed by the AuthenticationStandardLogonParameters ancestor class. However, the RememberPassword property is not included in the authentication process.

To use custom logon parameters in the XAF application, specify the LogonParametersType property in the Application Designer.

LogonParameters_Custom

Run the application.

LogonSavePassword

Note

In an XAF Windows Forms application, the logon parameters are stored in the LogonParameters file. Blazor applications do not store logon parameters. You can change this behavior by handling the CreateCustomLogonParameterStore event.

In some scenarios, you may need to store non-string logon parameters. If a persistent object is used as a logon parameter, you can store the string representation of its BaseObject.Oid property or another property that has a unique value (for example, PermissionPolicyUser.UserName).

You can handle the XafApplication.LastLogonParametersRead, XafApplication.LastLogonParametersReading and XafApplication.LastLogonParametersWriting events to customize the process of saving and loading the logon parameters, instead of the approach described in this topic. Additionally, you can use custom settings storage by handling the XafApplication.CreateCustomLogonParameterStore event.

See Also