Show / Hide Table of Contents

Class ConfigDataHelper

Class that translates between name/value data dictionaries and strongly typed config data classes, as well as handling in-memory caching and on-disk persistence

Inheritance
object
ConfigDataHelper
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOfficeErpSyncConnectorWS
Assembly: SuperOffice.Plugins.dll
Syntax
public class ConfigDataHelper
Remarks

This class operates on a 'parameter class', which generally looks something like this:

public class DummyArguments
{
	[ConfigField("A String", CRM.FieldMetadataTypeInfo.Text, DisplayDescription = "This is just a string")]
	public string AString;

	[ConfigField("A Date", CRM.FieldMetadataTypeInfo.Datetime, DisplayDescription = "This is just a date picker")]
	public DateTime ADate;

	[ConfigField("A Password", CRM.FieldMetadataTypeInfo.Password, DisplayDescription = "This is just a password")]
	public string APassword;

	[ConfigField("Mandatory Int", CRM.FieldMetadataTypeInfo.Integer, DisplayDescription = "This is just a number", Access = CRM.FieldAccessInfo.Mandatory)]
	public int MandatoryInt;

	[ConfigField("A Checkbox", CRM.FieldMetadataTypeInfo.Checkbox, DisplayDescription = "This is just an option")]
	public int ACheckbox;
}

Data is cached in an in-memory cache, and persisted to Isolated Storage files for later retrieval. In general, name-value dictionaries with data passed in must conform exactly to the parameter class definition.

Passwords are persisted in an encrypted manner.

Connection GUID to config mappings are persisted using IConfigDataStore. The default implementation writes in isolated storage per-user, per-assembly, per-domain. This means that changing the identity of the app-pool or moving to a different machine will reset all connection config values. You can create your own implementation of IConfigDataStore to replace the isolated storage with something else if you want.

Constructors

ConfigDataHelper(IServiceProvider)

Declaration
public ConfigDataHelper(IServiceProvider serviceProvider)
Parameters
Type Name Description
IServiceProvider serviceProvider

Methods

DeleteData(Guid)

Delete persisted & cached data for a given Guid

Declaration
public void DeleteData(Guid key)
Parameters
Type Name Description
Guid key

Unique key

DeleteData(string)

Delete persisted & cached data for a given Guid

Declaration
public void DeleteData(string key)
Parameters
Type Name Description
string key

Unique key

GetData<ArgClass>(Dictionary<string, string>)

Translate data for a given key; from wire format (dictionary of name/value) to strongly typed class. Dictionary must match class exactly. This is called when Testing newly created connections.

Declaration
public ArgClass GetData<ArgClass>(Dictionary<string, string> wireFormat) where ArgClass : new()
Parameters
Type Name Description
Dictionarystringstring wireFormat

Dictionary of names/values to decode

Returns
Type Description
ArgClass
Type Parameters
Name Description
ArgClass

The class that contains your parameters, tagged with ConfigFieldAttribute attributes

GetData<ArgClass>(Guid)

Retrieve data for a given key; from cache if possible, otherwise from persistent, isolated storage

Declaration
public ArgClass GetData<ArgClass>(Guid key) where ArgClass : new()
Parameters
Type Name Description
Guid key

Unique key

Returns
Type Description
ArgClass
Type Parameters
Name Description
ArgClass

The class that contains your parameters, tagged with ConfigFieldAttribute attributes

GetData<ArgClass>(string)

Retrieve data for a given key; from cache if possible, otherwise from persistent, isolated storage

Declaration
public ArgClass GetData<ArgClass>(string key) where ArgClass : new()
Parameters
Type Name Description
string key

Unique key

Returns
Type Description
ArgClass
Type Parameters
Name Description
ArgClass

The class that contains your parameters, tagged with ConfigFieldAttribute attributes

GetMetaData<ArgClass>()

Get metadata for a configuration data class, ready to send to SuperOffice for display in a data-driven GUI

Declaration
public static FieldMetadataInfo[] GetMetaData<ArgClass>()
Returns
Type Description
FieldMetadataInfo
Type Parameters
Name Description
ArgClass

The class that contains your parameters, tagged with ConfigFieldAttribute attributes

SaveData<ArgClass>(Guid, Dictionary<string, string>)

Save (perrsistent & cached stores) data for a given Guid

Declaration
public void SaveData<ArgClass>(Guid key, Dictionary<string, string> data) where ArgClass : new()
Parameters
Type Name Description
Guid key

Unique key

Dictionarystringstring data

Configuration data to save; must exactly match the argument class

Type Parameters
Name Description
ArgClass

The class that contains your parameters, tagged with ConfigFieldAttribute attributes

SaveData<ArgClass>(string, Dictionary<string, string>)

Save (perrsistent & cached stores) data for a given Guid

Declaration
public void SaveData<ArgClass>(string key, Dictionary<string, string> data) where ArgClass : new()
Parameters
Type Name Description
string key

Unique key

Dictionarystringstring data

Configuration data to save; must exactly match the argument class

Type Parameters
Name Description
ArgClass

The class that contains your parameters, tagged with ConfigFieldAttribute attributes

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top