@@ -1314,7 +1314,7 @@ private Device NormalizeDevice(IDevice device)
13141314 var validationResults = new ValidationResult ( false , $ "Invalid Component : \" { genericComponent . Type } \" Not Found") ;
13151315 if ( _configuration . InputValidationLevel > InputValidationLevel . Ignore )
13161316 {
1317- if ( InvalidComponentAdded != null ) InvalidComponentAdded . Invoke ( obj . Uuid , genericComponent , validationResults ) ;
1317+ MulticastIsolation . Raise ( InvalidComponentAdded , h => h ( obj . Uuid , genericComponent , validationResults ) ) ;
13181318
13191319 // Remove Component from Device
13201320 if ( _configuration . InputValidationLevel == InputValidationLevel . Remove ) obj . RemoveComponent ( genericComponent . Id ) ;
@@ -1334,7 +1334,7 @@ private Device NormalizeDevice(IDevice device)
13341334 var validationResults = new ValidationResult ( false , $ "Invalid Composition : \" { genericComposition . Type } \" Not Found") ;
13351335 if ( _configuration . InputValidationLevel > InputValidationLevel . Ignore )
13361336 {
1337- if ( InvalidCompositionAdded != null ) InvalidCompositionAdded . Invoke ( obj . Uuid , genericComposition , validationResults ) ;
1337+ MulticastIsolation . Raise ( InvalidCompositionAdded , h => h ( obj . Uuid , genericComposition , validationResults ) ) ;
13381338
13391339 // Remove Compsition from Device
13401340 if ( _configuration . InputValidationLevel == InputValidationLevel . Remove ) obj . RemoveComposition ( genericComposition . Id ) ;
@@ -1354,7 +1354,7 @@ private Device NormalizeDevice(IDevice device)
13541354 var validationResults = new ValidationResult ( false , $ "Invalid DataItem : \" { genericDataItem . Type } \" Not Found") ;
13551355 if ( _configuration . InputValidationLevel > InputValidationLevel . Ignore )
13561356 {
1357- if ( InvalidDataItemAdded != null ) InvalidDataItemAdded . Invoke ( obj . Uuid , genericDataItem , validationResults ) ;
1357+ MulticastIsolation . Raise ( InvalidDataItemAdded , h => h ( obj . Uuid , genericDataItem , validationResults ) ) ;
13581358
13591359 // Remove DataItem from Device
13601360 if ( _configuration . InputValidationLevel == InputValidationLevel . Remove ) obj . RemoveDataItem ( genericDataItem . Id ) ;
@@ -1522,7 +1522,7 @@ private bool AddDeviceAddedObservation(IDevice device, long timestamp = 0)
15221522 new ObservationValue ( ValueKeys . Result , device . Uuid )
15231523 } ) ;
15241524
1525- ObservationAdded ? . Invoke ( this , observation ) ;
1525+ MulticastIsolation . Raise ( ObservationAdded , this , observation , null ) ;
15261526
15271527 return true ;
15281528 }
@@ -1553,7 +1553,7 @@ private bool AddDeviceChangedObservation(IDevice device, long timestamp = 0)
15531553 new ObservationValue ( ValueKeys . Result , device . Uuid )
15541554 } ) ;
15551555
1556- ObservationAdded ? . Invoke ( this , observation ) ;
1556+ MulticastIsolation . Raise ( ObservationAdded , this , observation , null ) ;
15571557
15581558 return true ;
15591559 }
@@ -1583,7 +1583,7 @@ private bool AddDeviceRemovedObservation(IDevice device, long timestamp = 0)
15831583 new ObservationValue ( ValueKeys . Result , device . Uuid )
15841584 } ) ;
15851585
1586- ObservationAdded ? . Invoke ( this , observation ) ;
1586+ MulticastIsolation . Raise ( ObservationAdded , this , observation , null ) ;
15871587
15881588 return true ;
15891589 }
@@ -1717,7 +1717,7 @@ public IDevice AddDevice(IDevice device, bool initializeDataItems = true)
17171717 _updateInformation = true ;
17181718 }
17191719
1720- DeviceAdded ? . Invoke ( this , obj ) ;
1720+ MulticastIsolation . Raise ( DeviceAdded , this , obj , null ) ;
17211721
17221722 return obj ;
17231723 }
@@ -2124,7 +2124,7 @@ public bool AddObservation(string deviceKey, IObservationInput observationInput,
21242124 {
21252125 if ( observationInput != null )
21262126 {
2127- ObservationReceived ? . Invoke ( this , observationInput ) ;
2127+ MulticastIsolation . Raise ( ObservationReceived , this , observationInput , null ) ;
21282128
21292129 IObservationInput input = new ObservationInput ( ) ;
21302130 input . DeviceKey = deviceKey ;
@@ -2259,16 +2259,17 @@ public bool AddObservation(string deviceKey, IObservationInput observationInput,
22592259 else success = true ; // Return true if no update needed
22602260 }
22612261
2262- if ( ! validationResult . IsValid && InvalidObservationAdded != null )
2262+ if ( ! validationResult . IsValid )
22632263 {
2264- InvalidObservationAdded . Invoke ( deviceUuid , input . DataItemKey , validationResult ) ;
2264+ MulticastIsolation . Raise ( InvalidObservationAdded , h => h ( deviceUuid , input . DataItemKey , validationResult ) ) ;
22652265 }
22662266
22672267 return success ;
22682268 }
2269- else if ( InvalidObservationAdded != null )
2269+ else
22702270 {
2271- InvalidObservationAdded . Invoke ( deviceUuid , input . DataItemKey , new ValidationResult ( false , $ "DataItemKey \" { input . DataItemKey } \" not Found in Device") ) ;
2271+ var missingKeyResult = new ValidationResult ( false , $ "DataItemKey \" { input . DataItemKey } \" not Found in Device") ;
2272+ MulticastIsolation . Raise ( InvalidObservationAdded , h => h ( deviceUuid , input . DataItemKey , missingKeyResult ) ) ;
22722273 }
22732274 }
22742275
@@ -2333,28 +2334,19 @@ protected virtual ulong OnAddObservation(string deviceUuid, IDataItem dataItem,
23332334 /// <inheritdoc />
23342335 public void OnObservationAdded ( IObservation observation )
23352336 {
2336- if ( ObservationAdded != null )
2337- {
2338- ObservationAdded ? . Invoke ( this , observation ) ;
2339- }
2337+ MulticastIsolation . Raise ( ObservationAdded , this , observation , null ) ;
23402338 }
23412339
23422340 /// <inheritdoc />
23432341 public void OnInvalidObservationAdded ( string deviceUuid , string dataItemId , ValidationResult result )
23442342 {
2345- if ( InvalidObservationAdded != null )
2346- {
2347- InvalidObservationAdded ? . Invoke ( deviceUuid , dataItemId , result ) ;
2348- }
2343+ MulticastIsolation . Raise ( InvalidObservationAdded , h => h ( deviceUuid , dataItemId , result ) ) ;
23492344 }
23502345
23512346 /// <inheritdoc />
23522347 public void OnInvalidDeviceAdded ( IDevice device , ValidationResult result )
23532348 {
2354- if ( InvalidDeviceAdded != null )
2355- {
2356- InvalidDeviceAdded ? . Invoke ( device , result ) ;
2357- }
2349+ MulticastIsolation . Raise ( InvalidDeviceAdded , h => h ( device , result ) ) ;
23582350 }
23592351
23602352 #endregion
@@ -2453,16 +2445,16 @@ public bool AddAsset(string deviceKey, IAsset asset, bool? ignoreTimestamp = nul
24532445
24542446 if ( ! validationResults . IsValid && _configuration . InputValidationLevel > InputValidationLevel . Ignore )
24552447 {
2456- if ( InvalidAssetAdded != null ) InvalidAssetAdded . Invoke ( asset , validationResults ) ;
2448+ MulticastIsolation . Raise ( InvalidAssetAdded , h => h ( asset , validationResults ) ) ;
24572449 }
24582450
2459- AssetAdded ? . Invoke ( this , asset ) ;
2451+ MulticastIsolation . Raise ( AssetAdded , this , asset , null ) ;
24602452 return true ;
24612453 }
24622454 }
24632455 else
24642456 {
2465- if ( InvalidAssetAdded != null ) InvalidAssetAdded . Invoke ( asset , validationResults ) ;
2457+ MulticastIsolation . Raise ( InvalidAssetAdded , h => h ( asset , validationResults ) ) ;
24662458 }
24672459 }
24682460 }
0 commit comments