尝试使用VB .net中的postSharp librarry为我的Aspect设置我的属性。我该怎么办?
这是我的看点:
<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 :(得分:0)
设置属性的属性值时,您需要使用:=
运算符。
<MyAspect(CurrentTool:="LOGIN")>
Private Sub CallTologInFeature()
...
End Sub