Open topic with navigation

# Extend ConnectorBase

To create a new connector you must create a class that extends the `Autonomy.Connector.ConnectorBase` class. For example:

    using System;
    using Autonomy.Connector;

    namespace MyConnectorNamespace
    {
    	public class MyConnector : ConnectorBase
    	{
    		public MyConnector(IConfig config, ILog log) :
    		    base("My Connector" )
    		{
    		}

    		public override void Synchronize(ISynchronizeTask task)
    		{
    			string target = task.TaskConfig.Read("Target", "World");
    			task.Log.WriteLine(LogLevel.Normal, "Hello " + target);
    		}
    	}
    }

NOTE:

As shown in the example above, any connector implementation must extend `ConnectorBase` and have a constructor that takes two arguments (an `IConfig` and an `ILog`).

Micro Focus recommends that the `I` `Config` instance provided to the constructor is used only from within the constructor and that a reference to this object is not kept. This configuration is generally only useful for global settings that change how the connector behaves as a whole. Configuration for tasks should be accessed using the configuration objects provided to each task implementation.

The instance of `I` `Log` provided to the constructor can be used outside of the constructor, and writes to the connector's application log stream. It should not be used for logging that is specific to a task (such as `Synchronize`).

The implementation of `Synchronize` uses `task.``TaskConfig` and `task.``Log` which provide access to the configuration and log for the task.

The constructor of `ConnectorBase` is passed the string "My Connector". This is the name of the connector as it should be displayed to the user, and can be any string.

A Visual Studio solution with this sample code is provided in the SDK (`HelloWorldConnector.sln`).

This very basic connector implements only the `synchronize` fetch action. Your class does not have to implement the `synchronize` action, and it could implement other actions such as `collect`, `view`, `update`, and `delete`.

The body of the `synchronize` method reads a configuration value and writes a log message. It reads the value of the `Target` configuration parameter (which has a default value of "World") and then writes it to the synchronize log at the normal log level.

You now have the shell of a connector that you can compile and run. To run the connector, see Run the Connector.

© 2018 Micro Focus or one of its affiliates | Send documentation feedback to Micro Focus Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm