Home > Plug-in Development > How to use DXCore DecoupledStorage to persist plug-in data

How to use DXCore DecoupledStorage to persist plug-in data

December 16th, 2010

To persist your data using the DecoupedStorage object, use the appropriate ReadXXX and WriteXXX methods. In case your settings are language dependant, DecoupledStorage includes a property “LanguageID” that can create and select child storage objects for the purposes of language-specific storage (e.g., to support independent settings for C#, C++, Basic, etc.). Just set the LanguageID to the appropriate Language identifier (e.g., “CSharp”, “C/C++”, “Basic”, etc.), and then read and write normally. To activate the language-neutral storage object, set the LanguageID to an empty string. If your code is inside a CodeRush Options Page, you can get the LanguageID through the Options page’s LanguageID property (also, you can handle the LanguageChanged event in your Options page to find out when the user wants to create settings for another programming language).

Here is a sample of writing and reading data via the DecoupledStorage object:

CSharp code:

  • Writing data:
using (DecoupledStorage storage = new DecoupledStorage("MyPlugInData"))
{
  storage.WriteInt32("Dementions", "Length", 100);
  storage.WriteInt32("Dementions", "Height", 200);
  storage.WriteInt32("Dementions", "Width", 300);
  storage.WriteString("General", "ObjectName", "MyPlugInData");
}
  • Reading data:
int length;
int height;
int width;
string objectName;
using (DecoupledStorage storage = new DecoupledStorage("MyPlugInData"))
{
  length = storage.ReadInt32("Dementions", "Length");
  height = storage.ReadInt32("Dementions", "Height");
  width = storage.ReadInt32("Dementions", "Width");
  objectName = storage.ReadString("General", "ObjectName");
}

VisualBasic code:

  • Writing data:
Using storage As DecoupledStorage = New DecoupledStorage("MyPlugInData")
  storage.WriteInt32("Dementions", "Length", 100)
  storage.WriteInt32("Dementions", "Height", 200)
  storage.WriteInt32("Dementions", "Width", 300)
  storage.WriteString("General", "ObjectName", "MyPlugInData")
End Using
  • Reading data:
Dim length As Integer
Dim height As Integer
Dim width As Integer
Dim objectName As String
Using storage As DecoupledStorage = New DecoupledStorage("MyPlugInData")
  length = storage.ReadInt32("Dementions", "Length")
  height = storage.ReadInt32("Dementions", "Height")
  width = storage.ReadInt32("Dementions", "Width")
  objectName = storage.ReadString("General", "ObjectName")
End Using
—–
Products: DXCore
Versions: 10.2 and up
VS IDEs: any
Updated: Dec/28/2010
ID: D050

Similar Posts: