Class PreviewProvider
The one-stop shop for asynchronous Previews. This class takes a Preview hint and through the static GetPreview(String) method converts it into a Preview. The underlying Preview providers are dynamically loaded plugins.
Due to the possibility of fairly expensive operations behind the Preview, this system SHOULD NOT be used to mass-produce Previews in some tight loop. Call the Preview provider only when you know that the user actually needs a Preview here and now.Namespace: SuperOffice.CRM.Previews
Assembly: SoDataBase.dll
Syntax
public static class PreviewProvider : Object
Remarks
Preview plugin providers must implement the SuperOffice.CRM.Previews.IPreviewProviderPlugin interface, and are welcome to use the PreviewPluginBase base class as well.
string myPreview = PreviewProvider.GetPreview("{contact_id=" + myContactId + "}");
Methods
GetPreview(String)
Process the incoming hint, and return a Preview. The Preview is either a parseable Preview hint, or a literal text.
Declaration
public static string GetPreview(string PreviewHint)
Parameters
Type | Name | Description |
---|---|---|
String | PreviewHint | Preview hint, or literal text |
Returns
Type | Description |
---|---|
String | Formatted Preview, possibly including image tags or other metainformation |
Remarks
If it is a literal, it may be formatted according to current Preview rules, and is then returned. A Preview hint has the syntax {<id>=<value>[<id>=<value>]...}, ie., curly braces around the whole string, and one or more id/value pairs. The delimiter within each pair is an equals sign, and the delimiter between pairs is an ampersand. A typical hint is {contact_id=5}. Another possible hint would be {contact_id=123&simple=true}.
Id's are case-insensitive, using the OrdinalIgnoreCase comparer provided by the .NET framework.GetPreviewHintValue(String)
Get the inner value of a dynamic Preview hint - or nothing, if the Preview is not a dynamic hint. Dynamic hints are delimited by braces and contain at least one name value pair.
Declaration
public static string GetPreviewHintValue(string delimitedHint)
Parameters
Type | Name | Description |
---|---|---|
String | delimitedHint | Preview hint, including the braces |
Returns
Type | Description |
---|---|
String | Preview hint minus the braces, or string.Empty if no braces were present (then this is not a dynamic hint at all) |
Remarks
Preview plugin providers must implement the SuperOffice.CRM.Previews.IPreviewProviderPlugin interface, and are welcome to use the PreviewPluginBase base class as well.
string myPreview = PreviewProvider.GetPreview("{contact_id=" + myContactId + "}");
MakeImageHint(String, Int32)
Utility method for creating an image hint with the correct syntax, from a key and id combination. If you are programming something that is derived from PreviewPluginBase, using the MakeImageHint(String, Int32) is somewhat simpler than using this method.
Declaration
public static string MakeImageHint(string key, int id)
Parameters
Type | Name | Description |
---|---|---|
String | key | Key name, for instance person_id. This key must be something that is recognized by the image streaming service. |
Int32 | id | ID for the given key |
Returns
Type | Description |
---|---|
String | Image hint |
Remarks
Preview plugin providers must implement the SuperOffice.CRM.Previews.IPreviewProviderPlugin interface, and are welcome to use the PreviewPluginBase base class as well.
string myPreview = PreviewProvider.GetPreview("{contact_id=" + myContactId + "}");
MakePreviewHint(String)
Utility method for creating a Preview hint with the correct syntax, from a single key and single value
Declaration
public static string MakePreviewHint(string keyAndValue)
Parameters
Type | Name | Description |
---|---|---|
String | keyAndValue | Key and value with an equals sign as the delimiter |
Returns
Type | Description |
---|---|
String | Preview hint |
Remarks
Preview plugin providers must implement the SuperOffice.CRM.Previews.IPreviewProviderPlugin interface, and are welcome to use the PreviewPluginBase base class as well.
string myPreview = PreviewProvider.GetPreview("{contact_id=" + myContactId + "}");
MakePreviewHint(String, Int32)
Utility method for creating a Preview hint with the correct syntax, from a single key and single value
Declaration
public static string MakePreviewHint(string key, int value)
Parameters
Type | Name | Description |
---|---|---|
String | key | Key name |
Int32 | value | Key value |
Returns
Type | Description |
---|---|
String | Preview hint |
Remarks
Preview plugin providers must implement the SuperOffice.CRM.Previews.IPreviewProviderPlugin interface, and are welcome to use the PreviewPluginBase base class as well.
string myPreview = PreviewProvider.GetPreview("{contact_id=" + myContactId + "}");
ProcessHints(String)
Process hints by calling provider plugins as needed
Declaration
public static PreviewData ProcessHints(string nameValueHints)
Parameters
Type | Name | Description |
---|---|---|
String | nameValueHints | Name/value hints without leading/trailing braces |
Returns
Type | Description |
---|---|
PreviewData | Hints from each Preview provider, separated by newline |
Remarks
Preview plugins are called in parallel to improve snappiness