-
Notifications
You must be signed in to change notification settings - Fork 2
IProfileManager
zehavibarak edited this page Oct 27, 2022
·
1 revision
Some scenarios require you maintain custom settings for users in your app.
You can use the IProfileManager service to get a user profile, and then update and retrieve custom settings.
- Declare a model for your settings.
public struct MySetting {
public bool IsAvailable { get; set; }
}- Inject the IProfileManager service.
public class MyClass {
private readonly IProfileManager _profileManager;
public MyClass(IProfileManager profileManager) {
_profileManager = profileManager;
}
}- Use the Get() method to get the user profile, and the Set() and Get() methods to update settings and retrieve them.
public class MyClass {
...
public void Update(string userId) {
var profile = _profileManager.Get<MySettings>(userId);
profile.MyProperty = true;
_profileManager.Set(profile, userId);
}
}Note that settings model can include non-primitive properties, such as an array, dictionary.
Moding Ltd.