private void ExtractSystemProfiles() { var namespaceName = GetType().Namespace + ".Profiles.Xml."; var systemProfilesPath = SystemProfilesPath; foreach (var name in _assemblyInfo.GetManifestResourceNames(GetType()) .Where(i => i.StartsWith(namespaceName)) .ToList()) { var filename = Path.GetFileName(name).Substring(namespaceName.Length); var path = Path.Combine(systemProfilesPath, filename); using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), name)) { var fileInfo = _fileSystem.GetFileInfo(path); if (!fileInfo.Exists || fileInfo.Length != stream.Length) { _fileSystem.CreateDirectory(systemProfilesPath); using (var fileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { stream.CopyTo(fileStream); } } } } // Not necessary, but just to make it easy to find _fileSystem.CreateDirectory(UserProfilesPath); }
/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public Task <object> Get(GetDashboardConfigurationPage request) { IPlugin plugin = null; Stream stream = null; var page = ServerEntryPoint.Instance.PluginConfigurationPages.FirstOrDefault(p => string.Equals(p.Name, request.Name, StringComparison.OrdinalIgnoreCase)); if (page != null) { plugin = page.Plugin; stream = page.GetHtmlStream(); } if (plugin == null) { var altPage = GetPluginPages().FirstOrDefault(p => string.Equals(p.Item1.Name, request.Name, StringComparison.OrdinalIgnoreCase)); if (altPage != null) { plugin = altPage.Item2; stream = _assemblyInfo.GetManifestResourceStream(plugin.GetType(), altPage.Item1.EmbeddedResourcePath); } } if (plugin != null && stream != null) { return(_resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator(DashboardUIPath).ModifyHtml("dummy.html", stream, null, _appHost.ApplicationVersion.ToString(), null))); } throw new ResourceNotFoundException(); }
private void ExtractAll() { var type = GetType(); var resourcePath = type.Namespace + ".Ratings."; var localizationPath = LocalizationPath; _fileSystem.CreateDirectory(localizationPath); var existingFiles = GetRatingsFiles(localizationPath) .Select(Path.GetFileName) .ToList(); // Extract from the assembly foreach (var resource in _assemblyInfo .GetManifestResourceNames(type) .Where(i => i.StartsWith(resourcePath))) { var filename = "ratings-" + resource.Substring(resourcePath.Length); if (!existingFiles.Contains(filename)) { using (var stream = _assemblyInfo.GetManifestResourceStream(type, resource)) { var target = Path.Combine(localizationPath, filename); _logger.LogInformation("Extracting ratings to {0}", target); using (var fs = _fileSystem.GetFileStream(target, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { stream.CopyTo(fs); } } } } foreach (var file in GetRatingsFiles(localizationPath)) { LoadRatings(file); } LoadAdditionalRatings(); }
private Task <DynamicImageResponse> GetImage(ImageType type, string imageFormat) { var path = String.Format("{0}.Images.{1}.{2}", GetType().Namespace, type, imageFormat); return(Task.FromResult(new DynamicImageResponse { Format = ImageFormat.Jpg, HasImage = true, Stream = _assemblyInfo.GetManifestResourceStream(GetType(), path) })); }
public Task <DynamicImageResponse> GetChannelImage(ImageType type, CancellationToken cancellationToken) { switch (type) { case ImageType.Thumb: case ImageType.Backdrop: { var path = GetType().Namespace + ".Images." + type.ToString().ToLower() + ".png"; return(Task.FromResult(new DynamicImageResponse { Format = ImageFormat.Png, HasImage = true, Stream = _assemblyInfo.GetManifestResourceStream(GetType(), path) })); } default: throw new ArgumentException("Unsupported image type: " + type); } }