BindToTypePolicy.QueryBindToType Event
Allows you to spot dynamic loading of a type, check its name and assembly, and allow the type resolve operation.
Namespace: DevExpress.Utils
Assembly: DevExpress.Data.v24.2.dll
NuGet Package: DevExpress.Data
#Declaration
public static event BindToTypePolicy.WeakEventHandler<BindToTypePolicy.QueryBindToTypeEventArgs> QueryBindToType
#Event Data
The QueryBindToType event's data class is BindToTypePolicy.QueryBindToTypeEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Assembly | Gets the assembly that contains the processed type. |
Assembly |
Gets the assembly name.
Inherited from Bind |
Assembly |
Gets the assembly-qualified name of the type, which includes the name of the assembly from which this Type object is being loaded.
|
Cancel |
Gets or sets a value indicating whether the event should be canceled.
Inherited from Cancel |
Is |
Gets whether the type is whitelisted (the type is safe).
Inherited from Bind |
Is |
|
Query |
This member supports the internal infrastructure and is not intended to be used directly from your code.
Inherited from Bind |
Source |
|
Type | Gets or sets the type. |
Type |
Gets the type name. |
The event data class exposes the following methods:
Method | Description |
---|---|
To |
Returns a string in the following format: “Query Level: {Query |
#Remarks
The BindToTypePolicy fires the QueryBindToType
event every time DevExpress UI controls call the Type.GetType() method.
namespace DXApplication {
internal static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
DevExpress.Utils.BindToTypePolicy.QueryBindToType += BindToTypePolicy_QueryBindToType;
Application.Run(new Form1());
}
private static void BindToTypePolicy_QueryBindToType(object sender, DevExpress.Utils.BindToTypePolicy.QueryBindToTypeEventArgs e) {
if (!e.IsKnownType) {
// Resolves custom datasource types for DevExpress Reports.
if (e.TypeName == "ProductsJsonDataSource")
e.Type = typeof(ProductsJsonDataSource);
if (e.TypeName == "UsersJsonDataSource")
e.Type = typeof(UsersJsonDataSource);
}
}
}
}
Note
Handle the Query
Read the following topic for more information and examples: Safe Deserialization – How to Resolve Unknown Data Types.