andrew4582

PreApplicationStartCode

Mar 10th, 2011
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System.ComponentModel;
  2. using System.Web.WebPages.Razor;
  3. using Microsoft.Web.Infrastructure.DynamicModuleHelper;
  4.  
  5. namespace MVCViewScriptLibrary {
  6.  
  7.     /// <summary>
  8.     /// Added to assemblyInfo.cs
  9.     /// [assembly: PreApplicationStartMethod(typeof(MVCViewScriptLibrary.PreApplicationStartCode), "Start")]
  10.     /// </summary>
  11.     [EditorBrowsable(EditorBrowsableState.Never)]
  12.     public static class PreApplicationStartCode {
  13.        
  14.         private static bool _startWasCalled;
  15.  
  16.         public static void Start() {
  17.  
  18.             if (_startWasCalled) {
  19.                 return;
  20.             }
  21.  
  22.             _startWasCalled = true;
  23.            
  24.             //class to call the 'Start' method
  25.             DynamicModuleUtility.RegisterModule(typeof(ViewScriptModule));
  26.            
  27.             //Add namespace of helper class
  28.             WebPageRazorHost.AddGlobalImport(typeof(ViewScriptUrlHelperExtentions).Namespace);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment