Click or drag to resize
CTExtension Class
Base class for all CUSTOMTOOLS extensions.

Inheritant must implement Hook(CTInterface) and UnHook(CTInterface). Inheritant should have minimal or no constructor at all. For (un)initialization purposes implementations of InitNotify and UnInitNotify can be overridden.

To provide various funtionalities for core product, inheritant should implement GetInterface2(ctExtensionInterface) which must return valid object in every state of this extension. However, functions of the interfaces are not called unless the status is at least ctExtensionStatusInitialized.

Inheritance Hierarchy
SystemObject
  CTExtensionsCTExtension

Namespace: CTExtensions
Assembly: CTInterface (in CTInterface.dll)
Syntax
public abstract class CTExtension

The CTExtension type exposes the following members.

Constructors
  NameDescription
Public methodCTExtension
Constructor
Top
Properties
  NameDescription
Public propertyDatabase
Currently active database
Public propertyLicenseState
Indicator of current license state. Null = not checked True = value False = invalid
Public propertyProfile
Currently active profile
Top
Methods
  NameDescription
Public methodFriendlyName
Name of current extension in user-friendly manner. Can be localized. Short name of current type by default.
Public methodCode exampleGetExportProfileLinkToDBObject
Read id of the linked object stored by your extension using StoreExportProfileLinkToDBObject(ICTExportProfile, SQLObjectType, Int32, Int32). Use intData to identify specific link or otherwise first to found is returned.
Public methodGetInterface Obsolete.
Implementation of this function should return object implementing the requested type in every case if this extension supports the interface, including when this extension is not initialized. If this extension is not initialized, the only function that might get called is GetParent().
Public methodGetInterface2
Implementation of this function should return objects implementing the requested type in every case if this extension supports the interface, including when this extension is not initialized. If this extension is not initialized, the only function that might get called is GetParent().
Public methodGetInterfaceCapabilities
Returns all interfaces this extension is capable of.
Public methodGetSpecificInterface Obsolete.
Calls GetInterface2(ctExtensionInterface) and verifies that returned type is valid before passing it to the core.
Public methodGetSpecificInterfaces
Calls GetInterface2(ctExtensionInterface) and verifies that returned types are valid before passing it to the core.
Public methodGetStatus
Status of this extension as defined int CTEngineLib.ctExtensionStatus
Public methodHook
Implementation of this function is the only valid and supported place to hook into CTInterface events. Additional event -hooking is not allowed anywhere else. This is called after this object is initialized in case the current environment supports CTInterface events. Must not be called by anything else than internal implementation.
Public methodIdentifyingName
By default identifying name of each extensions is their full typename. This can be overridden but is not couraged as each add-in should have unique and non-changing identifying name.
Public methodInitNotify
Notification that this object is now initialized: Database and Profile are now valid. Inheritance may return false to prevent initialized status for eg. licensing purposes.
Public methodIsInitialized
Getter to indicate if this extension is currently initialized or not.
Public methodNotifyLoaded
Notification that this extension is now loaded.
Public methodNotifyUnLoaded
Notification that this extension is now UnLoaded.
Public methodReadExportSettings
Public methodRequestLicense
RequestLicense
Public methodSetGeneralParam
Possibility to provide some extension specific parameters.
Public methodCode exampleStoreExportProfileLinkToDBObject
Store link-data of your extension from export profile to given DB object type with given id. ID's stored using this function are kept linked to correct objects even in profile import/export -cases. Use intData to distinct different links of same type.
Public methodStoreExportSettings
Store arbitrary data to given export profile's data slot for your extension. You may store easily one string and one integer per export profile, or even unlimited bytearray.

To store settings that consider links to other CT objects, use StoreExportProfileLinkToDBObject(ICTExportProfile, SQLObjectType, Int32, Int32) so the object IDs are handled correctly in import/export.

Public methodUnHook
Implementation of this function must release all event hooks added at Hook(CTInterface). This function may be called multiple times. This is called before the object is going to be uninitialized, re-initialized or if CTInterface object is changed. Must not be called by anything else than internal implementation.
Public methodUnInitNotify
Notification that this object is now un-initialized: Database and Profile are not valid anymore.
Public methodUnload
Unloads this extension.
Top
Examples
Minimal CTExtension -style script Add-in:
C#
// @AUTO-REFERENCE { [CT_INSTALL_PATH]\CTInterface.dll }
// @AUTO-REFERENCE { [CT_INSTALL_PATH]\Interop.CTEngineLib.dll }

using ATR.CT.CTInterface;
using CTExtensions;
using CTEngineLib;

public class MyAddin : CTExtension
{

  public override bool Hook(CTInterface oCTInterface)
  {
    bool bHooked = false;
    if (oCTInterface != null)
    {
      // Hook to CTInterface events and set bHooked = true.
    }
    return bHooked;
  }

  public override void UnHook(CTInterface oCTInterface)
  {
    if (oCTInterface != null)
    {
      // Un-Hook all handlers from CTInterface
    }
  }

}
Availability

CUSTOMTOOLS 2017 SP1


See Also