Skip to main content

Posts tagged with 'aop'

Peter Lorimer has built the ASPeKT AOP framework. This episode is sponsored by Uncall.

Show Notes:

Want to be on the next episode? You can! All you need is the willingness to talk about something technical.

Welcome to another "Weekly Concerns". This is a post-a-week series of interesting links, relevant to programming and programmers. You can check out previous Weekly Concerns posts in the archive.

If you have an interesting link that you'd like to see in Weekly Concerns, leave a comment or contact me.

Welcome to another "Weekly Concerns". This is a post-a-week series of interesting links, relevant to programming and programmers. You can check out previous Weekly Concerns posts in the archive.

If you have an interesting link that you'd like to see in Weekly Concerns, leave a comment or contact me.

The Boise .NET User Group was kind enough to invite me to be a presenter. Boise is a bit too far away for me to make it there on a weekday on a small budget, but they were accomodating enough to allow me to present remotely. There were a couple minor technical issues, but mostly it went well. Even though I've done this presentation a lot, Brian cajoled me into talking about INotifyPropertyChanged, which is something I've only done once before during this talk (usually I'm constrained for time, or the group isn't interested in the MVVM pattern).

Brian Lagunas even made a recording of the presentation. The recording started a minute or so late, and it ending a couple minutes too early (the internet in the Boise location went down), but most of it is was recorded with Microsoft Live Meeting (not my favorite remote collaboration tool, but it was adequate). And now, it's on YouTube:

Slides and code are available in the AOP For You and Me GitHub repository.

StructureMap 3 was released recently, and as a regular user of StructureMap, so far I have to say that I'm pleased.

Mainly because not much was really broken, and also because I'm just happy to see a project I use so much continue to get updated.

There are a couple things that are moved around or renamed. In this post, I'll be talking about HTTP request scoping, decoration, and assembly scanning.

HTTP Request Scoping

StructureMap 3 no longer includes anything tied to HttpContext. But don't panic! It's all been moved to another package: StructureMap.Web. The API is a little different as well. Compare and contrast:

Also note that the cleanup (which I typically put in Application_EndRequest in Global.asax.cs) is also a bit different. In StructureMap 2, I would just call ObjectFactory.ReleaseAndDisposeAllHttpScopedObjects();. In StructureMap 3, instead I call HttpContextLifecycle.DisposeAndClearAll();.

Decoration

If you are using the decorator pattern, then you probably often wire it up in your IoC container. In StructureMap 2, you used EnrichWith. In StructureMap 3, you use DecorateWith. I also think, but I'm not 100% sure, that DecorateWith is a little smarter about types as well. which I only noticed in some of my Castle DynamicProxy stuff. Behold:

If you have my book, AOP in .NET, then you'll know that a change to "EnrichWith" is fairly significant to the code examples in that book. But luckily, it's a relatively easy change (or you can just keep using StructureMap 2.x).

Assembly Scanning

Not a big deal here, just note that some of the assembly scanning extensions (specifically TheCallingAssembly, AssembliesFromApplicationBaseDirectory, AssebliesFromPath) have moved to the StructureMap.Graph namespace. No biggy, especially since ReSharper is able to point these things out and add "using StructureMap.Graph" automatically.

Summary

StructureMap 3 is definitely worth a shot. Based on the NuGet numbers so far, it's not being installed en masse just yet. But based on how I use StructureMap, it's practically a no-brainer to make the upgrade. One thing I didn't mention above (because it's not an API change) is that the error messages in StructureMap are now way more useful, and there are other benefits (like performance) that you are essentially getting for free (in terms of the time you'll spend upgrading). The only drawback is that documentation (as always) is lagging, but between the unit tests, Stack Overflow, and just noodling around, I haven't found that to be much of an impediment to an otherwise splendid tool.

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter