BlogEngine.Core.SyndicationGenerator.GetMediaEnclosure C# (CSharp) Méthode

GetMediaEnclosure() private static méthode

Gets enclosure for supported media type
private static GetMediaEnclosure ( IPublishable publishable, string content, string media, string mediatype ) : string
publishable IPublishable
content string The content.
media string The media.
mediatype string The mediatype.
Résultat string
        private static string GetMediaEnclosure(IPublishable publishable, string content, string media, string mediatype)
        {
            const string RegexLink = @"<a href=((.|\n)*?)>((.|\n)*?)</a>";
            var enclosure = "<enclosure url=\"{0}\" length=\"{1}\" type=\"{2}\" />";
            var matches = Regex.Matches(content, RegexLink);

            if (matches.Count > 0)
            {
                string filename;

                foreach (var match in matches.Cast<Match>().Where(match => match.Value.Contains(media)))
                {
                    filename = match.Value.Substring(match.Value.IndexOf("http"));
                    filename = filename.Substring(0, filename.IndexOf(">")).Replace("\"", string.Empty).Trim();
                    filename = ValidateFileName(publishable, filename);

                    if (!fileExists)
                    {
                        continue;
                    }

                    enclosure = string.Format(enclosure, filename, fileSize, mediatype);
                    return enclosure;
                }
            }

            return string.Empty;
        }