USER-DEFINED TYPES AND AGGREGATES we will see later. In addition, classes that do not implement IBinary Serialize that is, those that set Format to Native in the SqlUser DefinedTypeAttribute can also take advantage of the smaller byte stream on disk. Since the units field can hold either a null or a reference to a string, an LDim class can put a null in the units field to indicate that it is representing a null. Note that encoding a representation like this has been used many times before. For example, a floating point number that is infinity or NaN just uses an encoding that can never occur when it is representing an actual number. Listing 5-6 shows the LDim implementation of INullable that uses this encoding technique. Listing 5-6: Encoded Implementation of INullable public struct LDim : INullable { private double value; private string units; // read only property public bool IsNull { get { return units == null;} } // rest of implementation } Implementing the Null Property LDimmust implement a public, static property named Nullthat returns an instance of LDim that represents a null. To do this, LDim can just return a new instance of the LDimclass. Listing 5-7 shows the LDimimplementation of the Nullproperty. Listing 5-7: Implementation of the Null Property public struct LDim : INullable { public static LDim Null { get{ return new LDim();} } // rest of implementation } This implementation is simple because LDim is a struct that is, it derives from System.ValueType. A new instance of a ValueType is

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

Bookmark the permalink.

Comments are closed.