The UI data objects generated from the Xomega model are defined as partial classes, so that you could easily enhance them in separate files. This allows you to regenerate the data objects whenever the model changes without losing your manual customizations. Your enhancements may include adding your own additional data properties and child objects, adding validation logic or specifying any other presentation layer logic to support your screens.
Here are the steps you can take to customize the generated UI data objects.
- Add a new file that contains a partial class for your data object.
- Define any additional properties and/or child objects similar to the way they are being defined in the generated class.
- Override the OnInitialized method to create and configure your custom properties as well as to configure the data object and any of the generated properties.
- Specify any additional validation or other logic as required by your user interface.
Below is an example of customizing the generated
ErrorLogObject data object by adding a new property that combines the values from two generated properties and displays them in a certain format.
Code:
using System;
using Xomega.Framework;
using Xomega.Framework.Properties;
namespace MyProject.Client.Objects
{
public partial class ErrorLogObject
{
public const string ProcedureWithLine = "ProcedureWithLine";
// A formatted combination of the error procedure and the error line properties.
public ComboProperty ProcedureWithLineProperty { get; private set; }
protected override void OnInitialized()
{
// Initialize and configure any additional custom properties
// and perform other initialization tasks for the object.
// The generated properties have been initialized and configured by this point.
ProcedureWithLineProperty = new ComboProperty(this, ProcedureWithLine);
ProcedureWithLineProperty.SetComponentProperties(ErrorProcedureProperty, ErrorLineProperty);
ProcedureWithLineProperty.Format = "{0} [line: {1}]";
}
}
}