//------------------------------------------------------------------------------
// <copyright file="CSSqlUserDefinedType.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;


[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.UserDefined,
 IsByteOrdered = true, MaxByteSize = 8000)]
public struct Person : INullable, IBinarySerialize
{
    private SqlString firstName;

    public SqlString FirstName
    {
        get
        {
            if (this.IsNull)
                return SqlString.Null;
            return firstName;
        }
        set
        {
            firstName = value;
        }
    }

    public override string ToString()
    {
        return "ToString()-Methode";
    }

    public bool IsNull
    {
        get
        {
            return false;
        }
    }

    public static Person Null
    {
        get
        {
            Person h = new Person();
            return h;
        }
    }

    public static Person Parse(SqlString s)
    {
        if (s.IsNull)
            return Null;

        Person u = new Person();
        u.firstName = s;
        return u;
    }
    public void Read(System.IO.BinaryReader r)
    {
        firstName = r.ReadString();
    }

    public void Write(System.IO.BinaryWriter w)
    {
        w.Write(firstName.Value);
    }
}