Initialization of DSPI Provider

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

When one DSPI provider is started (in RFID Management Console, right Click on Provider then Start) the method Init is invoked.

public override void Init(RfidProviderContext providerContext, string providerName, PropertyProfile providerInitParameters)

This method receives the argument providerInitParameters which contains the actual properties of the provider. At this point is very important to know, that this argument contains only properties which administrator has changed. It means only those, which are different than default properties. Because this pattern is a little strange I decided to post how the deal with properties during start up of the provider. Following example shows the full implementation of the initialization method:

public override void Init(RfidProviderContext providerContext, 
string providerName,
PropertyProfile providerInitParameters)
{ m_ProviderPropertyValues = new Dictionary<PropertyKey, object>();
// Obtain default provider's properties.
Dictionary<PropertyKey, RfidProviderPropertyMetadata> providerPropertyMetadata = getDefaultProviderMetadata(); // Here we create the full copy of default properties. foreach (PropertyKey key in providerPropertyMetadata.Keys)
{ // If the value with the current key does not exist // we create the null value. This is the case when this method is called first time. if (providerPropertyMetadata[key] == null) m_ProviderPropertyValues.Add(key, null); // If the value exists, we set it. else m_ProviderPropertyValues.Add(key, providerPropertyMetadata[key].DefaultValue);
}
            // Now we overwirte default values with values, provided by RFID services.
    	    if (providerInitParameters != null)
{
foreach (PropertyKey key2 in providerInitParameters.Keys) {
m_ProviderPropertyValues[key2] = providerInitParameters[key2];
}
}
}


Posted May 06 2007, 01:41 PM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.