2014-06-12 32 views
1

試圖在VB.net中爲使用postSharp庫創建的方面設置屬性。我該怎麼做?如何在使用PostSharp在VB.NET中調用方面時設置屬性

這是我看點:

<Serializable()> 
Public Class MyAspect 
    Inherits OnMethodBoundaryAspect 

    Public Property CurrentTool As String 

    Public Overrides Sub OnEntry(ByVal eventArgs As PostSharp.Aspects.MethodExecutionArgs) 
     MyBase.OnEntry(eventArgs) 
     eventArgs.MethodExecutionTag = Stopwatch.StartNew() 
    End Sub 

    Public Overrides Sub OnExit(ByVal eventArgs As PostSharp.Aspects.MethodExecutionArgs) 
     MyBase.OnExit(eventArgs) 
     Dim sw As Stopwatch = CType(eventArgs.MethodExecutionTag, Stopwatch) 
     sw.Stop() 

     Log.log("Method: " & eventArgs.Instance.GetType().Name & "." & eventArgs.Method.Name & " - Total time:" + CStr(sw.ElapsedMilliseconds/1000), " seconds.") 

    End Sub 


End Class 

我怎麼叫它我的方法之前,可以指定我CurrentTool財產?因爲這段代碼下面不工作..

<MyAspect(CurrentTool = "LOGIN")> 
Private Sub CallTologInFeature() 
    ... 
End Sub 

回答

0

當設置屬性的屬性值,你需要使用:=運營商。

<MyAspect(CurrentTool:="LOGIN")> 
Private Sub CallTologInFeature() 
... 
End Sub 
+0

它的工作原理!非常感謝! – Dom

相關問題