Files

181 lines
5.7 KiB
C#
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
/*
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
{
/// <summary>
/// Get/set the begin value.
/// </summary>
public class IntervalSec : Exceptional
{
/// <summary>
/// Create an instance of the IntervalSec class.
/// </summary>
public IntervalSec()
{ //
// Note that calling the parameterless constructor will leave the begin and
// end properties "uninitialized".
} //
/// <summary>
/// Create an instance of the IntervalSec class.
/// </summary>
///
/// <param name="begin">
/// The <see cref="double"/> begin time of this interval.
/// </param>
///
/// <param name="end">
/// The <see cref="double"/> end time of this interval.
/// </param>
///
public IntervalSec(double begin, double end)
{
try
{
Begin = begin;
End = end;
}
catch (System.Exception ex)
{
throw new Exception(
"encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Get/set the <see cref="double"/> begin time of the interval.
/// </summary>
public double Begin
{
get => _Begin.Value;
set => _Begin.Value = value;
}
private readonly Property<double> _Begin
= new Property<double>(
typeof(IntervalSec).Namespace + ".IntervalSec.Begin", 0, false);
/// <summary>
/// Get/set the <see cref="double"/> end time of the interval.
/// </summary>
public double End
{
get => _End.Value;
set => _End.Value = value;
}
private readonly Property<double> _End
= new Property<double>(
typeof(IntervalSec).Namespace + ".IntervalSec.End", 0, false);
/// <summary>
/// Method to implicitly convert this type into a DTS.Serialization.Test.IntervalSec.
/// </summary>
///
/// <param name="thisInterval">
/// The <see cref="DTS.Slice.Control.IntervalSec"/> to be converted.
/// </param>
///
/// <returns>
/// A <see cref="DTS.Serialization.Test.IntervalSec"/> equivalent to the speceified interval
/// object.
/// </returns>
///
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);
}
}
/// <summary>
/// Method to implicitly convert a DTS.Serialization.Test.IntervalSec object into this type.
/// </summary>
///
/// <param name="thatInterval">
/// The <see cref="DTS.Serialization.Test.IntervalSec"/> to be converted.
/// </param>
///
/// <returns>
/// A <see cref="DTS.Slice.Control.IntervalSec"/> equivalent to the specified interval
/// object.
/// </returns>
///
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);
}
}
/// <summary>
/// Test the specified object for equality with this object.
/// </summary>
///
/// <param name="obj">
/// The <see cref="object"/> to be tested for equality.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the specified object has memeberwise equality with
/// this object; false otherwise.
/// </returns>
///
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() + "\"" : "<<NULL>>"), ex);
}
}
/// <summary>
/// Get has code for this object.
/// </summary>
///
/// <returns>
/// The <see cref="int"/> hash code for this object.
/// </returns>
///
public override int GetHashCode()
{
try
{
return base.GetHashCode();
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating hash code for " + GetType().FullName, ex);
}
}
}
}