Skip to content

Commit

Permalink
Merge branch 'main' into braces
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein authored Aug 18, 2024
2 parents f5d0288 + 8bf4222 commit 2ce6549
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 51 deletions.
19 changes: 10 additions & 9 deletions BO4E/BO/Avis.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
using BO4E.COM;
using BO4E.ENUM;
using BO4E.meta;
Expand All @@ -20,37 +21,37 @@ public class Avis : BusinessObject
/// <summary>
/// Eine im Verwendungskontext eindeutige Nummer für das Avis.
/// </summary>
[JsonProperty(PropertyName = "avisNummer", Required = Required.Always)]
[JsonProperty(PropertyName = "avisNummer", Required = Required.Default)]
[JsonPropertyName("avisNummer")]
[NonOfficial(NonOfficialCategory.MISSING)]
[ProtoMember(1000)]
public string AvisNummer { get; set; }
public string? AvisNummer { get; set; }

/// <summary>
/// Gibt den Typ des Avis an.
/// </summary>
/// <see cref="AvisTyp" />
[JsonProperty(PropertyName = "avisTyp", Required = Required.Always)]
[JsonProperty(PropertyName = "avisTyp", Required = Required.Default)]
[JsonPropertyName("avisTyp")]
[ProtoMember(1001)]
public AvisTyp AvisTyp { get; set; }
public AvisTyp? AvisTyp { get; set; }

/// <summary>
/// Avispositionen
/// </summary>
[JsonProperty(PropertyName = "positionen", Required = Required.Always)]
[JsonProperty(PropertyName = "positionen", Required = Required.Default)]
[JsonPropertyName("positionen")]
[NonOfficial(NonOfficialCategory.MISSING)]
[ProtoMember(1002)]
[BoKey]
public List<Avisposition> Positionen { get; set; }
public List<Avisposition>? Positionen { get; set; }

/// <summary>
/// Summenbetrag
/// </summary>
[JsonProperty(PropertyName = "zuZahlen", Required = Required.Always)]
[JsonProperty(PropertyName = "zuZahlen", Required = Required.Default)]
[JsonPropertyName("zuZahlen")]
[NonOfficial(NonOfficialCategory.MISSING)]
[ProtoMember(1003)]
public Betrag ZuZahlen { get; set; }
}
public Betrag? ZuZahlen { get; set; }
}
2 changes: 0 additions & 2 deletions BO4E/BO/Lokationszuordnung.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using BO4E.COM;
using BO4E.ENUM;
using BO4E.meta;
using Newtonsoft.Json;
using ProtoBuf;
Expand Down
3 changes: 1 addition & 2 deletions BO4E/BO/TechnischeRessource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.Json.Serialization;
using BO4E.COM;
Expand Down Expand Up @@ -239,4 +238,4 @@ public class TechnischeRessource : BusinessObject
[JsonPropertyOrder(24)]
[NonOfficial(NonOfficialCategory.CUSTOMER_REQUIREMENTS)]
public string? LokationsbuendelObjektcode { get; set; }
}
}
17 changes: 0 additions & 17 deletions BO4E/BoMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,4 @@ where string.Equals(boName, businessObjectName, StringComparison.CurrentCultureI

//throw new ArgumentException($"No implemented BusinessObject type matches the name '{businessObjectName}'.");
}

/// <summary>
/// Get JSON Scheme for given Business Object type
/// </summary>
/// <param name="businessObjectType">Business Object type (e.g. typeof(BO4E.BO.Messlokation)</param>
/// <returns>A JSON scheme to be used for validation purposes.</returns>
/// <exception cref="ArgumentException">if given type is not derived from BusinessObject</exception>
public static JSchema GetJsonSchemeFor(Type businessObjectType)
{
if (!businessObjectType.IsSubclassOf(typeof(BusinessObject)))
{
throw new ArgumentException($"The given type {businessObjectType} is not derived from BusinessObject.");
}

var bo = Activator.CreateInstance(businessObjectType) as BusinessObject;
return bo.GetJsonScheme();
}
}
1 change: 0 additions & 1 deletion BO4E/COM/Bankverbindung.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using BO4E.ENUM;
using BO4E.meta;
using Newtonsoft.Json;
using ProtoBuf;
Expand Down
1 change: 0 additions & 1 deletion BO4E/COM/MarktpartnerDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using BO4E.BO;
using BO4E.meta;

