How to register custom provider to the Factory?

Jun 22, 2011 at 4:53 PM

After writing a provider, how do I register it to the SDS factory?

Jun 22, 2011 at 7:28 PM
Edited Jun 24, 2011 at 12:50 PM

Hi,

There are three ways to register providers. First is a DataSetFactory.Register( )  group of methods. These methods allow both to register provider names and associate extensions to a particular provider. This works only within a program that invokes the method, until it is closed.

The second way is the method SearchFolder( ) that accepts a path and makes a search in that folder for all assemblies containing providers and registers found providers. The method works only for code compiled for DEBUG configuration. This makes it convenient for development on a machine without Scientific DataSet runtime installation. 

Third way to register provider is to add registration entry to configuration file. Special configuration part can be added in application config file (then this will work only for this application), or into the Machine.Config file (then it works for all applications on the machine). The latter is done by SDS installer.

 

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <!-- Declare configuration section named Microsoft.Research.Science.Data -->
  <configSections>
	<section name="microsoft.research.science.data.1.2" type="Microsoft.Research.Science.Data.Factory.FactoryConfigurationSection, Microsoft.Research.Science.Data, Version=1.2.6754.0, Culture=neutral, PublicKeyToken=e550de0161496f12"/>
  <!-- Declarations of other config sections -->
  </configSections>


  <microsoft.research.science.data.1.2>
        <factories>
         <!-- Example: CsvDataSet provider with name "csv" and extension *.csv -->
         <add name="csv" type="Microsoft.Research.Science.Data.CSV.CsvDataSet, Microsoft.Research.Science.Data.CSV, Version=1.2.6754.0, Culture=neutral, PublicKeyToken=e550de0161496f12"/>
         <add ext=".csv" type="Microsoft.Research.Science.Data.CSV.CsvDataSet, Microsoft.Research.Science.Data.CSV, Version=1.2.6754.0, Culture=neutral, PublicKeyToken=e550de0161496f12"/>

         <!-- Register factory by name -->
         <add name="myProvider" type="MyNamespace.MyFactory, MyAssembly"/>
         <!-- Register factory by extension --> 
         <add ext=".dat" type="MyNamespace.DatProvider, MyAssembly"/>
       </factories>
  </microsoft.research.science.data.1.2>
</configuration>

See also documentation (Start / All Programs / Scientific DataSet 1.2 / Scientific DataSet Reference), Microsoft.Research.Science.Data.Factory namespace, DataSetFactory class.

See also How to create read-only provider.