Skip to content

Commit e956b17

Browse files
committed
bugfix #57
1 parent 643471c commit e956b17

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

libEDSsharp/CanOpenNodeExporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,9 @@ string formatvaluewithdatatype(string defaultvalue, DataType dt, bool fixstring=
11661166
defaultvalue = "0";
11671167
}
11681168

1169-
if (defaultvalue.Contains("$NODEID"))
1169+
if (defaultvalue.Contains("$NODEID", StringComparison.OrdinalIgnoreCase)) // fetch different case of "NODeID" (allowed according DS301)
11701170
{
1171-
defaultvalue = defaultvalue.Replace("$NODEID", "");
1171+
defaultvalue = defaultvalue.ToUpper().Replace("$NODEID", "");
11721172
defaultvalue = defaultvalue.Replace("+", "");
11731173
defaultvalue = defaultvalue.Trim();
11741174
nodeidreplace = true;

libEDSsharp/CanOpenNodeExporter_V4.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,11 +735,11 @@ private DataProperties Get_dataProperties(DataType dataType, string defaultvalue
735735
valueDefined = false;
736736
else if (dataType != DataType.VISIBLE_STRING && dataType != DataType.UNICODE_STRING && dataType != DataType.OCTET_STRING)
737737
{
738-
defaultvalue = defaultvalue.Trim().ToUpper(); // TOUPPER to fetch different case of "NODeID" (allowed acording DS301)
738+
defaultvalue = defaultvalue.Trim();
739739

740-
if (defaultvalue.Contains("$NODEID"))
740+
if (defaultvalue.Contains("$NODEID",StringComparison.OrdinalIgnoreCase)) // fetch different case of "NODeID" (allowed according DS301)
741741
{
742-
defaultvalue = defaultvalue.Replace("$NODEID", "");
742+
defaultvalue = defaultvalue.ToUpper().Replace("$NODEID", "");
743743
defaultvalue = defaultvalue.Replace("+", "");
744744
defaultvalue = defaultvalue.Trim();
745745
if (defaultvalue == "")

libEDSsharp/extensions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,20 @@ public static string ToHexString(this UInt32 val)
2424
}
2525

2626
}
27+
28+
public static class StringExtensions
29+
{
30+
public static bool Contains(this String str, String substring,
31+
StringComparison comp)
32+
{
33+
if (substring == null)
34+
throw new ArgumentNullException("substring",
35+
"substring cannot be null.");
36+
else if (!Enum.IsDefined(typeof(StringComparison), comp))
37+
throw new ArgumentException("comp is not a member of StringComparison",
38+
"comp");
39+
40+
return str.IndexOf(substring, comp) >= 0;
41+
}
42+
}
2743
}

0 commit comments

Comments
 (0)