Show / Hide Table of Contents

Class PreviewPluginBase

Base class for Preview provide plugins. This class contains some useful helper functions, and implements the Template Method pattern. Derived classes need to implement the InnerGetPreview(PreviewData) method, and can use the TryGetIntHint(String, out Int32) and similar methods to obtain values from the Preview hint.

Inheritance
Object
PreviewPluginBase
AppointmentPreviewPlugin
ContactPreviewPlugin
DocumentPreviewPlugin
FaqPreviewPlugin
PersonPreviewPlugin
ProductPreviewPlugin
ProjectPreviewPlugin
QuickReplyPreviewPlugin
ReplyTemplatePreviewPlugin
SalePreviewPlugin
SelectionPreviewPlugin
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.Previews
Assembly: SoDataBase.dll
Syntax
public abstract class PreviewPluginBase : IPreviewProviderPlugin, IPlugin
Remarks

The Preview hints are accessible through the Hints property, but clients should usually find the provided access methods sufficient. TryGetIntHint(String, out Int32), TryGetStringHint(String, out String) and TryGetBoolHint(String, out Boolean) look for and parse the given type of key, and return a bool value that specifies whether the given key was found.

and are boolean properties that give the result of a search for 'images=true' and 'simple=true', to promote a common way of specifying these two properties.

The class implements the SuperOffice.CRM.Previews.IPreviewProviderPlugin and thereby also the interfaces. Derived classes need to be marked with the attribute, specifying a provider name (please prefix with your company to help make it unique and recognizable), and optionally a priority. The attribute is also used to register hint keys; the derived class will be called only for requests matching at least one key.

Constructors

PreviewPluginBase()

Declaration
protected PreviewPluginBase()

Fields

ImageHint

Declaration
public const string ImageHint = "images"
Field Value
Type Description
String

SimpleHint

Declaration
public const string SimpleHint = "simple"
Field Value
Type Description
String

UpdatedHint

Declaration
public const string UpdatedHint = "updated"
Field Value
Type Description
String

Properties

Hints

The raw hints dictionary

Declaration
protected Dictionary<string, List<string>> Hints { get; }
Property Value
Type Description
Dictionary<String, List<String>>

Methods

FormatDescriptionText(String)

Remove blank lines from a string and make sure the length of the string does not exceed 256 characters. This method should be used to format the Text property of an entity like Appointment, Sale and Project, because the length of the text property is unlimited.

Declaration
protected static string FormatDescriptionText(string text)
Parameters
Type Name Description
String text

String to process

Returns
Type Description
String

Result with no blank lines and maximum 256 characters long

GetPreview(Dictionary<String, List<String>>, PreviewData)

Implements the interface method; caches this hints and calls the inner method

Declaration
public PreviewData GetPreview(Dictionary<string, List<string>> hints, PreviewData previewData)
Parameters
Type Name Description
Dictionary<String, List<String>> hints

Preview hints

PreviewData previewData
Returns
Type Description
PreviewData

Preview text, or string.Empty

GetRawValues(String)

Get raw hint values, based on the hint name

Declaration
protected List<string> GetRawValues(string hintName)
Parameters
Type Name Description
String hintName

Hint key to look for

Returns
Type Description
List<String>

List of raw values, or null if the hint did not exist

InnerGetPreview(PreviewData)

Subclass contract: derived class must implement their Preview logicin this method.

Declaration
protected abstract PreviewData InnerGetPreview(PreviewData previewData)
Parameters
Type Name Description
PreviewData previewData
Returns
Type Description
PreviewData

Preview text, or an empty string

Remarks

The Preview hints are accessible through the Hints property, but clients should usually find the provided access methods sufficient. TryGetIntHint(String, out Int32), TryGetStringHint(String, out String) and TryGetBoolHint(String, out Boolean) look for and parse the given type of key, and return a bool value that specifies whether the given key was found.

MakeImageHint(String, Int32)

Utility method for creating an image hint with the correct syntax, from a key and id combination. This method will automatically take into account the property of the current instance.

Declaration
protected 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

RemoveBlankLines(String)

Remove blank lines from a string, and convert \r\n to just \n. If the remainder of the string after processing is just \n, an empty string will be returned as the final result; otherwise we just remove single or multiple blank lines.

Declaration
protected static string RemoveBlankLines(string text)
Parameters
Type Name Description
String text

String to process

Returns
Type Description
String

Result with no blank lines

TryGetBoolHint(String, out Boolean)

Search the hints dictionary (this is an O(1) operation) for the given hint, and try to parse it as a bool. False is the result if the key is not found or has an invalid format. The return value is true if the hint is found and is parseable as a bool. Strings accepted are as for TryParse(String, Boolean). If more than one hint of the same name exists, the value of the first one will be used.

Declaration
protected bool TryGetBoolHint(string hintName, out bool result)
Parameters
Type Name Description
String hintName

Hint key to look for

Boolean result

Out: found value, or false

Returns
Type Description
Boolean

True if the hint is found and is valid

TryGetDateHint(String, out DateTime)

Search the hints dictionary (this is an O(1) operation) for the given hint, and try to parse it as a datetime. DateTime.MinValue is the result if the key is not found or has an invalid format. The return value is true iff the hint is found and is parseable as a datetime. Both the invariant and current cultures are used, in that order. If more than one hint of the same name exists, the value of the first one will be used.

Declaration
protected bool TryGetDateHint(string hintName, out DateTime result)
Parameters
Type Name Description
String hintName

Hint key to look for

DateTime result

Out: found value, or false

Returns
Type Description
Boolean

True if the hint is found and is valid

TryGetIntHint(String, out Int32)

Search the hints dictionary (this is an O(1) operation) for the given hint, and try to parse it as an int. Zero is the result if the key is not found or has an invalid format. The return value is true iff the hint is found and is parseable as an int. Formats accepted are as for . If more than one hint of the same name exists, the value of the first one will be used.

Declaration
protected bool TryGetIntHint(string hintName, out int result)
Parameters
Type Name Description
String hintName

Hint key to look for

Int32 result

Out: found value, or 0

Returns
Type Description
Boolean

True if the hint is found and is valid

TryGetStringHint(String, out String)

Search the hints dictionary (this is an O(1) operation) for the given hint. The return value is true iff the hint is found. If more than one hint of the same name exists, the value of the first one will be used.

Declaration
protected bool TryGetStringHint(string hintName, out string result)
Parameters
Type Name Description
String hintName

Hint key to look for

String result

Out: found value, or null

Returns
Type Description
Boolean

True if the hint is found and is valid

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 |  Back to top