152 lines
5.1 KiB
C#
152 lines
5.1 KiB
C#
/*
|
|
Test.IntervalSec.cs
|
|
|
|
Copyright © 2008
|
|
Diversified Technical Systems, Inc.
|
|
All Rights Reserved
|
|
*/
|
|
|
|
using System;
|
|
using DTS.Common.Utilities;
|
|
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
|
|
|
namespace DTS.Serialization
|
|
{
|
|
// *** see test.cs ***
|
|
public partial class Test
|
|
{
|
|
/// <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 \"IntervalSec\" object", ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get/set whether or not Begin and End values are automatically rounded.
|
|
/// </summary>
|
|
public bool DoRoundOffValues { get; set; }
|
|
|
|
/// <summary>
|
|
/// Get/set the number of decimal places Begin and End values will automatically be rounded
|
|
/// to if DoRoundOffValues property is true.
|
|
/// </summary>
|
|
public int NumberRoundingDecimalPlaces
|
|
{
|
|
get => _NumberOfRoundingDecimalPlaces.Value;
|
|
set => _NumberOfRoundingDecimalPlaces.Value = value;
|
|
}
|
|
private readonly Property<int> _NumberOfRoundingDecimalPlaces =
|
|
new Property<int>(
|
|
typeof(IntervalSec).Namespace + ".IntervalSec.NumberOfRoundingDecimalPlaces",
|
|
6,
|
|
true
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> begin time of the interval.
|
|
/// </summary>
|
|
public double Begin
|
|
{
|
|
get => DoRoundOffValues ? Math.Round(_Begin.Value, NumberRoundingDecimalPlaces) : _Begin.Value;
|
|
set => _Begin.Value = value;
|
|
}
|
|
private readonly Property<double> _Begin
|
|
= new Property<double>(typeof(IntervalSec).Namespace + ".Test.IntervalSec.Begin", 0, false);
|
|
|
|
/// <summary>
|
|
/// Get/set the <see cref="double"/> end time of the interval.
|
|
/// </summary>
|
|
public double End
|
|
{
|
|
get => DoRoundOffValues ? Math.Round(_End.Value, NumberRoundingDecimalPlaces) : _End.Value;
|
|
set => _End.Value = value;
|
|
}
|
|
private readonly Property<double> _End
|
|
= new Property<double>(typeof(IntervalSec).Namespace + ".Test.IntervalSec.End", 0, false);
|
|
|
|
/// <summary>
|
|
/// Determine whether or not this object and the one specified are equal.
|
|
/// </summary>
|
|
///
|
|
/// <param name="obj">
|
|
/// The <see cref="object"/> to be equality-checked.
|
|
/// </param>
|
|
///
|
|
/// <returns>
|
|
/// <see cref="bool"/> true if the object is equal; 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 checking " + GetType().FullName, 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|