Example #1
0
        public static IList <int> GetIds(this Insertions insertions)
        {
            var urls = insertions.ads.Select(x => x?.urls.@default);
            var ids  = urls.Select(x => GetIdFromUrl(x));

            return(ids.ToList());
        }
Example #2
0
        public static int GetFirstId(this Insertions insertions)
        {
            var firstInsertionUrl = insertions.ads.FirstOrDefault()?.urls?.@default;

            if (firstInsertionUrl == null)
            {
                throw new ArgumentNullException("firstInsertionUrl");
            }
            var groups  = Regex.Match(firstInsertionUrl, @"https?:\/\/www.*\/(?<id>\d+).*").Groups;
            var firstId = Convert.ToInt32(groups["id"].Value);

            return(firstId);
        }
Example #3
0
 /// <summary>
 /// Retrieve a typographic insertion. Returns null if key cannot be resolved.
 /// </summary>
 public TypographData GetInsertion(string key)
 {
     if (Insertions.TryGetValue(key, out TypographData insertion))
     {
         return(insertion);
     }
     else
     {
         if (Parent == null)
         {
             LogWarning($"Failed to resolve insertion '{key}'.");
             return(null);
         }
         return(Parent.GetInsertion(key));
     }
 }