Files
DP44/Common/DTS.Common.Serialization/Iso/Iso.File.Test.cs
2026-04-17 14:55:32 -04:00

571 lines
26 KiB
C#

/*
* Iso.File.Test.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
namespace DTS.Serialization.Iso
{
// *** see Iso.File.cs ***
public partial class File
{ ///
/// <summary>
/// ISO-style representation of a test.
/// </summary>
///
public partial class Test : Exceptional
{
/// <summary>
/// Get the data format edition number <see cref="string"/> of the file format generated by this object.
/// </summary>
public string DataFormatEditionNumber
{
get => _DataFormatEditionNumber.Value;
set => _DataFormatEditionNumber.Value = value;
}
public const string DataFormatEditionNumberLabel = "Data format edition number";
private readonly Property<string> _DataFormatEditionNumber
= new Property<string>(
typeof(File).Namespace + ".Iso.File.DataFormatEditionNumber",
"1.6",
true
);
/// <summary>
/// Get/set the laboratory name <see cref="string"/> for this test.
/// </summary>
public string LaboratoryName
{
get => _LaboratoryName.Value;
set => _LaboratoryName.Value = value;
}
private const string LaboratoryNameLabel = "Laboratory name";
private readonly Property<string> _LaboratoryName
= new Property<string>(
typeof(File).Namespace + ".Iso.File.LaboratoryName",
null,
false
);
/// <summary>
/// Get/set the laboratory contact name <see cref="string"/> for this test.
/// </summary>
public string LaboratoryContactName
{
get => _LaboratoryContactName.Value;
set => _LaboratoryContactName.Value = value;
}
private const string LaboratoryContactNameLabel = "Laboratory contact name";
private readonly Property<string> _LaboratoryContactName
= new Property<string>(
typeof(File).Namespace + ".Iso.File.LaboratoryContactName",
null,
false
);
/// <summary>
/// Get/set the laboratory contact phone <see cref="string"/> for this test.
/// </summary>
public string LaboratoryContactPhone
{
get => _LaboratoryContactPhone.Value;
set => _LaboratoryContactPhone.Value = value;
}
private const string LaboratoryContactPhoneLabel = "Laboratory contact phone";
private readonly Property<string> _LaboratoryContactPhone
= new Property<string>(
typeof(File).Namespace + ".Iso.File.LaboratoryContactPhone",
null,
false
);
/// <summary>
/// Get/set the laboratory contact fax <see cref="string"/> for this test.
/// </summary>
public string LaboratoryContactFax
{
get => _LaboratoryContactFax.Value;
set => _LaboratoryContactFax.Value = value;
}
private const string LaboratoryContactFaxLabel = "Laboratory contact fax";
private readonly Property<string> _LaboratoryContactFax
= new Property<string>(
typeof(File).Namespace + ".Iso.File.LaboratoryContactFax",
null,
false
);
/// <summary>
/// Get/set the laboratory contact email <see cref="string"/> for this test.
/// </summary>
public string LaboratoryContactEmail
{
get => _LaboratoryContactEmail.Value;
set => _LaboratoryContactEmail.Value = value;
}
private const string LaboratoryContactEmailLabel = "Laboratory contact email";
private readonly Property<string> _LaboratoryContactEmail
= new Property<string>(
typeof(File).Namespace + ".Iso.File.LaboratoryContactEmail",
null,
false
);
/// <summary>
/// Get/set the laboratory test reference number <see cref="string"/> for this test.
/// </summary>
public string LaboratoryTestReferenceNumber
{
get => _LaboratoryTestReferenceNumber.Value;
set => _LaboratoryTestReferenceNumber.Value = value;
}
private const string LaboratoryTestReferenceNumberLabel = "Laboratory test ref. number";
private readonly Property<string> _LaboratoryTestReferenceNumber
= new Property<string>(
typeof(File).Namespace + ".Iso.File.LaboratoryTestReferenceNumber",
null,
false
);
/// <summary>
/// Get/set the laboratory project reference number <see cref="string"/> for this test.
/// </summary>
public string LaboratoryProjectReferenceNumber
{
get => _LaboratoryProjectReferenceNumber.Value;
set => _LaboratoryProjectReferenceNumber.Value = value;
}
private const string LaboratoryProjectReferenceNumberLabel = ".Laboratory project ref. num"; //The leading "." means it's additional to the standard
private readonly Property<string> _LaboratoryProjectReferenceNumber
= new Property<string>(
typeof(File).Namespace + ".Iso.File.LaboratoryProjectReferenceNumber",
null,
false
);
/// <summary>
/// Get/set the customer name <see cref="string"/> for this test.
/// </summary>
public string CustomerName
{
get => _CustomerName.Value;
set => _CustomerName.Value = value;
}
private const string CustomerNameLabel = "Customer name";
private readonly Property<string> _CustomerName
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerName",
null,
false
);
/// <summary>
/// Get/set the customer test reference number <see cref="string"/> for this test.
/// </summary>
public string CustomerTestReferenceNumber
{
get => _CustomerTestReferenceNumber.Value;
set => _CustomerTestReferenceNumber.Value = value;
}
private const string CustomerTestReferenceNumberLabel = "Customer test ref. number";
private readonly Property<string> _CustomerTestReferenceNumber
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerTestReferenceNumber",
null,
false
);
/// <summary>
/// Get/set the customer project reference number <see cref="string"/> for this test.
/// </summary>
public string CustomerProjectReferenceNumber
{
get => _CustomerProjectReferenceNumber.Value;
set => _CustomerProjectReferenceNumber.Value = value;
}
private const string CustomerProjectReferenceNumberLabel = "Customer project ref. number";
private readonly Property<string> _CustomerProjectReferenceNumber
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerProjectReferenceNumber",
null,
false
);
/// <summary>
/// Get/set customer order number <see cref="string"/> for the current test.
/// </summary>
public string CustomerOrderNumber
{
get => _CustomerOrderNumber.Value;
set => _CustomerOrderNumber.Value = value;
}
private const string CustomerOrderNumberLabel = "Customer order number";
private readonly Property<string> _CustomerOrderNumber
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerOrderNumber",
null,
false
);
/// <summary>
/// Get/set customer cost unit <see cref="string"/> for this test.
/// </summary>
public string CustomerCostUnit
{
get => _CustomerCostUnit.Value;
set => _CustomerCostUnit.Value = value;
}
private const string CustomerCostUnitLabel = "Customer cost unit";
private readonly Property<string> _CustomerCostUnit
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerCostUnit",
null,
false
);
/// <summary>
/// Get/set the Test engineer name <see cref="string"/> for this test.
/// </summary>
public string TestEngineerName
{
get => _TestEngineerName.Value;
set => _TestEngineerName.Value = value;
}
private const string TestEngineerNameLabel = "Customer test engineer name";
private readonly Property<string> _TestEngineerName
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerTestEngineerName",
null,
false
);
/// <summary>
/// Get/set the Test engineer phone <see cref="string"/> for this test.
/// </summary>
public string TestEngineerPhone
{
get => _TestEngineerPhone.Value;
set => _TestEngineerPhone.Value = value;
}
private const string TestEngineerPhoneLabel = "Customer test engineer phone";
private readonly Property<string> _TestEngineerPhone
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerTestEngineerPhone",
null,
false
);
/// <summary>
/// Get/set the Test engineer fax <see cref="string"/> for this test.
/// </summary>
public string TestEngineerFax
{
get => _TestEngineerFax.Value;
set => _TestEngineerFax.Value = value;
}
private const string TestEngineerFaxLabel = "Customer test engineer fax";
private readonly Property<string> _TestEngineerFax
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerTestEngineerFax",
null,
false
);
/// <summary>
/// Get/set the Test engineer email <see cref="string"/> for this test.
/// </summary>
public string TestEngineerEmail
{
get => _TestEngineerEmail.Value;
set => _TestEngineerEmail.Value = value;
}
private const string TestEngineerEmailLabel = "Customer test engineer email";
private readonly Property<string> _TestEngineerEmail
= new Property<string>(
typeof(File).Namespace + ".Iso.File.CustomerTestEngineerEmail",
null,
false
);
/// <summary>
/// Get/set the title <see cref="string"/> for this test.
/// </summary>
public string Title
{
get => _Title.Value;
set => _Title.Value = value;
}
private const string TitleLabel = "Title";
private readonly Property<string> _Title
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Title",
null,
false
);
/// <summary>
/// Get/set the number of media <see cref="string"/> representation for this test.
/// </summary>
public string NumberOfMedia
{
get => _NumberOfMedia.Value;
set => _NumberOfMedia.Value = value;
}
private const string NumberOfMediaLabel = "Medium No./number of media";
private readonly Property<string> _NumberOfMedia
= new Property<string>(
typeof(File).Namespace + ".Iso.File.NumberOfMedia",
"1/1",
true
);
/// <summary>
/// Get/set the timestamp <see cref="string"/> for this test.
/// </summary>
public string Timestamp
{
get => _Timestamp.Value;
set => _Timestamp.Value = value;
}
private const string TimestampLabel = "Timestamp";
private readonly Property<string> _Timestamp
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Timestamp",
// 14967 DateTime stamp not complete in ISO export
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
true
);
/// <summary>
/// Get/set this ISO file test's comment <see cref="string"/>.
/// </summary>
public string TestComment
{
get => _Comments.Value;
set => _Comments.Value = value;
}
protected const string CommentsLabel = "Comments";
private readonly Property<string> _Comments
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Comments",
null,
false
);
/// <summary>
/// Get/set the type <see cref="string"/> for this test.
/// </summary>
public string Type
{
get => _Type.Value;
set => _Type.Value = value;
}
private const string TypeLabel = "Type of the test";
private readonly Property<string> _Type
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Type",
null,
false
);
/// <summary>
/// Get/set the date <see cref="System.DateTime"/> for this test.
/// </summary>
public DateTime Date
{
get => _Date.Value;
set => _Date.Value = value;
}
private const string DateLabel = "Date of the test";
private readonly Property<DateTime> _Date
= new Property<DateTime>(
typeof(File).Namespace + ".Iso.File.Date",
DateTime.Now,
false
);
/// <summary>
/// Get/set the subtype <see cref="string"/> for this test.
/// </summary>
public string Subtype
{
get => _Subtype.Value;
set => _Subtype.Value = value;
}
private const string SubtypeLabel = "Subtype of the test";
private readonly Property<string> _Subtype
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Subtype",
null,
false
);
/// <summary>
/// Get/set the regulation <see cref="string"/> for this test.
/// </summary>
public string Regulation
{
get => _Regulation.Value;
set => _Regulation.Value = value;
}
private const string RegulationLabel = "Regulation";
private readonly Property<string> _Regulation
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Regulation",
null,
false
);
/// <summary>
/// Get/set the <see cref="double"/> reference temperature value for this test.
/// </summary>
public string ReferenceTemperature
{
get => _ReferenceTemperature.Value;
set => _ReferenceTemperature.Value = value;
}
private const string ReferenceTemperatureLabel = "Reference temperature";
private readonly Property<string> _ReferenceTemperature
= new Property<string>(
typeof(File).Namespace + ".Iso.File.ReferenceTemperature",
null,
false
);
// [DefaultValue( "90.0" )] -- all values should have
/// <summary>
/// Get/set the <see cref="double"/> relative air humdity value for this test.
/// </summary>
public string RelativeAirHumidity
{
get => _RelativeAirHumidity.Value;
set => _RelativeAirHumidity.Value = value;
}
private const string RelativeAirHumidityLabel = "Relative air humidity";
private readonly Property<string> _RelativeAirHumidity
= new Property<string>(
typeof(File).Namespace + ".Iso.File.RelativeAirHumidity",
null,
false
);
/// <summary>
/// Get the <see cref="int"/> number of test objects in this test.
/// </summary>
public int NumberOfTestObjects => Objects.Count;
private const string NumberOfTestObjectsLabel = "Number of test objects";
/// <summary>
/// Get/set the <see cref="DTS.Serialization.Iso.File.Test.Object"/>s for this test.
/// </summary>
public List<Object> Objects
{
get => _Objects.Value;
set => _Objects.Value = value;
}
private readonly Property<List<Object>> _Objects
= new Property<List<Object>>(
typeof(File).Namespace + ".Iso.File.Test.Objects",
new List<Object>(),
true
);
/// <summary>
/// Get/set the list of <see cref="DTS.Serialization.Iso.File.Test.Channel"/>s for this test.
/// </summary>
public List<Channel> Channels
{
get => _Channels.Value;
set => _Channels.Value = value;
}
private readonly Property<List<Channel>> _Channels
= new Property<List<Channel>>(
typeof(File).Namespace + ".Iso.File.Channels",
new List<Channel>(),
true
);
/// <summary>
/// Get/set the list of <see cref="ExtraProperty"/>s for this test.
/// </summary>
public List<ExtraProperty> ExtraProperties
{
get => _ExtraProperties.Value;
set => _ExtraProperties.Value = value;
}
private readonly Property<List<ExtraProperty>> _ExtraProperties
= new Property<List<ExtraProperty>>(
typeof(File).Namespace + ".Iso.File.ExtraProperties",
new List<ExtraProperty>(),
true
);
/// <summary>
/// Generate a <see cref="string"/> representation for this instance.
/// </summary>
///
/// <returns>
/// A <see cref="string"/> representation of this instance.
/// </returns>
///
public override string ToString()
{
try
{
var builder = new StringBuilder();
string line = null;
builder.Append(DataFormatEditionNumberLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => DataFormatEditionNumber)) + (null != line ? Eol : ""));
builder.Append(LaboratoryNameLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => LaboratoryName)) + (null != line ? Eol : ""));
builder.Append(LaboratoryContactNameLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => LaboratoryContactName)) + (null != line ? Eol : ""));
builder.Append(LaboratoryContactPhoneLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => LaboratoryContactPhone)) + (null != line ? Eol : ""));
builder.Append(LaboratoryContactFaxLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => LaboratoryContactFax)) + (null != line ? Eol : ""));
builder.Append(LaboratoryContactEmailLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => LaboratoryContactEmail)) + (null != line ? Eol : ""));
builder.Append(LaboratoryTestReferenceNumberLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => LaboratoryTestReferenceNumber)) + (null != line ? Eol : ""));
builder.Append(LaboratoryProjectReferenceNumberLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => LaboratoryProjectReferenceNumber)) + (null != line ? Eol : ""));
builder.Append(CustomerNameLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => CustomerName)) + (null != line ? Eol : ""));
builder.Append(CustomerTestReferenceNumberLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => CustomerTestReferenceNumber)) + (null != line ? Eol : ""));
builder.Append(CustomerProjectReferenceNumberLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => CustomerProjectReferenceNumber)) + (null != line ? Eol : ""));
builder.Append(CustomerOrderNumberLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => CustomerOrderNumber)) + (null != line ? Eol : ""));
builder.Append(CustomerCostUnitLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => CustomerCostUnit)) + (null != line ? Eol : ""));
builder.Append(TestEngineerNameLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => TestEngineerName)) + (null != line ? Eol : ""));
builder.Append(TestEngineerPhoneLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => TestEngineerPhone)) + (null != line ? Eol : ""));
builder.Append(TestEngineerFaxLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => TestEngineerFax)) + (null != line ? Eol : ""));
builder.Append(TestEngineerEmailLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => TestEngineerEmail)) + (null != line ? Eol : ""));
builder.Append(TitleLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Title)) + (null != line ? Eol : ""));
builder.Append(NumberOfMediaLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => NumberOfMedia)) + (null != line ? Eol : ""));
builder.Append(TimestampLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Timestamp)) + (null != line ? Eol : ""));
builder.Append(CommentsLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => TestComment)) + (null != line ? Eol : ""));
builder.Append(TypeLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Type)) + (null != line ? Eol : ""));
builder.Append(ReferenceTemperatureLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => ReferenceTemperature.ToString())) + (null != line ? Eol : ""));
builder.Append(RelativeAirHumidityLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => RelativeAirHumidity.ToString())) + (null != line ? Eol : ""));
builder.Append(DateLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Date.ToString("yyyy-MM-dd"))) + (null != line ? Eol : ""));
builder.Append(RegulationLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Regulation)) + (null != line ? Eol : ""));
builder.Append(SubtypeLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Subtype)) + (null != line ? Eol : ""));
foreach (var exp in ExtraProperties)
{
builder.Append(exp.Key.PadRight(SeparatorOffset) + Separator + (line = exp.Value) + (null != line ? Eol : ""));
}
builder.Append(NumberOfTestObjectsLabel.PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => NumberOfTestObjects.ToString())) + (null != line ? Eol : ""));
return builder.ToString();
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating string representation for " + GetType().FullName, ex);
}
}
}
}
}