#region Disclaimer / License // Copyright (C) 2010, Jackie Ng // http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #endregion using System; using System.Collections.Generic; using System.Text; using OSGeo.MapGuide.MaestroAPI.Schema; using GeoAPI.Geometries; namespace OSGeo.MapGuide.MaestroAPI.Feature { /// /// Base class of all MapGuide property values. Functions as a nullable box type /// around an underlying data type /// public abstract class PropertyValue { /// /// Initializes a new instance of the class. /// protected PropertyValue() { this.IsNull = true; } /// /// Gets or sets a value indicating whether this instance is null. /// /// /// true if this instance is null; otherwise, false. /// public virtual bool IsNull { get; protected set; } /// /// Sets the value to null. /// public virtual void SetNull() { this.IsNull = true; } /// /// Gets the type. /// public abstract PropertyValueType Type { get; } } /// /// Base class of all nullable value type property values. /// /// public abstract class ValueTypePropertyValue : PropertyValue where T : struct { /// /// Initializes a new instance of the class. /// protected ValueTypePropertyValue() : base() { } /// /// Initializes a new instance of the class. /// /// The value. protected ValueTypePropertyValue(T value) : base() { _value = value; } private Nullable _value; /// /// Gets or sets a value indicating whether this instance is null. /// /// /// true if this instance is null; otherwise, false. /// public override bool IsNull { get { return !_value.HasValue; } } /// /// Gets or sets the value. /// /// /// The value. /// public T Value { get { if (IsNull) throw new Exception("Null Value"); //LOCALIZEME return _value.Value; } set { _value = value; } } /// /// Sets the value to null. /// public override void SetNull() { _value = null; } } /// /// Base class of all reference type property values /// /// public abstract class ReferenceTypePropertyValue : PropertyValue where T : class { /// /// Initializes a new instance of the class. /// protected ReferenceTypePropertyValue() : base() { } /// /// Initializes a new instance of the class. /// /// The value. protected ReferenceTypePropertyValue(T value) : base() { _value = value; this.IsNull = false; } private T _value; /// /// Gets or sets the value. /// /// /// The value. /// public T Value { get { if (IsNull) throw new Exception("Null Value"); //LOCALIZEME return _value; } set { _value = value; this.IsNull = (value == null); } } } /// /// Stores byte data /// public class ByteValue : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Byte; } } } /// /// Stores boolean data /// public class BooleanValue : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Boolean; } } } /// /// Stores blob data /// public class BlobValue : ReferenceTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Blob; } } } /// /// Stores clob data /// public class ClobValue : ReferenceTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Clob; } } } /// /// Stores datetime data /// public class DateTimeValue : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.DateTime; } } } /// /// Stores double data /// public class DoubleValue : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Double; } } } /// /// Stores feature data /// public class FeatureValue : ReferenceTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Feature; } } } /// /// Stores geometry data /// public class GeometryValue : ReferenceTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Geometry; } } } /// /// Stores int16 data /// public class Int16Value : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Int16; } } } /// /// Stores int32 data /// public class Int32Value : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Int32; } } } /// /// Stores int64 data /// public class Int64Value : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Int64; } } } /// /// Stores raster data /// public class RasterValue : ReferenceTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Raster; } } } /// /// Stores float data /// public class SingleValue : ValueTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.Single; } } } /// /// Stores string data /// public class StringValue : ReferenceTypePropertyValue { /// /// Gets the type. /// public override PropertyValueType Type { get { return PropertyValueType.String; } } } }