ValueManager Class

Represents an auxiliary class used to initializes value managers.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

public class ValueManager
Public Class ValueManager

A common task in a business application is to store temporary data accessible from any part of the application on a per-user basis. This task is solved differently under different platforms. For example, in a Windows Forms application, you would use static variables, while in an ASP.NET application, you would store the required data in session variables. In the context of the eXpressApp Framework, this means that you would have to implement the business logic in two platform-specific ways, for instance, via two platform-specific Controllers. The concept of value managers allows you to overcome this limitation, and have only one platform-independent Controller.

Value managers are instantiated via the ValueManager.GetValueManager<ValueType> method. This method initializes platform-specific value managers. So, the type of a value manager initialized via this method will be different in ASP.NET and Windows Forms applications. A value manager is an object which implements the IValueManager<ValueType> interface, and so has the Value property. This property returns a previously assigned value if it is available (use the CanManageValue property to check if a value is available).

The following example demonstates how to store a string value separately for each user. In a Module, ViewController or another appropriate class, declare a static property of the IValueManager<string> type:

public string MyValue {
    get {
        IValueManager<string> valueManager = ValueManager.GetValueManager<string>("myKey");
        if (valueManager.CanManageValue) 
            return valueManager.Value;
        else return "Some default value";
    }
    set {
        IValueManager<string> valueManager = ValueManager.GetValueManager<string>("myKey");
        if (valueManager.CanManageValue)
            valueManager.Value = value;
    }
}

When the demonstrated code is used in a Windows Forms application, a value manager will store the MyValue in a regular property. In an ASP.NET application, HttpSessionState will be used instead.

Inheritance

Object
ValueManager
See Also