aop-automatic-exception-handling:2004 年的 C# 示例演示了使用 ContextBoundObject 的 AOP

时间:2024-07-25 07:16:43
【文件属性】:

文件名称:aop-automatic-exception-handling:2004 年的 C# 示例演示了使用 ContextBoundObject 的 AOP

文件大小:14KB

文件格式:ZIP

更新时间:2024-07-25 07:16:43

C#

aop-自动异常 我在 2003-2004 年为旧 GotDotNet 站点编写了这个示例。 它演示了一种在 .NET 中使用 ContextBoundObject 类实现面向方面编程 (AOP) 的方法。 此示例创建了一个属性,该属性可应用于 ContextBoundObject 上的方法,该属性将自动执行异常处理,而无需添加 try...catch 块。 [ExceptionMethodContextAttribute(WriteToEventLog = true, SwallowException = false, ExceptionReturnValue = "")] 在上面的例子中,该方法将异常添加到应用程序事件日志中,拦截带有空字符串的返回值,并将异常抛出给调用者。 如果我们不想向调用者抛出异常,我们会将 SwallowException 设置为 true。 查看通过几


【文件预览】:
aop-automatic-exception-handling-master
----Mainform.cs(7KB)
----SampleObj.cs(1KB)
----AssemblyInfo.cs(2KB)
----ExceptionDetail.cs(15KB)
----Mainform.resx(5KB)
----.gitignore(3KB)
----README.md(1KB)
----ContextBoundSample.sln(920B)
----ContextBoundSample.csproj(4KB)
----App.ico(1KB)

网友评论