Migrating .NET Clients

Contents

General Changes

StreamBase 5.0 introduced a new version of the .NET API for building .NET StreamBase clients. The new API has the following features:

  • The .NET client API now uses the Microsoft .NET Framework 2.0.

  • The .NET API is no longer dependent on the Java runtime.

  • StreamBase 5.0 and later requires Microsoft Visual Studio 2005 or later to build .NET StreamBase clients.

StreamBase 5.1 restored the StreamBase Monitor API (StreamBase.SB.Monitor.* classes) to the .NET API.

Build Changes

To migrate a pre-5.0 .NET client application to the StreamBase 5.0 .NET API, you must recompile it using Visual Studio 2005 or later, and make the following changes to your code:

  • Remove your application's reference to the netrt.dll assembly, which is no longer necessary.

  • Remove all using statements for the following namespaces:

    • StreamBase.SB.Lang

    • StreamBase.SB.Monitor

    • StreamBase.SB.Util

    • CodeMesh.JuggerNET

  • Examine your code for changes in the API, as described in the next section.

API Changes

The API changes described in this section may require you to modify your existing .NET code.

  • The StringArray collection has been removed. Use System.Collection.Specialized.StringCollection instead.

  • The StreamPropertiesArray collection has been removed. Use a simple StreamProperties[] array instead.

  • The FieldArray collection has been removed. Use a simple Schema.Field[] array instead.

  • The DataTypeArray collection has been removed. Use a simple DataType[] array instead.

  • StreamBase.SB.Schema constructors no longer have a hasHeader boolean. All created Schemas have headers.

  • DataType.AllTypes() now returns a System.Collections.ObjectModel.ReadOnlyCollection<DataType> object.

The following APIs have been removed:

  • StreamBaseClient.CanDequeue()

  • Schema.HasHeader()

  • Schema.GetHeaderSize()

  • Schema.GetNullMaskSize()

  • Schema.GetNullMaskOffset()

  • Schema.GetPaddedSize()

  • Schema.GetUnpaddedSize()

  • Schema.GetMaxPackedSize()

  • Schema.Field.GetRepSize()

DequeueResult no longer has an Iterator() method, but instead now implements System.Collections.IEnumerable. To enumerate Tuples in the DequeueResult, use a foreach loop, like the following example.

DequeueResult dr = myStreamBaseClient.Dequeue();
foreach (Tuple tuple in dr)
(...)

You can also call DequeueResult.GetEnumerator() to access the IEnumerator and iterate through it manually.

You can also access the tuples in a DequeueResult using its default indexed property, as shown in this example

DequeueResult dr = myStreamBaseClient.Dequeue();
for (int i = 0; i < dr.GetTupleCount(); i++)
{
  Tuple tuple = dr[i];
  (...)
}

The DequeueResult.ReuseTuple() method is no longer needed. It has been deprecated and has no effect.

The Timestamp class has been revamped to make use of System.DataTime and System.Data.SqlTypes.SqlDateTime instead of StreamBase.SB.Util.Date and StreamBase.SB.Sql.Date. Consequently, the following methods have changed:

  • public Timestamp(StreamBase.SB.Util.Date) is changed to

    public Timestamp(System.DateTime)
    
  • public StreamBase.SB.Util.Date ToDate() is changed to

    public System.DateTime ToDateTime()
    
  • public StreamBase.SB.Sql.Date ToSQLDate() is changed to

    public System.Data.SqlTypes.SqlDateTime ToSqlDateTime()
    

Two new methods have been added to leverage the System.TimeSpan class. You can construct a Timestamp of type Timestamp.INTERVAL using the following constructor:

public Timestamp(System.TimeSpan)

You can also convert an INTERVAL-type Timestamp into a TimeSpan using the following method:

public System.TimeSpan ToTimeSpan()

The StreamBaseURI constructors that used to take a StreamBase.SB.Util.Map now take a System.Collections.Specialized.StringDictionary.