As Lars explained, outside a provider there are no API methods that can help you, but in my ECL Event Handler example you can see how I did it.
I determined the location of the configuration file as follows and loaded it into an XDocument
:
// location and name of ECL config file
private const string EclConfigFile = @"{0}\config\ExternalContentLibrary.xml";
// ECL configuration namespace
private static readonly XNamespace EclNs = "http://www.sdltridion.com/ExternalContentLibrary/Configuration";
// read ExternalContentLibrary.xml from ..\Tridion\config folder
XDocument eclConfig = XDocument.Load(string.Format(EclConfigFile,
ConfigurationSettings.GetTcmHomeDirectory()));
Then you can access the values in the configuration file via LINQ to XML. In my ECL Event Handler example it looks like I'm doing exactly what you are looking for. I first build a list of mountpoint IDs based on a given mountpoint type, so that I can use MountPointIds.Contains(eclUri.MountPointId)
in my event handler to have it trigger only for the correct mountpoint.
Another option you can consider is storing it in your provider (IContentLibrary
), since that exposes a string configurationXmlElement
in its Initialize
method. Then in your mountpoint (IContentLibraryContext
), you could use the Dispatch
method to access whatever you stored.
update
To explain my second option (using the Dispatch
method) I'm basing my code samples on my Flickr ECL provider.
Provider.cs
// added to line 21
internal static string ConfigurationXmlElement { get; private set; }
// added to line 45
ConfigurationXmlElement = configurationXmlElement;
Mountpoint.cs
// changes to method on lines 155 - 158
public string Dispatch(string command, string payloadVersion, string payload, out string responseVersion)
{
if (command.Equals("GetConfigurationXmlElement"))
{
return Provider.ConfigurationXmlElement;
}
throw new NotSupportedException();
}
You can now call the dispatch method like this:
string responseVersion;
string xml = eclSession.GetContentLibrary(eclUri).Dispatch("GetConfigurationXmlElement", "1.0.0.0", "", out responseVersion);
In the Dispatch
method I ignored the payloadVersion
, this can be used to make the method work for a specific provider version (so that you can update the provider and still maintain backwards compatibility). The payload
parameter can be used to supply input (parameters) to the method (usually by sending an XML document as the payload
, containing whatever parameters you need to send).