/// <summary>Provide a fresh instance of a loader which descriptor /// has previously been retrieved with the <see cref="EnumerateKnownLoaders"/> /// method.</summary> /// <param name="descriptor">Descriptor for the loader to be instanciated. /// </param> /// <returns></returns> public ILoader Instanciate(ILoaderDescriptor descriptor) { LoaderInstanciatorDelegate instanciator; if (!_knownLoaders.TryGetValue(descriptor, out instanciator)) { throw new ArgumentException(); } return(instanciator(null)); }
/// <summary>Register a loader in the collection of known ones. /// Currently, this is a core only feature. There is no way for the /// suite to be instructed by the client software to do this on the /// fly.</summary> /// <param name="descriptor">Registered loader descriptor (mandatory). /// </param> /// <param name="instanciator">An instanciator delegate that can create /// a fresh instance of the loader.</param> internal void RegisterLoader(ILoaderDescriptor descriptor, LoaderInstanciatorDelegate instanciator) { if (null == descriptor) { throw new ArgumentNullException(); } if (null == instanciator) { throw new ArgumentNullException(); } if (_knownLoaders.ContainsKey(descriptor)) { throw new InvalidOperationException(); } _knownLoaders.Add(descriptor, instanciator); return; }