Files
DP44/Common/DTS.Common.Serialization/File.cs

114 lines
4.1 KiB
C#
Raw Normal View History

2026-04-17 14:55:32 -04:00
/*
* DTS.Export.File.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
{
/// <summary>
/// Basic representation of a DTS export file.
/// </summary>
public abstract partial class File : Exceptional
{
/// <summary>
/// property controling whether to adjust filtered data by one sample or not
/// this is used by various write methods which in turn call the actual filtered method
/// TDC when it software filters ends up including an extra sample, this preserves that behavior
/// </summary>
public static bool UseLegacyTDCSoftwareFiltering { get; set; } = false;
public int DefaultEncoding { get; set; } = Encoding.UTF8.CodePage;
public Common.Enums.IsoViewMode ISOViewMode { get; set; }
/// <summary>
/// Initialize an instance of the DTS.Export.File class.
/// </summary>
///
/// <param name="formatName">
/// The format name <see cref="string"/> of this file.
/// </param>
///
public File(string formatName)
{
try
{
FormatName = formatName;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Get the string name of this file's format.
/// </summary>
public string FormatName
{
get => _FormatName.Value;
private set => _FormatName.Value = value;
}
private readonly Property<string> _FormatName
= new Property<string>(
typeof(File).Name + ".File.FormatName",
null,
false
);
/// <summary>
/// Get/set the base export directory path <see cref="string"/> for events.
/// </summary>
public static string BaseExportDirectory
{
get => _BaseExportDirectory.Value;
set => _BaseExportDirectory.Value = value;
}
private static readonly Property<string> _BaseExportDirectory
= new Property<string>(
typeof(File).Namespace + ".BaseExportDirectory",
null,
false
);
/// <summary>
/// If the specified path string doesn't end with a backslash, add one.
/// </summary>
///
/// <param name="path">
/// The path <see cref="string"/> to be trailing-backslash checked.
/// </param>
///
/// <returns>
/// The original path <see cref="string"/> if it already ended with a backslash;
/// otherwise, the original path string appended with a backslash.
/// </returns>
///
protected string EnsureTrailingBackslashOnPathString(string path)
{
try
{
return path.EndsWith("\\", StringComparison.OrdinalIgnoreCase) ? path : path + "\\";
}
catch (System.Exception ex)
{
throw new Exception("encountered problem trailing backslash on path string " + (null != path ? "\"" + path + "\"" : "<<NULL>>") + " to valid standard path string", ex);
}
}
private readonly Dictionary<string, FilteredData> _EUUnfilteredDataForLinearizedChannels = new Dictionary<string, FilteredData>();
public virtual void SetEUData(string channelID, FilteredData fd) { _EUUnfilteredDataForLinearizedChannels[channelID] = fd; }
public virtual FilteredData GetEUData(string channelID) { return _EUUnfilteredDataForLinearizedChannels[channelID]; }
public virtual int GetChannelNumberFromChannelFileName(string channelFileName) { return -1; } //19044 overridden in TDAS.File and SliceRaw.File
}
}