ExtractDriverStorage Class
In This Article
A storage of drivers used to manage writing/reading operations for data extracts.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v24.2.Core.dll
NuGet Package: DevExpress.Dashboard.Core
#Declaration
#Remarks
By default, the DashboardExtractDataSource stores data within a file. If necessary, you add a custom logic for writing/reading extract data by implementing the ICustomExtractDriver interface. After you have implemented a custom driver, you can use it in two ways.
- To use a custom driver across all data extracts, assign its instance to the ExtractDriverStorage.DefaultDriver property.
- To use a custom driver for the specified data extract, register this driver in the
ExtractDriverStorage
using the ExtractDriverStorage.RegisterCustomDriver method and assign its name to the DashboardExtractDataSource.DriverName property.
#Example
The following example demonstrates how to create a custom driver to encrypt/decrypt extract data. It implements the ICustomExtractDriver interface:
- The ICustomExtractDriver.CreateWriteSession method creates a write session that is used to encrypt extract pages.
- The ICustomExtractDriver.CreateReadSession method creates a read session that provides logic for reading encrypted pages.
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using DevExpress.DashboardCommon;
namespace Dashboard_CustomExtractDriver {
public class ExtractEncryptionDriver : ICustomExtractDriver {
public IDriverReadSession CreateReadSession(string resourceName) {
return new EncryptionReadSession(FileExtractDriver.Instance.CreateReadSession(resourceName));
}
public IDriverWriteSession CreateWriteSession(string resourceName) {
return new EncryptionWriteSession(FileExtractDriver.Instance.CreateWriteSession(resourceName));
}
}
public class EncryptionWriteSession : IDriverWriteSession {
IDriverWriteSession writeSession;
public EncryptionWriteSession(IDriverWriteSession writeSession) {
this.writeSession = writeSession;
}
public void Dispose() {
writeSession.Dispose();
}
public void SetPage(Guid pageID, byte[] data) {
writeSession.SetPage(pageID, Encrypt(data));
}
byte[] Encrypt(byte[] page) {
byte[] entropy = { 1, 2, 3 };
byte[] encryptedPage = ProtectedData.Protect(page, entropy, DataProtectionScope.CurrentUser);
return encryptedPage;
}
}
public class EncryptionReadSession : IDriverReadSession {
IDriverReadSession readSession;
public EncryptionReadSession(IDriverReadSession readSession) {
this.readSession = readSession;
}
public void Dispose() {
readSession.Dispose();
}
byte[] Decrypt(byte[] page) {
byte[] entropy = { 1, 2, 3 };
byte[] decryptedPage = ProtectedData.Unprotect(page, entropy, DataProtectionScope.CurrentUser);
return decryptedPage;
}
public byte[] GetPage(Guid pageID) {
return Decrypt(readSession.GetPage(pageID));
}
public IEnumerable<Guid> GetPageIDs() {
return readSession.GetPageIDs();
}
}
}
See Also