Just determine the version that's installed, and put checks in your code to determine whether or not certain functions should be used.
public interface ISapiFunctions
{
public void Function1();
public void Function2();
}
public class SapiBase : ISapiFunctions
{
public virtual void Function1()
{
}
public virtual void Function2()
{
}
}
public class Sapi4 : SapiBase
{
public override void Function1()
{
}
}
public void Sapi5 : SapiBase
{
public override void Function1()
{
}
public override void Function2()
{
}
}
In the code above, if you instantiated the
sapi4
class (because sapi v4 is currently what's installed), it would support the functionality in
Function1
, but NOT the functionality in
Function2
(resulting in the base class' do-nothing copy to be executed). If you instantiate
sapi5
, all functionality would be available because sapi5 can perform the desired task. The end result would be that you could call
Function1
AND
Function2
from the code that instantiates either of the classes without worrying if the currently installed sapi version even supports it.