Ejemplo n.º 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());
     }
 }
Ejemplo n.º 2
0
        private AppDomain CreateAppDomain(DateTime timeStamp, SandboxCasPolicySettings casSettings)
        {
            if (m_policyChanged)
            {
                lock (this)
                {
                    m_policyChanged = false;
                }
            }
            string appDomainName = "Local Processing " + timeStamp.ToString(CultureInfo.InvariantCulture);

            return(m_policyManager.CreateAppDomainWithPolicy(appDomainName, m_evidence, m_setupInfo, casSettings));
        }
Ejemplo n.º 3
0
        private bool IsLastAppDomainReusable(SandboxCasPolicySettings casSettings)
        {
            if (m_policyChanged)
            {
                return(false);
            }
            if (!object.Equals(m_settingsForLastDispensedAppDomain, casSettings))
            {
                return(false);
            }
            TimeSpan t = DateTime.Now - m_lastAppDomainCreationTime;

            if (t < TimeSpan.FromMinutes(1.0))
            {
                return(t >= TimeSpan.FromMinutes(0.0));
            }
            return(false);
        }
Ejemplo n.º 4
0
        public SandboxCasPolicySettings Copy()
        {
            SandboxCasPolicySettings sandboxCasPolicySettings = new SandboxCasPolicySettings();

            if (m_basePermissions != null)
            {
                sandboxCasPolicySettings.m_basePermissions = m_basePermissions.Copy();
            }
            if (m_fullTrustAssemblies != null)
            {
                foreach (StrongName fullTrustAssembly in m_fullTrustAssemblies)
                {
                    sandboxCasPolicySettings.AddFullTrustAssembly(fullTrustAssembly);
                }
                return(sandboxCasPolicySettings);
            }
            return(sandboxCasPolicySettings);
        }
Ejemplo n.º 5
0
        public override bool Equals(object obj)
        {
            SandboxCasPolicySettings sandboxCasPolicySettings = obj as SandboxCasPolicySettings;

            if (sandboxCasPolicySettings == null)
            {
                return(false);
            }
            if (!object.Equals(m_basePermissions, sandboxCasPolicySettings.m_basePermissions))
            {
                return(false);
            }
            if (m_fullTrustAssemblies == null)
            {
                if (sandboxCasPolicySettings.m_fullTrustAssemblies != null)
                {
                    return(false);
                }
            }
            else
            {
                if (sandboxCasPolicySettings.m_fullTrustAssemblies == null)
                {
                    return(false);
                }
                int count = m_fullTrustAssemblies.Count;
                if (count != sandboxCasPolicySettings.m_fullTrustAssemblies.Count)
                {
                    return(false);
                }
                for (int i = 0; i < count; i++)
                {
                    if (!object.Equals(m_fullTrustAssemblies[i], sandboxCasPolicySettings.m_fullTrustAssemblies[i]))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 6
0
 public abstract AppDomain CreateAppDomainWithPolicy(string appDomainName, Evidence evidence, AppDomainSetup setupInfo, SandboxCasPolicySettings casSettings);
Ejemplo n.º 7
0
 public abstract AssemblyLoadContext CreateAssemblyLoadContextWithPolicy(string appDomainName, Evidence evidence, AppDomainSetup setupInfo, SandboxCasPolicySettings casSettings);