/* DTS.Slice.Control.IntervalSec.cs Copyright © 2008 Diversified Technical Systems, Inc. All Rights Reserved */ using DTS.Common.Utilities; using DTS.Common.Utilities.DotNetProgrammingConstructs; namespace DTS.Slice.Control { /// /// Get/set the begin value. /// public class IntervalSec : Exceptional { /// /// Create an instance of the IntervalSec class. /// public IntervalSec() { // // Note that calling the parameterless constructor will leave the begin and // end properties "uninitialized". } // /// /// Create an instance of the IntervalSec class. /// /// /// /// The begin time of this interval. /// /// /// /// The end time of this interval. /// /// public IntervalSec(double begin, double end) { try { Begin = begin; End = end; } catch (System.Exception ex) { throw new Exception( "encountered problem constructing " + GetType().FullName, ex); } } /// /// Get/set the begin time of the interval. /// public double Begin { get => _Begin.Value; set => _Begin.Value = value; } private readonly Property _Begin = new Property( typeof(IntervalSec).Namespace + ".IntervalSec.Begin", 0, false); /// /// Get/set the end time of the interval. /// public double End { get => _End.Value; set => _End.Value = value; } private readonly Property _End = new Property( typeof(IntervalSec).Namespace + ".IntervalSec.End", 0, false); /// /// Method to implicitly convert this type into a DTS.Serialization.Test.IntervalSec. /// /// /// /// The to be converted. /// /// /// /// A equivalent to the speceified interval /// object. /// /// public static implicit operator Serialization.Test.IntervalSec(IntervalSec thisInterval) { try { return new Serialization.Test.IntervalSec(thisInterval.Begin, thisInterval.End); } catch (System.Exception ex) { throw new Exception("encountered problem implicitly converting " + typeof(IntervalSec).FullName + " to " + typeof(Serialization.Test.IntervalSec).FullName, ex); } } /// /// Method to implicitly convert a DTS.Serialization.Test.IntervalSec object into this type. /// /// /// /// The to be converted. /// /// /// /// A equivalent to the specified interval /// object. /// /// public static implicit operator IntervalSec(Serialization.Test.IntervalSec thatInterval) { try { return new IntervalSec(thatInterval.Begin, thatInterval.End); } catch (System.Exception ex) { throw new Exception("encountered problem implicitly converting " + typeof(Serialization.Test.IntervalSec).FullName + " to " + typeof(IntervalSec).FullName, ex); } } /// /// Test the specified object for equality with this object. /// /// /// /// The to be tested for equality. /// /// /// /// true if the specified object has memeberwise equality with /// this object; false otherwise. /// /// public override bool Equals(object obj) { try { var that = obj as IntervalSec; return null != obj && Begin.Equals(that.Begin) && End.Equals(that.End); } catch (System.Exception ex) { throw new Exception("encountered problem equality-testing the object " + (null != obj ? "\"" + obj.ToString() + "\"" : "<>"), ex); } } /// /// Get has code for this object. /// /// /// /// The hash code for this object. /// /// public override int GetHashCode() { try { return base.GetHashCode(); } catch (System.Exception ex) { throw new Exception("encountered problem generating hash code for " + GetType().FullName, ex); } } } }