Programmatic Tipping
Aspects can be added to fields, methods and types programmatically, i.e. using a compiled imperative programming language.
PostSharp Laos uses this approach for Compound Aspects. Here is an example from the Binding Sample:
public override void ProvideAspects(object targetElement, LaosReflectionAspectCollection collection) { // Get the target type. Type targetType = (Type) targetElement; // On the type, add a Composition aspect to implement // the IBindable interface. collection.AddAspect(targetType, new AddBindableInterfaceSubAspect()); // Add a OnMethodBoundaryAspect on each writable non-static property. foreach (PropertyInfo property in targetType.GetProperties()) { if (property.DeclaringType == targetType && property.CanWrite ) { MethodInfo method = property.GetSetMethod(); if (!method.IsStatic) collection.AddAspect(method, new OnPropertySetSubAspect(property.Name, this)); } } }
Programmatic tipping is also by high-level code weavers that assemble aspects from many low-level advices.
