Files
spark/src/DataStreamSuite/SharedStreams/StreamFactories/HistoricDataParams.cs
T

61 lines
1.9 KiB
C#

namespace bts.SilverPine;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
public interface IHistoricDataParams {
string? DataType { get; }
string? Venue { get; }
string? Symbol { get; }
DateTime BeginDate { get; }
DateTime EndDate { get; }
TimeSpan? Interval { get; }
string? TsNanosCol { get; }
}
public class HistoricDataParams : IHistoricDataParams {
public string? DataType { get; set; }
public string? Venue { get; set; }
public string? Symbol { get; set; }
public DateTime BeginDate { get; set; }
public DateTime EndDate { get; set; }
public TimeSpan? Interval { get; set; }
public string? TsNanosCol { get; set; }
[MemberNotNull(nameof(DataType), nameof(Venue), nameof(Symbol), nameof(TsNanosCol))]
public HistoricDataParams Validate() {
validateNotNull(DataType);
validateNotNull(Venue);
validateNotNull(Symbol);
validateNotNull(TsNanosCol);
return this;
}
[MemberNotNull(nameof(Interval))]
public HistoricDataParams ValidateInterval() {
validateNotNull(Interval);
return this;
}
static void validateNotNull<T>([NotNull]T arg, [CallerArgumentExpression(nameof(arg))]string argName = "") {
if (arg is null) {
throw new InvalidOperationException($"Invalid HistoricDataParams: {argName} is null");
}
}
}
public static class HistoricDataParamsExtensions {
// public static void Validate(this IHistoricDataParams hdp) {
// validateNotNull(hdp.DataType);
// validateNotNull(hdp.Venue);
// validateNotNull(hdp.Symbol);
// validateNotNull(hdp.TsNanosCol);
// }
// static void validateNotNull<T>([NotNull]T arg, [CallerArgumentExpression(nameof(arg))]string argName = "") {
// if (arg is null) {
// throw new InvalidOperationException($"Invalid HistoricDataParams: {argName} is null");
// }
// }
}