/// <summary> /// Creates a new class of vector that matches the given fileName. /// </summary> /// <param name="fileName">The string fileName from which to create a vector.</param> /// <param name="featureType">Specifies the type of feature for this vector file</param> /// <param name="progHandler">Overrides the default progress handler with the specified progress handler</param> /// <returns>An IFeatureSet that allows working with the dataset.</returns> /// <exception cref="ArgumentNullException">Raised when fileName is null.</exception> /// <exception cref="IOException">Raised when suitable DataProvider not found.</exception> public IFeatureSet CreateVector(string fileName, FeatureType featureType, IProgressHandler progHandler) { if (fileName == null) { throw new ArgumentNullException("fileName", "fileName should be not null"); } // To Do: Add Customization that allows users to specify which plugins to use in priority order. // First check for the extension in the preferred plugins list var ext = Path.GetExtension(fileName); IDataProvider pdp; if (PreferredProviders.TryGetValue(ext, out pdp)) { var vp = pdp as IVectorProvider; if (vp != null) { var result = vp.CreateNew(fileName, featureType, true, progHandler); if (result != null) { return(result); } } // if we get here, we found the provider, but it did not succeed in opening the file. } // Then check the general list of developer specified providers... but not the directory providers foreach (var dp in DataProviders.OfType <IVectorProvider>()) { if (GetSupportedExtensions(dp.DialogReadFilter).Contains(ext)) { // attempt to open with the fileName. var result = dp.CreateNew(fileName, featureType, true, progHandler); if (result != null) { return(result); } } } throw new IOException(DataStrings.FileTypeNotSupported); }