using Newtonsoft.Json;
Expand Down
4 changes: 2 additions & 2 deletions BO4E/meta/BusinessObjectSerializationBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ static BusinessObjectSerializationBinder()
public static IList<Type> BusinessObjectAndCOMTypes { get; }

/// <inheritdoc cref="ISerializationBinder.BindToType(string, string)" />
public Type BindToType(string assemblyName, string typeName)
public Type BindToType(string? assemblyName, string typeName)
{
return BusinessObjectAndCOMTypes.SingleOrDefault(t => t.Name == typeName);
}

/// <inheritdoc cref="ISerializationBinder.BindToName(Type, out string, out string)" />
public void BindToName(Type serializedType, out string assemblyName, out string typeName)
public void BindToName(Type serializedType, out string? assemblyName, out string typeName)
{
assemblyName = null;
typeName = serializedType.Name;
Expand Down
20 changes: 11 additions & 9 deletions BO4E/meta/CentralEuropeStandardTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ namespace BO4E.meta
/// </summary>
public abstract class CentralEuropeStandardTime
{
private static readonly TimeZoneInfo? _CentralEuropeStandardTimezoneInfo;

/// <summary>
/// Central Europe Standard Time as hard coded default time. Public to be used elsewhere ;)
/// </summary>
public static readonly TimeZoneInfo CentralEuropeStandardTimezoneInfo;
public static TimeZoneInfo CentralEuropeStandardTimezoneInfo
{
get => _CentralEuropeStandardTimezoneInfo!;
}

static CentralEuropeStandardTime()
{
Expand All @@ -26,13 +31,10 @@ static CentralEuropeStandardTime()
{
throw new FileNotFoundException($"The file resource {resourceFileName} was not found.");
}

using (var jsonReader = new StreamReader(stream))
{
var jsonString = jsonReader.ReadToEnd();
//Console.WriteLine(jsonString);
CentralEuropeStandardTimezoneInfo = JsonConvert.DeserializeObject<TimeZoneInfo>(jsonString);
}
using var jsonReader = new StreamReader(stream);
var jsonString = jsonReader.ReadToEnd();
//Console.WriteLine(jsonString);
_CentralEuropeStandardTimezoneInfo = JsonConvert.DeserializeObject<TimeZoneInfo>(jsonString);
}

/// <summary>
Expand All @@ -42,4 +44,4 @@ static CentralEuropeStandardTime()
// ReSharper disable once InconsistentNaming
public static TimeZoneInfo CENTRAL_EUROPE_STANDARD_TIME => CentralEuropeStandardTimezoneInfo;
}
}
}
4 changes: 2 additions & 2 deletions BO4E/meta/MultiLangResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ

// See if there is a [FieldName] attribute applied to the property
// for the requested language
var att = prop.AttributeProvider.GetAttributes(true)
var att = prop.AttributeProvider?.GetAttributes(true)
.OfType<FieldName>()
.FirstOrDefault(a => a.Language == _language);

Expand All @@ -52,4 +52,4 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ
return prop;
}
}
}
}
2 changes: 0 additions & 2 deletions BO4ETestProject/TestZeitraumDeserialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using BO4E.BO;
using BO4E.COM;
using BO4E.ENUM;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
Expand Down
4 changes: 0 additions & 4 deletions TestBO4E.Extensions/TestEnergiemengeExtensionCompleteness.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using BO4E;
using BO4E.BO;
using BO4E.COM;
using BO4E.ENUM;
Expand All @@ -11,9 +10,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;


using System;
using System.Collections.Generic;
using System.IO;
Expand Down

0 comments on commit 2ce6549

Please sign in to comment.