Click or drag to resize

MatrixDataProviderExtension Class

Base implementation of interface type ctExtensionInterfaceMatrixDataProvider. Must implement at least GetParent. Override GetInterface2(ctExtensionInterface) in your extension and return your implementation of this interface when requested type is ctExtensionInterfaceMatrixDataProvider. This extension allows overriding Revision and CustomScope data; i.e. to return data for them from a scripted source.
Inheritance Hierarchy
SystemObject
  CTExtensions.InterfacesMatrixDataProviderExtension

Namespace:  CTExtensions.Interfaces
Assembly:  CTInterface (in CTInterface.dll)
Syntax
public abstract class MatrixDataProviderExtension : IExtensionInterface

The MatrixDataProviderExtension type exposes the following members.

Constructors
  NameDescription
Protected methodMatrixDataProviderExtension
Initializes a new instance of the MatrixDataProviderExtension class
Top
Methods
  NameDescription
Public methodGetParent
Must implement. Return parent CTExtension of this extension interface.
Public methodOverrideMatrixData
Allows overriding matrix data (Revisions, CustomScopes) for files when the CT Core is about to read and cache it. Enables custom data sourcing for Revisions and CustomScopes.
Top
Examples
This example shows how to override Revision (or CustomScope) data with a CTExtension that has MatrixDataProviderExtension capability.

Language: C#
Class name: RevisionsExtension
C#
// @AUTO-REFERENCE { [CT_INSTALL_PATH]\CTInterface.dll }
// @AUTO-REFERENCE { [CT_INSTALL_PATH]\Interop.CTEngineLib.dll }

using ATR.CT.CTInterface;
using CTExtensions;
using CTExtensions.Interfaces;
using CTEngineLib;
using System.Collections.Generic;
using System;

namespace Example
{

  /*
  * YOU MUST HAVE only following Revision scope properties defined 
  * (Attribute | Label) and they must be editboxes:
  *
  *    revision     |   Revision
  *    description  |   Description
  *    designer     |   Approved By
  *
  *
  * This extension overrides revisions with following data
  *
  *   A | Here's Johnny!                    | Jack Nicholson
  *   B | Say 'hello' to my little friend!  | Al Pacino
  *   C | Revision you can't refuse.        | Marlon Brando
  *
  */
  public class RevisionsExtension : CTExtension
  {
    private RevisionProvider moRevisionProvider = null;

    public override bool Hook(CTInterface oCTInterface)
    {
      return false;
    }

    public override void UnHook(CTInterface oCTInterface)
    {

    }

    public override IExtensionInterface[] GetInterface2(ctExtensionInterface eInterface)
    {
      if (eInterface == ctExtensionInterface.ctExtensionInterfaceMatrixDataProvider)
      {
        if (moRevisionProvider == null)
          moRevisionProvider = new RevisionProvider(this);
        return new[] { moRevisionProvider };
      }
      return null;
    }


    class RevisionProvider : MatrixDataProviderExtension
    {

      RevisionsExtension moParent;

      public RevisionProvider(RevisionsExtension parent)
      {
        moParent = parent;
      }

      public override ICTExtension GetParent()
      {
        return moParent;
      }


      public override bool OverrideMatrixData(string bsFilename, string bsConfiguration, ctPropertyScope eScope, string bsData, ref string pbsOverriddenData)
      {


        bool bOverride = false;
        if (eScope == ctPropertyScope.ctPropertyScopeRevision)
        {
          var headers = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase)
        {
          { "revision", "Revision" },
          { "description", "Description" },
          { "designer", "Approved By" }
        };

          var data = new MatrixData(headers);

          var row = data.AddRow();
          row.SetValue("revision", "A");
          row.SetValue("description", "Here's Johnny!");
          row.SetValue("designer", "Jack Nicholson");

          row = data.AddRow();
          row.SetValue("revision", "B");
          row.SetValue("description", "Say 'hello' to my little friend!");
          row.SetValue("designer", "Al Pacino");

          row = data.AddRow();
          row.SetValue("revision", "C");
          row.SetValue("description", "Revision you can't refuse.");
          row.SetValue("designer", "Marlon Brando");

          pbsOverriddenData = data.ToString();
          bOverride = true;
        }

        return bOverride;
      }
    }

  }


}
Availability

CUSTOMTOOLS 2022 SP1


See Also