155 lines
5.3 KiB
C#
155 lines
5.3 KiB
C#
/*
|
|
Test.IntervalSec.cs
|
|
|
|
Copyright © 2008
|
|
Diversified Technical Systems, Inc.
|
|
All Rights Reserved
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using DTS.Utilities;
|
|
using DTS.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 { return _NumberOfRoundingDecimalPlaces.Value; }
|
|
set { _NumberOfRoundingDecimalPlaces.Value = value; }
|
|
}
|
|
private 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 { return DoRoundOffValues ? Math.Round( _Begin.Value, NumberRoundingDecimalPlaces ) : _Begin.Value; }
|
|
set { _Begin.Value = value; }
|
|
}
|
|
private 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 { return DoRoundOffValues ? Math.Round( _End.Value, NumberRoundingDecimalPlaces ) : _End.Value ; }
|
|
set { _End.Value = value; }
|
|
}
|
|
private 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
|
|
{
|
|
IntervalSec that = obj as IntervalSec;
|
|
return null != obj
|
|
&& this.Begin.Equals( that.Begin )
|
|
&& this.End.Equals( that.End );
|
|
}
|
|
|
|
catch ( System.Exception ex )
|
|
{
|
|
throw new Test.IntervalSec.Exception( "encountered problem equality checking " + this.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 " + this.GetType( ).FullName, ex );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|