public override string ToString() { var properties = new Dictionary <string, string> { { "AddType", AddType.ToString() }, { "FileGlobs", StringifyList(FileGlobs) } }; return(StringifyValues(GetType().ToString(), properties)); }
// picks random ad from given list for given type public static Ad_S1 GetAdd(List <Ad_S1> _ads, AddType _type) { bool _contains = false; // check that list contains type foreach (Ad_S1 _ad in _ads) { if (_ad.Type == _type) { _contains = true; break; } } if (!_contains) { throw new ArgumentException(string.Format("List of ads does not contain given type \"{0}\"", _type.ToString())); } // pick a random ad while (true) { Random _rand = new Random(); int _index = _rand.Next(_ads.Count); Ad_S1 _ad = _ads[_index]; if (_ad.Type == _type) { return(_ad); } } }