Originally posted by kriz83
View Post
Announcement
Collapse
No announcement yet.
PED named key does not honor case when retried from Feature object
Collapse
X
-
-
Originally posted by racerfern View PostI know nothing about coding in whatever language this is. My "programming" experience dates back to Fortran WAT V. However, I'm enjoying this conversation more than any other on this forum. Thanks for the lessons.
We almost never use exceptions. If there is an exception, than we overlooked something and it is not safe anymore to use the application. Hence, we let the application crash and have it restarted automatically (I work in the medical industry). We do have a high code coverage and automated MTBF tests, so we know crashes take seldom place.
Leave a comment:
-
Originally posted by racerfern View PostI know nothing about coding in whatever language this is. My "programming" experience dates back to Fortran WAT V. However, I'm enjoying this conversation more than any other on this forum. Thanks for the lessons.
The reason been - we just had similar discussion at work....
Leave a comment:
-
I know nothing about coding in whatever language this is. My "programming" experience dates back to Fortran WAT V. However, I'm enjoying this conversation more than any other on this forum. Thanks for the lessons.
Leave a comment:
-
Originally posted by kriz83 View PostI would get rid of all the checks, since at the end we'are doing a catch all anyways :-(
Otherwise:
Code:if ( (obj != null) && (!String.IsNullOrEmpty(key?.trim()) )
And if you have many checks - can you imagine how long the line would be? And debugging this will be a nightmare - how do you find which check fails?
Sorry for drugging this off-topic...
[EDIT] But what I don't get - why there's two try/catch blocks?
Leave a comment:
-
I would get rid of all the checks, since at the end we'are doing a catch all anyways :-(
Otherwise:
Code:if ( (obj != null) && (!String.IsNullOrEmpty(key?.trim()) )
Leave a comment:
-
One note -
Code:If String.IsNullOrEmpty(Key.Trim)
Code:If String.IsNullOrEmpty(Key?.Trim)
Leave a comment:
-
Originally posted by kriz83 View PostNever seen a function with that many different return paths.
Do you believe this looks better?
Leave a comment:
-
Reviving a 5 month old thread? Just fix the issue plz ...
Never seen a function with that many different return paths. This is an absolute drama when debugging an application.
Verstuurd vanaf mijn SM-G965F met Tapatalk
Leave a comment:
-
Can confirm that the HS3 SDK did not support mixed case keys. You can find the source code attached:
Code:Public Function AddNamed(ByVal Key As String, ByVal Obj As Object) As Boolean Try If Key Is Nothing Then Return False If String.IsNullOrEmpty(Key.Trim) Then Return False If Obj Is Nothing Then Return False CheckNamed() SyncLock Ncol.SyncRoot Try If Ncol.ContainsKey(Key.Trim.ToLower) Then Return False SyncLock Ncol.SyncRoot Ncol.Add(Key.Trim.ToLower, Obj) End SyncLock Return True Catch ex As Exception Return False End Try End SyncLock Catch ex As Exception Return False End Try End Function Public Function AddUnNamed(ByVal Obj As Object) As Integer Try If Obj Is Nothing Then Return -1 CheckUnNamed() SyncLock UNcol.SyncRoot Return UNcol.Add(Obj) End SyncLock Catch ex As Exception Return -1 End Try End Function
Will look into ditching this limitation though. I'm updating the documentation to reflect this until we can implement a workaround.
Leave a comment:
-
I am porting a HS3 implementation so I do not think it was the case with HS3.
Leave a comment:
-
PED named key does not honor case when retried from Feature object
A PED entry was made with:
Code:Const PEDKEY As String = "PEDkey" PED.AddNamed(PEDKEY, Join(arrPED, ","))
The feature was updated to contain the PED with:
Code:hs.UpdatePropertyByRef(iTopRef, HomeSeer.PluginSdk.Devices.EProperty.PlugExtraData, PED)
Code:Dim PED As HomeSeer.PluginSdk.Devices.PlugExtraData = hs.GetPropertyByRef(iTopRef, HomeSeer.PluginSdk.Devices.EProperty.PlugExtraData)
Code:?PED.NamedKeys Count = 1 (0): "pedkey" ?PED.ContainsNamed(PEDKEY) False ?PED.ContainsNamed("pedkey") True
Tags: None
Leave a comment: