private static MediaFile CreateMediaFile(FWCreative creative, FWCreativeRendition rendition, FWAsset asset) { Uri uri; if (Uri.TryCreate(asset.Url, UriKind.RelativeOrAbsolute, out uri)) { var mediaFile = new MediaFile(); mediaFile.Value = uri; mediaFile.Width = rendition.Width; mediaFile.Height = rendition.Height; mediaFile.Codec = rendition.ContentType ?? asset.ContentType; mediaFile.Type = asset.MimeType; mediaFile.Id = asset.Id; mediaFile.Bitrate = (long)(asset.Bytes / creative.Duration.GetValueOrDefault(TimeSpan.FromSeconds(30)).TotalSeconds / 1000 * 8); if (rendition.CreativeApi != FWCreativeApi.none) { mediaFile.ApiFramework = rendition.CreativeApi.ToString().ToUpperInvariant(); } return mediaFile; } else return null; }
internal static FWAsset LoadAsset(XElement element) { var result = new FWAsset(); result.Bytes = element.GetIntAttribute("bytes"); result.ContentType = (string)element.Attribute("contentType"); result.Id = (string)element.Attribute("id"); result.Name = (string)element.Attribute("name"); result.Url = (string)element.Attribute("url"); result.MimeType = (string)element.Attribute("mimeType"); result.Content = (string)element.Attribute("content"); return result; }