About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



Writing Object Use to Standard Output

A preponderance of fundamental SharePoint proxy objects implement the IDisposable pattern, and therefore the disposal state of such objects becomes a subject of interest, this is predominantly important when using mock object schemes. Recently, I had to do just this and it's not actually very complicated, but I needed to remember it so decided to post it. While the goal was to make the method analogous to type, the approach can be easily schemed to SharePoint proxy objects, since as you can see it’s a very simple approach.

In the below, the new static extension method TraceUsing in class Extensions is being defined. Since we are going to follow a object, the instance represents type "T" and the Action parameter set to type "T" lets you specify an action to be performed on "T". In my specific case, the parameter supply to Action was just a write to standard output saying that we are currently using an arbitrary object (to an HtmlTextWriter in my case).

C#:
  1. public static class Extensions
  2. {
  3.  
  4. public static void TraceUsing<T>(this T instance, Action<T> action)
  5. {
  6. try
  7. {
  8. action(instance);
  9. }
  10. finally
  11. {
  12. var disp = instance as IDisposable;
  13. if (disp != null)
  14. {
  15. disp.Dispose();
  16. }
  17. }
  18. }
  19. }

  • Share/Bookmark

1 Comment »

  1. [...] Writing Object Use to Standard Output [...]

    Pingback by Links (1/29/2009) « Steve Pietrek - Everything SharePoint — January 29, 2009 @ 7:45 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment