Capability interfaces and registration
When you build a connector based on the Tridion Connector Template, you automatically have interfaces to the various connector capabilities. It is nonetheless important to understand some basics of how the capabilities are implemented and registered.
When you start a connector, the connector's interface registers the capability interfaces. A connector can register the scope of each capability as either entity-specific or connector-wide, where:
- An entity-specific capability is limited to a certain entity type. For example, register a capability that applies only to a specific entity type, a contact.
- A connector-wide capability can be used for any registered entity type.
For a given connector, the Application Client first looks for entity-specific capabilities, based on the connector's entity type. If Application Client fails to find any, it then looks for connector-wide capabilities.
Note that you can implement connector capabilities either as separate classes, which is the approach we recommend, or as part of the connector implementation. The following sample code illustrates implementing capabilities as separate classes:
public class MyEntityService : IGetEntity, ICreateEntity, IUpdateEntity, IDeleteEntity
{
public IEntity GetEntity(IEntityIdentity identity, IConnectorContext context = null)
{
return new MyEntity(identity)
{
Name = "Arne Bengt",
Age = 23,
Factor = 0.3f,
Price = 99.99,
Image = new BinaryReference { Type = "RefImage", Id = "/photo-1536649986370-e623f6c7c1e1" }
};
}
public IEntityIdentity CreateEntity(IEntityIdentity parentId, string type, IEntity entity, IConnectorContext context = null)
{
...
}
public void UpdateEntity(IEntityIdentity identity, IEntity entity, IConnectorContext context = null)
{
...
}
public void DeleteEntity(IEntityIdentity identity, IConnectorContext context = null)
{
...
}
}
For a complete example of capability implementation and registration of its interfaces, refer to the Tridion Connector Template.