Skip to content

Commit

Permalink
Changed code so that repeating instances of <RightsCountry> and <Righ…
Browse files Browse the repository at this point in the history
…tsTerritory> are taken into account.
  • Loading branch information
jaerith committed May 8, 2019
1 parent c986624 commit 5499153
Showing 1 changed file with 108 additions and 48 deletions.
156 changes: 108 additions & 48 deletions OnixData/Legacy/OnixLegacySalesRights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public partial class OnixLegacySalesRights
{
#region CONSTANTS

private const char CONST_LIST_DELIM = ' ';
public const char CONST_LIST_DELIM = ' ';

public const int CONST_MISSING_NUM_VALUE = -1;

public const int CONST_SR_TYPE_FOR_SALE_WITH_EXCL_RIGHTS = 1;
public const int CONST_SR_TYPE_FOR_SALE_WITH_NONEXCL_RIGHTS = 2;
Expand All @@ -23,23 +25,111 @@ public partial class OnixLegacySalesRights
public OnixLegacySalesRights()
{
salesRightsTypeField = "";
rightsTerritoryField = rightsCountryField = "";
rightsTerritoryList = rightsCountryList = new List<string>();
rightsCountryField = shortRightsCountryField = null;
rightsTerritoryField = shortRightsTerritoryField = null;
rightsTerritoryList = new List<string>();
rightsCountryList = new List<string>();
}

private string salesRightsTypeField;
private string rightsCountryField;

private string[] rightsCountryField;
private string[] shortRightsCountryField;
private List<string> rightsCountryList;
private string rightsTerritoryField;

private string[] rightsTerritoryField;
private string[] shortRightsTerritoryField;
private List<string> rightsTerritoryList;

#region Helpers

public string[] OnixRightsCountryField
{
get
{
string[] asOnixRightsCountryList = new string[0];

if ((this.shortRightsCountryField != null) && (this.shortRightsCountryField.Length > 0))
asOnixRightsCountryList = this.shortRightsCountryField;
else if ((this.rightsCountryField != null) && (this.rightsCountryField.Length > 0))
asOnixRightsCountryList = this.rightsCountryField;

return asOnixRightsCountryList;
}
}

public string[] OnixRightsTerritoryField
{
get
{
string[] asOnixRightsTerritoryList = new string[0];

if ((this.shortRightsTerritoryField != null) && (this.shortRightsTerritoryField.Length > 0))
asOnixRightsTerritoryList = this.shortRightsTerritoryField;
else if ((this.rightsTerritoryField != null) && (this.rightsTerritoryField.Length > 0))
asOnixRightsTerritoryList = this.rightsTerritoryField;

return asOnixRightsTerritoryList;
}
}

public List<string> RightsCountryList
{
get
{
if (this.rightsCountryList.Count() <= 0)
{
if (this.OnixRightsCountryField.Count() > 0)
{
foreach (string sTmpCountryMiniList in this.OnixRightsCountryField)
{
List<string> TmpCountryList = new List<string>();

if (sTmpCountryMiniList.Contains(CONST_LIST_DELIM))
TmpCountryList = new List<string>(sTmpCountryMiniList.Split(CONST_LIST_DELIM));
else
TmpCountryList = new List<string>() { sTmpCountryMiniList };

this.rightsCountryList.AddRange(TmpCountryList);
}
}
}

return this.rightsCountryList;
}
}

public List<string> RightsTerritoryList
{
get
{
if (this.rightsTerritoryList.Count() <= 0)
{
if (this.OnixRightsTerritoryField.Count() > 0)
{
foreach (string sTmpTerritoryMiniList in this.OnixRightsTerritoryField)
{
List<string> TmpTerritoryList = new List<string>();

if (sTmpTerritoryMiniList.Contains(CONST_LIST_DELIM))
TmpTerritoryList = new List<string>(sTmpTerritoryMiniList.Split(CONST_LIST_DELIM));
else
TmpTerritoryList = new List<string>() { sTmpTerritoryMiniList };

this.rightsTerritoryList.AddRange(TmpTerritoryList);
}
}
}

return this.rightsTerritoryList;
}
}

public int SalesRightsTypeNum
{
get
{
int nSRTypeNum = -1;
int nSRTypeNum = CONST_MISSING_NUM_VALUE;

if (!String.IsNullOrEmpty(this.salesRightsTypeField))
Int32.TryParse(this.salesRightsTypeField, out nSRTypeNum);
Expand All @@ -66,7 +156,8 @@ public string SalesRightsType
}

/// <remarks/>
public string RightsCountry
[System.Xml.Serialization.XmlElementAttribute("RightsCountry")]
public string[] RightsCountry
{
get
{
Expand All @@ -75,27 +166,12 @@ public string RightsCountry
set
{
this.rightsCountryField = value;

if (!String.IsNullOrEmpty(this.rightsCountryField))
{
if (this.rightsCountryField.Contains(CONST_LIST_DELIM))
this.rightsCountryList = new List<string>(this.rightsCountryField.Split(CONST_LIST_DELIM));
else
this.rightsCountryList = new List<string>() { this.rightsCountryField };
}
}
}

public List<string> RightsCountryList
{
get
{
return this.rightsCountryList;
}
}

/// <remarks/>
public string RightsTerritory
[System.Xml.Serialization.XmlElementAttribute("RightsTerritory")]
public string[] RightsTerritory
{
get
{
Expand All @@ -104,22 +180,6 @@ public string RightsTerritory
set
{
this.rightsTerritoryField = value;

if (!String.IsNullOrEmpty(this.rightsTerritoryField))
{
if (this.rightsTerritoryField.Contains(CONST_LIST_DELIM))
this.rightsTerritoryList = new List<string>(this.rightsTerritoryField.Split(CONST_LIST_DELIM));
else
this.rightsTerritoryList = new List<string>() { this.rightsTerritoryField };
}
}
}

public List<string> RightsTerritoryList
{
get
{
return this.rightsTerritoryList;
}
}

Expand All @@ -140,29 +200,29 @@ public string b089
}
}

/// <remarks/>
public string b090
[System.Xml.Serialization.XmlElementAttribute("b090")]
public string[] b090
{
get
{
return RightsCountry;
return shortRightsCountryField;
}
set
{
RightsCountry = value;
shortRightsCountryField = value;
}
}

/// <remarks/>
public string b388
[System.Xml.Serialization.XmlElementAttribute("b388")]
public string[] b388
{
get
{
return RightsTerritory;
return shortRightsTerritoryField;
}
set
{
RightsTerritory = value;
shortRightsTerritoryField = value;
}
}

Expand Down

0 comments on commit 5499153

Please sign in to comment.