/// <summary> /// Init with the various items for a talk. /// </summary> /// <param name="t"></param> public TalkUserControlViewModel(ITalk t) { Talk = t; // Talk metadata. Title = t.Title; var auth = new StringBuilder(); foreach (var a in t.Speakers) { if (auth.Length > 0) { auth.AppendFormat(", {0}", a); } else { auth.Append(a); } } Authors = auth.ToString(); Time = string.Format("{0} - {1} ({2} minutes)", t.StartTime.ToString("h:mm tt"), t.EndTime.ToString("h:mm tt"), (t.EndTime - t.StartTime).Minutes); // Split the talk out by file names, and put them out to be displayed everywhere. // We screen out everything here that doesn't have a good file type (one of the requirements of IsValid for now). // TODO: fix up so we can deal with links to other material. var byName = from f in t.AllTalkFiles where f.IsValid group f by f.DisplayName; TalkFiles = new ReactiveList <TalkFileCollectionUserControlViewModel>(); TalkFiles.AddRange(byName.Select(fs => new TalkFileCollectionUserControlViewModel(fs.ToArray(), t))); SubTalks = new ReactiveList <TalkUserControlViewModel>(t.SubTalks.Select(st => new TalkUserControlViewModel(st))); }
public Guid SaveTalk(ITalk talk) { using (var db = new RtDataContext(_connectionString)) { var dto = db.Talks.FirstOrDefault(t => t.TalkId == talk.TalkId); if (dto == null || talk.TalkId == Guid.Empty) { dto = new TalkDto() { TalkId = Guid.NewGuid() }; db.Talks.InsertOnSubmit(dto); } dto.LocationId = talk.LocationId; dto.PresenterId = talk.PresenterId; dto.Topic = talk.Topic; db.SubmitChanges(); return(dto.TalkId); } }
public dummySession() { Talks = new ITalk[] { new dummyTalk() }; Title = "session title"; StartTime = DateTime.Now; Id = "1"; }
public void TestGetNewTalk() { ITalk talk = Factory.Instance.GetNewTalk("TEST", 60); Assert.True(null != talk && talk.Duration == 60 && talk.Title == "TEST" && talk.EventType == EventTypes.Talk && !talk.IsScheduled); }
public void StateLog(ITalk player, ITalk enemy) { Player.Player p = (Player.Player)player; gw.ChangeValue(p.GetHealthPercentage()); gw.WriteText(String.Format("Player has {0} health remaining...", p.Health)); Enemy e = (Enemy)enemy; gw.WriteText(String.Format("{0} has {1} health remaining...", e.Name, e.Health)); }
public void TestGetNewLunch() { ITalk talk = Factory.Instance.GetNewLunch(DateTime.Today); Assert.True(null != talk && talk.StartTime == DateTime.Today.AddHours(12) && talk.Title == Titles.Lunch && talk.EventType == EventTypes.Lunch && talk.IsScheduled); }
/// <summary> /// Initializes a new instance of the <see cref="Track" /> class. /// </summary> /// <param name="date">The date.</param> public Track(DateTime date) { //Use only date component and excluded time. date = date.Date; Date = date; _morningSession = Factory.Instance.GetNewSession(SessionTypes.Morning, date); _afternoonSession = Factory.Instance.GetNewSession(SessionTypes.Afternoon, date); _lunch = Factory.Instance.GetNewLunch(Date); _networkingEvent = Factory.Instance.GetNewNetworkingEvent(date); }
public void TestGetNewNetworkingEvent() { ITalk talk = Factory.Instance.GetNewNetworkingEvent(DateTime.Today); Assert.True(null != talk && talk.StartTime == DateTime.Today.AddHours(16) && talk.Title == Titles.NetworkingEvent && talk.EventType == EventTypes.Networking && talk.IsScheduled); }
/// <summary> /// Updates the remaining duration. /// </summary> /// <param name="talk">The talk.</param> private void UpdateRemainingDuration(ITalk talk) { if (RemainingDuration > 0) { RemainingDuration -= talk.Duration; } else { BufferDuration -= talk.Duration; } }
/// <summary> /// Adds the talk to this session. /// </summary> /// <param name="talk">The talk.</param> /// <exception cref="Shared.TrackManagementException">Unable to add talk to session.</exception> private void AddTalk(ITalk talk) { if (RemainingDuration <= 0 && BufferDuration <= 0) { throw new TrackManagementException(Resource.UnableToAddTalk); } SetTalkStartTime(talk); UpdateRemainingDuration(talk); Talks.Add(talk); UpdateNextSessionStartTime(talk.Duration); }
public void TestScheduleTalksWithInvalidData() { ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 90); ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 50); ITalk talkC = Factory.Instance.GetNewTalk("Talk C", 60); var unscheduledTalks = new List <ITalk> { talkA, talkB, talkC }; List <ITalk> scheduledTalks = TalkScheduler.Instance.ScheduleTalks(unscheduledTalks, 180); Assert.True(null == scheduledTalks); }
public void TestTalkToString() { ITalk talk = Factory.Instance.GetNewTalk("Test", 60); talk.StartTime = DateTime.Today.AddHours(9); //Passing in DateTime.Now tests for filtering date component during objcet creation. ITalk lunch = Factory.Instance.GetNewLunch(DateTime.Now); ITalk networkingEvent = Factory.Instance.GetNewNetworkingEvent(DateTime.Now); Assert.True(talk.ToString().Equals("09:00AM Test 60min") && lunch.ToString().Equals("12:00PM Lunch") && networkingEvent.ToString().Equals("04:00PM Networking Event")); }
public void TestScheduleTalksWithLesserDuration() { ISession session2 = Factory.Instance.GetNewSession(SessionTypes.Morning, DateTime.Now); ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 60); ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 60); var unscheduledTalks = new List <ITalk> { talkA, talkB }; session2.ScheduleTalks(unscheduledTalks); Assert.True(session2.RemainingDuration == 60 && session2.Talks.Count == 2 && unscheduledTalks.Count == 0); }
static void Main() { Document theDoc = new Document("Test Document"); IStorable isDoc = theDoc; isDoc.Read(); ITalk itDoc = theDoc; itDoc.Read(); theDoc.Read(); theDoc.Talk(); }
public void Test_LogInterceptionBehavior() { UnityContainer container = new UnityContainer(); container.AddNewExtension <Interception>(); container.RegisterType <ITalk, PeopleTalk>( new InjectionConstructor("AOP", 18), new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <LogInterceptionBehavior>()); ITalk talker = container.Resolve <ITalk>(); bool isTalked = talker.talk("Test!"); Assert.IsTrue(isTalked); }
/// <summary>Prints the exception message to console.</summary> /// <param name="trackManagementException">The track management exception.</param> private void PrintException(TrackManagementException trackManagementException) { Console.WriteLine(trackManagementException.Message); if (null == UnscheduledTalks) { return; } Console.WriteLine(Resource.UnableToSchedule); for (int index = 0; index < UnscheduledTalks.Count; index++) { ITalk unscheduledTalk = UnscheduledTalks[index]; Console.WriteLine(Constants.UnscheduledTalksFormat, index + 1, unscheduledTalk.Title, unscheduledTalk.Duration); } }
static void Main() { Documento doc = new Documento("Documento 1"); ITalk idoc = doc as ITalk; if (idoc != null) { idoc.Read(); } doc.Read(); doc.Talk(); doc.Write(); }
public static void Main() { Document doc = new Document(); doc.Read(); doc.Talk(); IStorable isdoc = doc; isdoc.Read(); ITalk itdoc = doc; itdoc.Read(); }
static void Main() { //pravi objekt Document-a Document theDoc = new Document("Test document"); IStorable isDoc = theDoc; isDoc.Read(); ITalk itDoc = theDoc; itDoc.Read(); theDoc.Read(); theDoc.Talk(); }
public void TestScheduleTalksWithNoSubset() { ISession session4 = Factory.Instance.GetNewSession(SessionTypes.Morning, DateTime.Now); ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 60); ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 60); ITalk talkC = Factory.Instance.GetNewTalk("Talk C", 90); ITalk talkD = Factory.Instance.GetNewTalk("Talk D", 50); var unscheduledTalks = new List <ITalk> { talkA, talkB, talkC, talkD }; session4.ScheduleTalks(unscheduledTalks); Assert.True(session4.RemainingDuration == 180 && session4.Talks.Count == 0 && unscheduledTalks.Count == 4); }
static void Main() { Document theDoc = new Document("Test Document"); IStorable isDoc = theDoc; isDoc.Read(); ((ITalk)theDoc).Read(); //otherway ITalk itDoc = theDoc; itDoc.Read(); theDoc.Read(); theDoc.Talk(); }
public void TestToString() { ISession session6 = Factory.Instance.GetNewSession(SessionTypes.Morning, DateTime.Now); ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 60); ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 60); ITalk talkC = Factory.Instance.GetNewTalk("Talk C", 60); var unscheduledTalks = new List <ITalk> { talkA, talkB, talkC }; session6.ScheduleTalks(unscheduledTalks); Assert.True(session6.ToString().Equals(new StringBuilder("09:00AM Talk A 60min").Append(Environment.NewLine) .Append("10:00AM Talk B 60min").Append(Environment.NewLine) .Append("11:00AM Talk C 60min").Append(Environment.NewLine) .ToString())); }
/// <summary> /// The method is used to assign time for all the scheduled talks /// </summary> /// <param name="tracks"></param> private void AssignTimeToTalks(IList <ITrack> tracks) { DateTime date = new DateTime(); TimeSpan ts = startTime; date = date.Date + ts; TimeSpan scheduledTime = date.TimeOfDay; foreach (var item in tracks) { //Order the sessions presnet in the SessionEnum IOrderedEnumerable <KeyValuePair <SessionEnum, ITalkList> > orderedTracks = item.OrderBy(keyValuePair => SessionHelper.GetSesionAttributes((SessionEnum)keyValuePair.Key, Constants.Order)); ITalk previousTalk = null; foreach (KeyValuePair <SessionEnum, ITalkList> talkList in orderedTracks) { //If the session is the lunch time add an empty talk to it with schedule time bool isTalkSession = (bool)SessionHelper.GetSesionAttributes(talkList.Key, Constants.IsTalkSession); //if (talkList.Key == SessionEnum.Lunch) if (!isTalkSession) { talkList.Value[0].ScheduledTime = previousTalk.ScheduledTime.Add(new TimeSpan(0, previousTalk.Value, 0)); previousTalk = talkList.Value[0]; continue; } foreach (ITalk talk in talkList.Value) { //If it is the first talk of the track start it with the start time provided while initilizing this class if (previousTalk == null) { talk.ScheduledTime = scheduledTime; } //Else add the duration of the previous talk to the previous talks scheduled time else { talk.ScheduledTime = previousTalk.ScheduledTime.Add(new TimeSpan(0, previousTalk.Value, 0)); } previousTalk = talk; } } } }
public void TestScheduleTrackWithValidTalkDuration() { ITrack track = new Track(DateTime.Now); ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 60); ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 60); ITalk talkC = Factory.Instance.GetNewTalk("Talk C", 60); ITalk talkD = Factory.Instance.GetNewTalk("Talk D", 60); ITalk talkE = Factory.Instance.GetNewTalk("Talk E", 60); ITalk talkF = Factory.Instance.GetNewTalk("Talk F", 60); var unscheduledTalks = new List <ITalk> { talkA, talkB, talkC, talkD, talkE, talkF }; bool result = track.ScheduleTrack(unscheduledTalks); Assert.True(result && track.BufferDuration == 60 && unscheduledTalks.Count == 0 && track.MorningSession.RemainingDuration == 0 && track.AfternoonSession.RemainingDuration == 0); }
static void Main(string[] args) { Document theDoc = new Document("Test Document"); IStorable isDoc = theDoc as IStorable; if (isDoc != null) { isDoc.Read(); } ITalk itDoc = theDoc as ITalk; if (itDoc != null) { itDoc.Read(); } theDoc.Read(); theDoc.Talk(); Console.ReadLine(); }
public void TestAddTalks() { ISession session5 = Factory.Instance.GetNewSession(SessionTypes.Afternoon, DateTime.Now); ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 60); ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 60); ITalk talkC = Factory.Instance.GetNewTalk("Talk C", 60); var unscheduledTalks = new List <ITalk> { talkA, talkB, talkC }; var scheduledTalks = new List <ITalk> { talkA, talkB, talkC }; session5.AddTalks(scheduledTalks, unscheduledTalks); Assert.True(session5.RemainingDuration == 0 && session5.Talks[1].StartTime == DateTime.Today.AddHours(14) && //start time check session5.Talks.Count == scheduledTalks.Count && unscheduledTalks.Count == 0); }
/// <summary> /// Passes the input strings and creates the list of talks to be scheduled. /// </summary> /// <param name="inputs">The conference talks as strings.</param> /// <returns> List of unscheduled talks. </returns> public List <ITalk> GetTalks(List <string> inputs) { var talks = new List <ITalk>(); if (null == inputs || inputs.Count == 0) { return(talks); } foreach (string entry in inputs) { var inputEntry = entry.Trim(); int indexOf = inputEntry.LastIndexOf(Constants.Space, StringComparison.Ordinal); string title = inputEntry.Substring(0, indexOf); string talkDuration = inputEntry.Substring(indexOf + 1).ToLower(); int duration = GetDuration(talkDuration); ITalk talk = Factory.Instance.GetNewTalk(title, duration); talks.Add(talk); } return(talks); }
public void Run() { // Create a Document object Document theDoc = new Document("Test Document"); IStorable isDoc = theDoc as IStorable; if (isDoc != null) { isDoc.Read(); } // Cast to an ITalk interface ITalk itDoc = theDoc as ITalk; if (itDoc != null) { itDoc.Read(); } theDoc.Read(); theDoc.Talk(); }
/// <summary> /// Configure for showing multiple files. /// </summary> /// <param name="files"></param> public TalkFileCollectionUserControlViewModel(IFile[] files, ITalk t) { // The title we use is what we grab from the first file. Title = files.Length > 0 ? files[0].DisplayName : ""; // Show the list of files that can downloaded/opened. These guys can opened by other // apps in the system by clicking or pressing on them. var allFilesVM = (from f in files select new { FilePointer = f, UserControl = new FileUserControlViewModel(f) }) .ToArray(); TalkFiles = new ReactiveList <FileUserControlViewModel>(); TalkFiles.AddRange(allFilesVM.Select(f => f.UserControl)); #if WINDOWS_APP // If there is a PDF file, then we use that to show a "hero" slide. // TODO: WARNING - this will create a PDFFile, but one may not want that here // if one is also going to create other PDF file guys!! var pdf = allFilesVM.Where(f => f.FilePointer.FileType == "pdf" && f.FilePointer.IsValid).FirstOrDefault(); if (pdf != null) { var pdfFile = new PDFFile(pdf.UserControl.FileDownloader); var fullVM = new Lazy <FullTalkAsStripViewModel>(() => new FullTalkAsStripViewModel(Locator.Current.GetService <IScreen>(), pdfFile)); HeroSlide = new FirstSlideHeroViewModel(pdfFile, fullVM); var timeSpan = new TimePeriod(t.StartTime, t.EndTime); Thumbs = new ExpandingSlideThumbViewModel(pdfFile, timeSpan); } else { HeroSlide = new FirstSlideHeroViewModel((PDFFile)null, null); } #endif }
/// <summary> /// Is this talk the same as that other talk? /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(ITalk other) { var italk = other as IndicoTalk; if (italk == null) { return(false); } if (italk.aTalk.ID != aTalk.ID) { return(false); } if (italk.aTalk.Title != aTalk.Title) { return(false); } if (italk.aTalk.StartDate != aTalk.StartDate) { return(false); } if (italk.aTalk.EndDate != aTalk.EndDate) { return(false); } if (italk.aTalk.SlideURL != aTalk.SlideURL) { return(false); } // Next, there are other minor things that might get updated that will require us to re-do this talk. return(true); }
public Guid SaveTalk(ITalk talk) { using (var db = new RtDataContext(_connectionString)) { var dto = db.Talks.FirstOrDefault(t => t.TalkId == talk.TalkId); if (dto == null || talk.TalkId == Guid.Empty) { dto = new TalkDto() { TalkId = Guid.NewGuid() }; db.Talks.InsertOnSubmit(dto); } dto.LocationId = talk.LocationId; dto.PresenterId = talk.PresenterId; dto.Topic = talk.Topic; db.SubmitChanges(); return dto.TalkId; } }
/// <summary> /// Sets the talk's start time. /// </summary> /// <param name="talk">The talk.</param> private void SetTalkStartTime(ITalk talk) { talk.StartTime = NextTalkStartTime; talk.IsScheduled = true; }
/// <summary> /// Adds the talk to this session. /// </summary> /// <param name="talk">The talk.</param> /// <exception cref="Shared.TrackManagementException">Unable to add talk to session.</exception> private void AddTalk(ITalk talk) { if (RemainingDuration <= 0 && BufferDuration <= 0) throw new TrackManagementException(Resource.UnableToAddTalk); SetTalkStartTime(talk); UpdateRemainingDuration(talk); Talks.Add(talk); UpdateNextSessionStartTime(talk.Duration); }
public TalkProxy(ITalk talker) { this.talker = talker; }
public Guid SaveTalk(ITalk talk) { return _talkSaver.SaveTalk(talk); }
/// <summary> /// Updates the remaining duration. /// </summary> /// <param name="talk">The talk.</param> private void UpdateRemainingDuration(ITalk talk) { if (RemainingDuration > 0) RemainingDuration -= talk.Duration; else BufferDuration -= talk.Duration; }