Example #1
0
        internal static T Activate <T>(AddInToken token, AddInSecurityLevel level)
        {
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
            System.Diagnostics.Contracts.Contract.EndContractBlock();

            // the name for the addin makes a good name for the appdomain
            return(Activate <T>(token, level, token.Name));
        }
Example #2
0
        // Creates a new AppDomain with the given security level & the specified friendly name.
        // Then creates an instance of the add-in within that appdomain, handing back the host
        // add-in view.  We'll also have to create an AddInControllerImpl to track & unload this add-in.
        internal static T Activate <T>(AddInToken token, AddInSecurityLevel level, String appDomainName)
        {
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
            if (appDomainName == null)
            {
                throw new ArgumentNullException("appDomainName");
            }
            System.Diagnostics.Contracts.Contract.EndContractBlock();

            PermissionSet permissionSet = GetPermissionSetForLevel(level);

            return(Activate <T>(token, permissionSet, appDomainName));
        }
Example #3
0
        internal static PermissionSet GetPermissionSetForLevel(AddInSecurityLevel level)
        {
            if (AddInSecurityLevel.Internet > level || level > AddInSecurityLevel.Host)
            {
                throw new ArgumentOutOfRangeException("level");
            }
            System.Diagnostics.Contracts.Contract.EndContractBlock();

            if (level == AddInSecurityLevel.Host)
            {
                return(AppDomain.CurrentDomain.PermissionSet);
            }
            else
            {
                // Get a permission set for all non-GAC'ed code within the AD.
                Evidence sandboxEvidence = new Evidence();

                if (level == AddInSecurityLevel.Internet)
                {
                    sandboxEvidence.AddHostEvidence(new Zone(SecurityZone.Internet));
                }
                else if (level == AddInSecurityLevel.Intranet)
                {
                    sandboxEvidence.AddHostEvidence(new Zone(SecurityZone.Intranet));
                }
                else if (level == AddInSecurityLevel.FullTrust)
                {
                    sandboxEvidence.AddHostEvidence(new Zone(SecurityZone.MyComputer));
                }
                else if (level != AddInSecurityLevel.Internet)
                {
                    throw new ArgumentOutOfRangeException("level");
                }


                return(SecurityManager.GetStandardSandbox(sandboxEvidence));
            }
        }
Example #4
0
        internal static T Activate <T>(AddInToken token, AddInProcess process, AddInSecurityLevel level)
        {
            PermissionSet permissionSet = GetPermissionSetForLevel(level);

            return(Activate <T>(token, process, permissionSet));
        }
 public T Activate <T>(AddInProcess process, AddInSecurityLevel level)
 {
     return(AddInActivator.Activate <T>(this, process, level));
 }
 public T Activate <T>(AddInSecurityLevel trustLevel, String appDomainName)
 {
     return(AddInActivator.Activate <T>(this, trustLevel, appDomainName));
 }
 public T Activate <T>(AddInSecurityLevel trustLevel)
 {
     return(AddInActivator.Activate <T>(this, trustLevel));
 }