NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Creating a Writer

The following example creates a writer, which is a class that can take data of some type and convert it to a byte array that can be passed to a stream.

public class MyWriter
{
private Stream s;
public MyWriter(Stream stream) {
s = stream;
} // end MyWriter(Stream stream)
public void WriteDouble(double myData) {
byte[] b = myData.GetBytes(); 
// GetBytes is a binary representation of a double data type.
s.Write(b,0,b.Length);
} // end WriteFoo(double myData)
public void Close()
{
s.Close();
}
}

In this scenario, you create a class that has a constructor with a stream argument. From here, you can expose whatever write methods are necessary. You must convert whatever you are writing to a byte[]. After obtaining the byte[] b, it is written to the stream s by the Write method.