Samples Index

Open all samples in Visual Studio

PostSharp comes with a set of samples that help you getting started with PostSharp. Samples are typically located in the C:\Program Files\PostSharp 1.0\Samples directory. Check you have write access to that directory before trying to build the samples.

We provide the following samples:

Beginner
PostSharp.Samples.XTrace A trace aspect implemented using PostSharp Laos. You can trace execution of methods in your assembly or in a different assembly, and accesses to fields.
PostSharp.Samples.Composition Automatic implementation of interface by object composition. Composition is often referred to as an alternative to multiple inheritance. Based on Laos.
PostSharp.Samples.Transaction A custom attribute that enables transaction boundaries to be defined declaratively. This sample uses the System.Transactions namespace. For VB.NET.
PostSharp.Samples.Cache A demonstration that caching can implemented using a custom attribute and PostSharp Laos. Written in J#.
PostSharp.Samples.DbInvoke "DB-Invoke is to stored procedures what P-Invoke is to unmanaged APIes". This sample gives a proof of concept to this ambitious motto.
PostSharp.Samples.Compact A proof that PostSharp Laos works also with the Compact Framework.
Intermediate
PostSharp.Samples.Explorer A Code Object Model explorer similar to ildasm or Visual Studio's Object Browser, but based on PostSharp and following the low-level CIL object model
PostSharp.Samples.Binding A sample compound aspect, that is, an aspect composed of many sub-aspects. Here we demonstrate how to call an event PropertyChanged automatically... when a property is changed.
PostSharp.Samples.Silverlight A set of three aspects (including NotifyPropertyChanged)... for Silverlight 2.
Advanced
PostSharp.Samples.Trace A simple trace aspect implemented using the low-level code weaver
PostSharp.Samples.Host Demonstrates how to weave assemblies at runtime.
PostSharp.Samples.Librarian Is a complete layered business application that illustrates the use of PostSharp Laos in real-world situation.