Skip to main content
.NET Standard 2.0+

ValueManager Class

Represents an auxiliary class used to initializes value managers.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v22.1.dll

Declaration

public class ValueManager

Remarks

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 Web Forms 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 Web Forms 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:

using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;

namespace MySolutionName.Module.Controllers {
    public class MyViewController : ViewController {
        protected override void OnActivated() {
            MyValue = "MyString"; // Store a value in ValueManager
            string myString = MyValue; // Get a value from ValueManager
        }
        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 Web Forms application, HttpSessionState will be used instead.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ValueManager class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

Object
ValueManager
See Also