コード例 #1
0
 public RefCountedAppDomain GetAppDomain(SandboxCasPolicySettings casSettings)
 {
     lock (this)
     {
         if (m_lastDispensedAppDomain != null && !IsLastAppDomainReusable(casSettings))
         {
             try
             {
                 m_lastDispensedAppDomain.Dispose();
             }
             finally
             {
                 m_lastDispensedAppDomain = null;
             }
         }
         if (m_lastDispensedAppDomain == null)
         {
             DateTime            now = DateTime.Now;
             RefCountedAppDomain refCountedAppDomain = new RefCountedAppDomain(CreateAppDomain(now, casSettings));
             if (m_areAppDomainsReusable)
             {
                 m_lastDispensedAppDomain            = refCountedAppDomain.CreateNewReference();
                 m_lastAppDomainCreationTime         = now;
                 m_settingsForLastDispensedAppDomain = casSettings.Copy();
             }
             return(refCountedAppDomain);
         }
         return(m_lastDispensedAppDomain.CreateNewReference());
     }
 }