SanSYS

Untitled

Mar 11th, 2015
8,431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. internal static object CreateInstanceFromVirtualPath(
  2.                         VirtualPath virtualPath,
  3.                         Type requiredBaseType,
  4.                         HttpContext context,
  5.                         bool allowCrossApp
  6.                     )
  7. {
  8.     ITypedWebObjectFactory objectFactory = GetVirtualPathObjectFactory(virtualPath, context, allowCrossApp);
  9.     if (objectFactory == null) return null;
  10.  
  11.     // Make sure it has the required base type (VSWhidbey 516771)
  12.     Util.CheckAssignableType(requiredBaseType, objectFactory.InstantiatedType);
  13.  
  14.     // impersonate client while executing page ctor (see ASURT 89712)
  15.     // (compilation is done while not impersonating client)
  16.  
  17.     Object instance;
  18.     using (new ClientImpersonationContext(context))
  19.     {
  20.         instance = objectFactory.CreateInstance();
  21.     }
  22.  
  23.     return instance;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment