Esempio n. 1
0
        public HostControl GetNewHost(Type rootComponentType, LoaderType loaderType)
        {
            if (loaderType == LoaderType.NoLoader)
            {
                return(GetNewHost(rootComponentType));
            }

            HostSurface   hostSurface = (HostSurface)this.CreateDesignSurface(this.ServiceContainer);
            IDesignerHost host        = (IDesignerHost)hostSurface.GetService(typeof(IDesignerHost));

            switch (loaderType)
            {
            case LoaderType.BasicDesignerLoader:
                BasicHostLoader basicHostLoader = new BasicHostLoader(rootComponentType);
                hostSurface.BeginLoad(basicHostLoader);
                hostSurface.Loader = basicHostLoader;
                break;

            case LoaderType.CodeDomDesignerLoader:
                CodeDomHostLoader codeDomHostLoader = new CodeDomHostLoader();
                hostSurface.BeginLoad(codeDomHostLoader);
                hostSurface.Loader = codeDomHostLoader;
                break;

            default:
                throw new Exception("Loader is not defined: " + loaderType.ToString());
            }

            hostSurface.Initialize();
            return(new HostControl(hostSurface));
        }
Esempio n. 2
0
        public HostControl GetHostFromSourceCode(String strSourceCode)
        {
            HostSurface   hostSurface = (HostSurface)this.CreateDesignSurface(this.ServiceContainer);
            IDesignerHost host        = (IDesignerHost)hostSurface.GetService(typeof(IDesignerHost));

            CodeDomHostLoader codeDomHostLoader = new CodeDomHostLoader();

            codeDomHostLoader.SourceCodeToPasrse = strSourceCode;

            hostSurface.BeginLoad(codeDomHostLoader);
            hostSurface.Loader = codeDomHostLoader;
            hostSurface.Initialize();

            return(new HostControl(hostSurface));
        }