Ejemplo n.º 1
0
        /// <summary>
        /// Executes supplied action within separate application domain.
        /// </summary>
        /// <param name="action">Action to be executed.</param>
        /// <returns>Any object that results from action execution or null if nothing is supposed to be returned.</returns>
        /// <exception cref="ArgumentNullException">Is thrown in case supplied action is null.</exception>
        private static TReturn ExecuteSharePointAction <TReturn>(SharePointAction <TReturn> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            AppDomain domain = null;

            try
            {
                // Create instance of server implementation in a separate application domain for
                // security and isolation purposes.
                Type           type = typeof(HostedSharePointServerImpl);
                AppDomainSetup info = new AppDomainSetup();
                info.ApplicationBase = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
                info.PrivateBinPath  = "bin; bin/debug";
                domain = AppDomain.CreateDomain("WSS30", null, info);

                HostedSharePointServerImpl impl =
                    (HostedSharePointServerImpl)
                    domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);

                // Execute requested action within created application domain.
                return(action(impl));
            }
            finally
            {
                if (domain != null)
                {
                    AppDomain.Unload(domain);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets list of supported languages by this installation of SharePoint.
        /// </summary>
        /// <returns>List of supported languages</returns>
        public int[] GetSupportedLanguages()
        {
            HostedSharePointServerImpl impl = new HostedSharePointServerImpl();

            return(impl.GetSupportedLanguages(LanguagePacksPath));
        }