using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Xml.Serialization;

[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.Native)]
[XmlSerializerAssemblyAttribute(AssemblyName = 
    "pointclsproj.xmlserializers, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil")]

public struct PointCls : INullable
{
    public int x;
    public int y;

    public override string ToString()
    {
        if (this.IsNull)
            return "null";
        else
            return String.Format("{0}:{1}", x, y);
    }

    public bool IsNull
    {
        get
        {
            // Put your code here
            return m_Null;
        }
    }

    public static PointCls Null
    {
        get
        {
            PointCls h = new PointCls();
            h.m_Null = true;
            return h;
        }
    }

    public static PointCls Parse(SqlString s)
    {
        if (s.IsNull)
            return Null;
        PointCls u = new PointCls();
        string[] strs = s.Value.Split(':');
        u.x = Int32.Parse(strs[0]);
        u.y = Int32.Parse(strs[1]);
        u.m_Null = false;
        return u;
    }

    [SqlMethod(IsMutator=true)]
    public void SetXY(SqlInt32 x, SqlInt32 y)
    {
        this.x = x.Value;
        this.y = y.Value;
    }

    // Private member
    private bool m_Null;
}


