public static string GetInstallDirectory(MPExtendedProduct product) { if (GetFileLayoutType() != FileLayoutType.Installed) { throw new InvalidOperationException("Install directory not available for source installations"); } // If possible, try to read it from the registry, where the install location is set during installation. RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\MPExtended"); if (key != null) { object value = key.GetValue(String.Format("{0}InstallLocation", Enum.GetName(typeof(MPExtendedProduct), product))); if (value != null) { return(value.ToString()); } } // Fallback to dynamic detection based upon the default install location of the services switch (product) { case MPExtendedProduct.Service: return(Path.GetFullPath(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))); case MPExtendedProduct.WebMediaPortal: DirectoryInfo webmpinfo = new DirectoryInfo(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); return(webmpinfo.Parent.FullName); default: throw new ArgumentException(); } }
public ConfigurationList(MPExtendedProduct product) : base() { this[ConfigurationFile.Authentication] = new ConfigurationSerializer <Authentication, AuthenticationSerializer, AuthenticationUpgrader>(ConfigurationFile.Authentication, "Authentication.xml", "Services.xml"); if (product == MPExtendedProduct.Service || product == MPExtendedProduct.Configurator) { this[ConfigurationFile.MediaAccess] = new ConfigurationSerializer <MediaAccess, MediaAccessSerializer, MediaAccessUpgrader>(ConfigurationFile.MediaAccess, "MediaAccess.xml"); this[ConfigurationFile.Services] = new ConfigurationSerializer <Services, ServicesSerializer, ServicesUpgrader>(ConfigurationFile.Services, "Services.xml"); this[ConfigurationFile.Streaming] = new ConfigurationSerializer <Streaming, StreamingSerializer, StreamingUpgrader>(ConfigurationFile.Streaming, "Streaming.xml"); this[ConfigurationFile.StreamingProfiles] = new ProfilesConfigurationSerializer(); this[ConfigurationFile.Scraper] = new ConfigurationSerializer <Scraper, ScraperSerializer>(ConfigurationFile.Scraper, "Scraper.xml"); } if (product == MPExtendedProduct.WebMediaPortal) { this[ConfigurationFile.StreamingPlatforms] = new ConfigurationSerializer <StreamingPlatforms, StreamingPlatformsSerializer>(ConfigurationFile.StreamingPlatforms, "StreamingPlatforms.xml"); } if (product == MPExtendedProduct.WebMediaPortal || product == MPExtendedProduct.Configurator) { this[ConfigurationFile.WebMediaPortalHosting] = new ConfigurationSerializer <WebMediaPortalHosting, WebMediaPortalHostingSerializer, WebMediaPortalHostingUpgrader>(ConfigurationFile.WebMediaPortalHosting, "WebMediaPortalHosting.xml"); this[ConfigurationFile.WebMediaPortal] = new ConfigurationSerializer <WebMediaPortal, WebMediaPortalSerializer>(ConfigurationFile.WebMediaPortal, "WebMediaPortal.xml"); } }
public static InstallationProperties DetectForProduct(MPExtendedProduct product) { var prop = DetectForProductAuto(product); prop.Product = product; prop.CacheDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MPExtended", "Cache"); prop.LogDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MPExtended", "Logs"); return(prop); }
private static InstallationProperties CreateForInstallation(MPExtendedProduct product) { var prop = new InstallationProperties(); prop.FileLayout = FileLayoutType.Installed; prop.InstallationDirectory = GetInstallDirectory(product); prop.DefaultConfigurationDirectory = Path.Combine(prop.InstallationDirectory, "DefaultConfig"); prop.ConfigurationDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MPExtended"); prop.ConfigurationBackupDirectory = Path.Combine(prop.ConfigurationDirectory, "ConfigBackup"); return(prop); }
public static bool IsProductInstalled(MPExtendedProduct product) { if (Properties.FileLayout == FileLayoutType.Source) { return(true); } string keyname = String.Format("{0}InstallLocation", Enum.GetName(typeof(MPExtendedProduct), product)); object regLocation = RegistryReader.ReadKeyAllViews(RegistryHive.LocalMachine, @"Software\MPExtended", keyname); return(regLocation != null); }
private static string GetInstallDirectory(MPExtendedProduct product) { // If possible, try to read it from the registry, where the install location is set during installation. string keyname = String.Format("{0}InstallLocation", Enum.GetName(typeof(MPExtendedProduct), product)); object regLocation = RegistryReader.ReadKeyAllViews(RegistryHive.LocalMachine, @"Software\MPExtended", keyname); if (regLocation != null) { return(regLocation.ToString()); } // try default installation location string location = null; switch (product) { case MPExtendedProduct.Service: case MPExtendedProduct.Configurator: location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "MPExtended", "Service"); break; case MPExtendedProduct.WebMediaPortal: location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "MPExtended", "WebMediaPortal"); break; } if (Directory.Exists(location)) { return(location); } // Fallback to dynamic detection based upon the current execution location switch (product) { case MPExtendedProduct.Service: case MPExtendedProduct.Configurator: return(Path.GetFullPath(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))); case MPExtendedProduct.WebMediaPortal: DirectoryInfo currentDir = new DirectoryInfo(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); // If we're executing from the WebMP context, we're inside the WebMediaPortal/www/bin directory, but if we're executing from the // host service context, we're directly inside the WebMediaPortal folder. return(currentDir.FullName.Contains(@"\www\") ? currentDir.Parent.Parent.FullName : currentDir.FullName); default: throw new ArgumentException(); } }
private static InstallationProperties DetectForProductAuto(MPExtendedProduct product) { // Source distributions are recognized by a GlobalVersion.cs file in one of our parent directories. In that // case, immediately build the properties for a source type. If we can't find the file, assume we are installed. // This depends on people not putting a GlobalVersion.cs in a parent directory of the installation. string binDir = AppDomain.CurrentDomain.BaseDirectory; DirectoryInfo info = new DirectoryInfo(binDir); do { if (File.Exists(Path.Combine(info.FullName, "GlobalVersion.cs"))) { return(CreateForSource()); } info = info.Parent; } while (info != null); return(CreateForInstallation(product)); }
public static void Load(MPExtendedProduct product) { Properties = InstallationProperties.DetectForProduct(product); }
public static bool IsProductInstalled(MPExtendedProduct product) { if (Properties.FileLayout == FileLayoutType.Source) return true; string keyname = String.Format("{0}InstallLocation", Enum.GetName(typeof(MPExtendedProduct), product)); object regLocation = RegistryReader.ReadKeyAllViews(RegistryHive.LocalMachine, @"Software\MPExtended", keyname); return regLocation != null; }
private static InstallationProperties CreateForInstallation(MPExtendedProduct product) { var prop = new InstallationProperties(); prop.FileLayout = FileLayoutType.Installed; prop.InstallationDirectory = GetInstallDirectory(product); prop.DefaultConfigurationDirectory = Path.Combine(prop.InstallationDirectory, "DefaultConfig"); prop.ConfigurationDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MPExtended"); prop.ConfigurationBackupDirectory = Path.Combine(prop.ConfigurationDirectory, "ConfigBackup"); return prop; }
public static InstallationProperties DetectForProduct(MPExtendedProduct product) { var prop = DetectForProductAuto(product); prop.Product = product; prop.CacheDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MPExtended", "Cache"); prop.LogDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MPExtended", "Logs"); return prop; }
private static string GetInstallDirectory(MPExtendedProduct product) { // If possible, try to read it from the registry, where the install location is set during installation. string keyname = String.Format("{0}InstallLocation", Enum.GetName(typeof(MPExtendedProduct), product)); object regLocation = RegistryReader.ReadKeyAllViews(RegistryHive.LocalMachine, @"Software\MPExtended", keyname); if (regLocation != null) { return regLocation.ToString(); } // try default installation location string location = null; switch (product) { case MPExtendedProduct.Service: location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "MPExtended", "Service"); break; case MPExtendedProduct.WebMediaPortal: location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "MPExtended", "WebMediaPortal"); break; } if (Directory.Exists(location)) { return location; } // Fallback to dynamic detection based upon the current execution location switch(product) { case MPExtendedProduct.Service: return Path.GetFullPath(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); case MPExtendedProduct.WebMediaPortal: DirectoryInfo webmpinfo = new DirectoryInfo(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); return webmpinfo.Parent.Parent.FullName; default: throw new ArgumentException(); } }
private static InstallationProperties DetectForProductAuto(MPExtendedProduct product) { // Source distributions are recognized by a GlobalVersion.cs file in one of our parent directories. In that // case, immediately build the properties for a source type. If we can't find the file, assume we are installed. // This depends on people not putting a GlobalVersion.cs in a parent directory of the installation. string binDir = AppDomain.CurrentDomain.BaseDirectory; DirectoryInfo info = new DirectoryInfo(binDir); do { if (File.Exists(Path.Combine(info.FullName, "GlobalVersion.cs"))) return CreateForSource(); info = info.Parent; } while (info != null); return CreateForInstallation(product); }
public static string GetInstallDirectory(MPExtendedProduct product) { if (GetFileLayoutType() != FileLayoutType.Installed) { throw new InvalidOperationException("Install directory not available for source installations"); } // If possible, try to read it from the registry, where the install location is set during installation. RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\MPExtended"); if (key != null) { object value = key.GetValue(String.Format("{0}InstallLocation", Enum.GetName(typeof(MPExtendedProduct), product))); if (value != null) { return value.ToString(); } } // Fallback to dynamic detection based upon the default install location of the services switch(product) { case MPExtendedProduct.Service: return Path.GetFullPath(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); case MPExtendedProduct.WebMediaPortal: DirectoryInfo webmpinfo = new DirectoryInfo(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); return webmpinfo.Parent.FullName; default: throw new ArgumentException(); } }