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 FWCreativeRendition LoadCreativeRendition(XElement element)
        {
            var result = new FWCreativeRendition();

            result.Id = (string)element.Attribute("creativeRenditionId");
            result.ContentType = (string)element.Attribute("contentType");
            result.WrapperType = (string)element.Attribute("wrapperType");
            result.WrapperUrl = (string)element.Attribute("wrapperUrl");
            result.AdReplicaId = (string)element.Attribute("adReplicaId");
            result.Width = element.GetIntAttribute("width");
            result.Height = element.GetIntAttribute("height");
            result.Preference = (FWPreference)element.GetIntAttribute("preference");
            result.CreativeApi = (FWCreativeApi)Enum.Parse(typeof(FWCreativeApi), (string)element.Attribute("creativeApi"), true);

            var otherAssetsXml = element.Element("otherAsset");
            if (otherAssetsXml != null)
            {
                foreach (var otherAssetXml in otherAssetsXml.Elements("asset"))
                {
                    result.OtherAssets.Add(LoadAsset(otherAssetXml));
                }
            }

            var assetXml = element.Element("asset");
            if (assetXml != null)
            {
                result.Asset = LoadAsset(assetXml);
            }

            var parametersXml = element.Element("parameters");
            if (parametersXml != null)
            {
                foreach (var parameterXml in parametersXml.Elements("parameter"))
                {
                    result.Parameters.Add(LoadParameter(parameterXml));
                }
            }

            return result;
        }