private string InitializeHostingEnvironment(string destinationPath, string virtualDirectory) { if (string.IsNullOrEmpty(destinationPath)) { throw new NullReferenceException("destinationPath"); } if (!Directory.Exists(destinationPath)) { throw new ArgumentException("The directory '" + destinationPath + "' does not exist.", "destinationPath"); } if (string.IsNullOrEmpty(virtualDirectory)) { virtualDirectory = "/"; } var noneWebContextHostingEnvironment = new NoneWebContextHostingEnvironment(); noneWebContextHostingEnvironment.ApplicationVirtualPath = virtualDirectory;// : virtualDirectory.Insert(0, "/"); noneWebContextHostingEnvironment.ApplicationPhysicalPath = destinationPath; GenericHostingEnvironment.Instance = noneWebContextHostingEnvironment; var fallbackMapPathVPPConfig = new System.Collections.Specialized.NameValueCollection(); fallbackMapPathVPPConfig.Add("physicalPath", AppDomain.CurrentDomain.BaseDirectory); fallbackMapPathVPPConfig.Add("virtualPath", "~/"); VirtualPathNonUnifiedProvider fallbackVPP = new VirtualPathNonUnifiedProvider("fallbackMapPathVPP", fallbackMapPathVPPConfig); GenericHostingEnvironment.Instance.RegisterVirtualPathProvider(fallbackVPP); Global.BaseDirectory = destinationPath; return(virtualDirectory); }
private void InitalizeEPiServer(string webConfigPath) { if (!File.Exists(webConfigPath)) { throw new ArgumentException("The configuration file '" + webConfigPath + "' does not exist", "webConfigPath"); } var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = webConfigPath }; var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); EPiServerFrameworkSection frameworkSection = config.GetSection("episerver.framework") as EPiServerFrameworkSection; EPiServerShellSection shellSection = config.GetSection("episerver.shell") as EPiServerShellSection; foreach (ModuleElement s in shellSection.ProtectedModules) { string resourcePath = s.ResourcePath.Replace("{rootpath}", shellSection.ProtectedModules.RootPath).Replace("{modulename}", s.Name); var fallbackMapPathVPPConfig = new System.Collections.Specialized.NameValueCollection(); fallbackMapPathVPPConfig.Add("physicalPath", AppDomain.CurrentDomain.BaseDirectory); fallbackMapPathVPPConfig.Add("virtualPath", resourcePath); VirtualPathNonUnifiedProvider fallbackVPP = new VirtualPathNonUnifiedProvider("fallbackMapPathVPP", fallbackMapPathVPPConfig); GenericHostingEnvironment.Instance.RegisterVirtualPathProvider(fallbackVPP); } ConfigurationSource.Instance = new FileConfigurationSource(config); EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType.Installer); }
private static void SetupHostingEnvironment(string applicationPath) { var hostingEnvironment = new TestHostingEnvironment { ApplicationVirtualPath = "/", ApplicationPhysicalPath = applicationPath }; GenericHostingEnvironment.Instance = hostingEnvironment; var fallbackMapPathVppConfig = new NameValueCollection { { "physicalPath", AppDomain.CurrentDomain.BaseDirectory }, { "virtualPath", "~/" } }; var fallbackVpp = new VirtualPathNonUnifiedProvider("fallbackMapPathVpp", fallbackMapPathVppConfig); hostingEnvironment.RegisterVirtualPathProvider(fallbackVpp); }
private static void SetupHostingEnvironment(string applicationPath) { var hostingEnvironment = new TestHostingEnvironment { ApplicationVirtualPath = "/", ApplicationPhysicalPath = applicationPath }; GenericHostingEnvironment.Instance = hostingEnvironment; var fallbackMapPathVppConfig = new NameValueCollection { {"physicalPath", AppDomain.CurrentDomain.BaseDirectory}, {"virtualPath", "~/"} }; var fallbackVpp = new VirtualPathNonUnifiedProvider("fallbackMapPathVpp", fallbackMapPathVppConfig); hostingEnvironment.RegisterVirtualPathProvider(fallbackVpp); }
private static string GetImageReplyingFromVpp(IEnumerable <MachineImage> images, string imageType, VirtualPathNonUnifiedProvider vpp) { var imgs = images.Where(i => i.ImageType != null && i.ImageType.Equals(imageType)); foreach (var img in imgs) { var imagVirtualPath = GenerateVppUrl(img, vpp.VirtualPathRoot); if (!string.IsNullOrEmpty(imagVirtualPath) && vpp.FileExists(imagVirtualPath)) { return(imagVirtualPath); } } return(string.Empty); }