private IImage LoadImageFromUrl(string url, ImageType type = ImageType.BookCover, string mediaType = "image/jpeg") { if (string.IsNullOrWhiteSpace(url)) { return(null); } var name = Guid.NewGuid().ToString(); var bytes = _client.GetImage(url); var image = _session.NewImage(name, type, mediaType, bytes); return(image); }
private static IImage LoadImageFromResource(IEntitySession session, string name, ImageType type = ImageType.BookCover, string mediaType = "image/jpeg") { const int MaxImageSize = 100 * 1024; var fileName = "Vita.Samples.BookStore.SampleData.Generate.Images." + name; var thisAsm = typeof(SampleDataGenerator).Assembly; var stream = thisAsm.GetManifestResourceStream(fileName); var reader = new System.IO.BinaryReader(stream); var bytes = reader.ReadBytes(MaxImageSize); var image = session.NewImage(name, type, mediaType, bytes); return(image); }
private static IImage LoadImageFromResource(IEntitySession session, string name, ImageType type = ImageType.BookCover, string mediaType = "image/jpeg") { const int MaxImageSize = 100 * 1024; var fileName = "Vita.Samples.BookStore.SampleData.Generate.Images." + name; var thisAsm = typeof(SampleDataGenerator).Assembly; var stream = thisAsm.GetManifestResourceStream(fileName); var reader = new System.IO.BinaryReader(stream); var bytes = reader.ReadBytes(MaxImageSize); var image = session.NewImage(name, type, mediaType, bytes); return image; }