Skip to content

Commit

Permalink
ISHEvent and ISHBackgroundTask are checked in ishTypeFieldDefinitions…
Browse files Browse the repository at this point in the history
… to see if field information is needed to be added manually.
  • Loading branch information
Arian Taghva Manesh committed Oct 12, 2023
1 parent e114e30 commit 73b2b74
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Source/ISHRemote/Trisoft.ISHRemote/Objects/IshTypeFieldSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,11 @@ internal class IshTypeFieldSetup
/// </summary>
public IshTypeFieldSetup(ILogger logger, string xmlIshFieldSetup)
{
var hasIshEventFieldDefinitions = false;
var hasIshBackgroundTaskFieldDefinitions = false;
_logger = logger;
_ishTypeFieldDefinitions = new SortedDictionary<string, IshTypeFieldDefinition>();
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml(xmlIshFieldSetup);

if (xmlDocument.SelectSingleNode("//ishtypedefinition[@name='ISHEvent']") != null)
hasIshEventFieldDefinitions = true;
if (xmlDocument.SelectSingleNode("//ishtypedefinition[@name='ISHBackgroundTask']") != null)
hasIshBackgroundTaskFieldDefinitions = true;
foreach (XmlNode xmlIshTypeDefinition in xmlDocument.SelectNodes("ishfieldsetup/ishtypedefinition"))
{
var name = xmlIshTypeDefinition.Attributes?.GetNamedItem("name").Value;
Expand All @@ -73,10 +67,12 @@ public IshTypeFieldSetup(ILogger logger, string xmlIshFieldSetup)
_logger.WriteWarning($"IshType '{name}' is not supported");
}
}

if (!hasIshBackgroundTaskFieldDefinitions)

if (_ishTypeFieldDefinitions.Values.SingleOrDefault(ishTypeFieldDefinition =>
ishTypeFieldDefinition.ISHType == Enumerations.ISHType.ISHBackgroundTask) == null)
{ AddIshBackgroundTaskTableFieldSetup(); }
if (!hasIshEventFieldDefinitions)
if (_ishTypeFieldDefinitions.Values.SingleOrDefault(ishTypeFieldDefinition =>
ishTypeFieldDefinition.ISHType == Enumerations.ISHType.ISHEvent) == null)
{ AddIshEventTableFieldSetup(); }
}

Expand Down

0 comments on commit 73b2b74

Please sign in to comment.