在像OperationContext
一個複雜的對象是安全的寫這樣的代碼:檢查空的層次結構中的if語句
if(OperationContext.Current!=null &&
OperationContext.Current.ServiceSecurityContext !=null &&
OperationContext.Current.ServiceSecurityContext.WindowsIdentity !=null)
或者我需要到代碼中分離到三個if
報表?
我的問題是如果OperationContext.Current
爲空我恐怕OperationContext.Current.ServiceSecurityContext
會拋出NullReferenceException
。
什麼是電路評估? –
@ilayzeidman我在我的回答中解釋過。此外,我提供的鏈接將爲您提供您需要了解的一切。 – James