public IEnumerable <Talk> Load()
        {
            var registeredTalks = new List <Talk>();

            foreach (var talk in TalksList)
            {
                var    unit  = CheckForValidUnit(talk);
                string topic = null;


                var durationPosition = talk.IndexOfAny("0123456789".ToCharArray());

                var duration = "1";

                if (durationPosition == -1)
                {
                    topic = talk.Substring(0, talk.LastIndexOf(unit, StringComparison.OrdinalIgnoreCase));
                }
                else
                {
                    topic = talk.Substring(0, durationPosition);

                    duration = talk.Substring(durationPosition,
                                              talk.LastIndexOfAny("0123456789".ToCharArray()) - durationPosition + 1);
                }


                var talkDuration = new TalkDuration((TimeUnit)Enum.Parse(typeof(TimeUnit), unit, true)
                                                    , Convert.ToInt32(duration));

                registeredTalks.Add(new Talk(topic, talkDuration));
            }

            return(registeredTalks);
        }
Exemple #2
0
 public Talk(string topic, TalkDuration duration)
 {
     try
     {
         Duration = duration;
         if (IsInValidTitle(topic))
         {
             throw new ArgumentException("Title Cannot contain Numeric values");
         }
         Topic = topic;
     }
     catch (ArgumentException e)
     {
         throw;
     }
 }