public LatestProfile( IListenedShow latestShow, IShow show, UserProfile profile, ISubscription subscription ) { LatestListenedShow = latestShow; LatestShow = show; Profile = profile; Subscription = subscription; }
public void Delete( IShow show ) { Checks.Argument.IsNotNull( show, "show" ); using ( IUnitOfWork u = UnitOfWork.Begin() ) { _repo.Remove( show ); u.Commit(); } }
public void SaveCommit(IShow show, out bool success) { using (IUnitOfWork u = UnitOfWork.Begin()) { Save(show, out success); if (success) u.Commit(); } }
private void BindListenedShow(IShow show) { var listened = _ListenedShowService.GetByUserAndShowId(GetUserId(), show.Id); if (listened == null) { return; } if (listened.Attended) { btnAttended.Text = "Attended"; btnAttended.CssClass.Remove(0); btnAttended.CssClass = "notesAttended"; hdnAttended.Value = "true"; } if (listened.Stars != null && listened.Stars.HasValue) { CurrentRating = listened.Stars.Value; } else { CurrentRating = 0; } lblCreatedDate.Text = _LocalZone.ToLocalTime(listened.CreatedDate).ToString(); lblUpdatedDate.Text = listened.UpdatedDate.HasValue ? _LocalZone.ToLocalTime(listened.UpdatedDate.Value).ToString() : ""; Button button; switch (listened.Status) { case (int)ListenedStatus.InProgress: button = btnInProgress; break; case (int)ListenedStatus.Finished: button = btnFinished; break; case (int)ListenedStatus.NeedToListen: button = btnNeedToListen; break; case (int)ListenedStatus.None: default: button = btnNeverHeard; break; } SetListenedStatusButton(button); }
private static Episode CreateEpisode(MazeShowEpisode episode, IShow show) { return(new Episode { Title = episode.Name, AirDate = episode.AirDate, Season = episode.Season, EpisodeInSeason = episode.Number, ShowName = show.Name, ShowId = show.ShowId }); }
private async Task <IReadOnlyList <IEpisode> > FindEpisodesFromMazeApi(IShow show) { var request = WebRequest.Create($"http://api.tvmaze.com/shows/{show.MazeId}/episodes"); using (var response = await request.GetResponseAsync()) using (var streamReader = new StreamReader(response.GetResponseStream())) { var responseString = streamReader.ReadToEnd(); var mazeEpisodes = JsonSerializer.Deserialize <IReadOnlyList <MazeShowEpisode> >(responseString); return(mazeEpisodes.Select(episode => CreateEpisode(episode, show)).ToList()); } }
private void CreateOrUpdateEpisode(IShow show, IEpisode episode) { var existingEpisode = show.Episodes.SingleOrDefault(x => x.Season == episode.Season && x.EpisodeInSeason == episode.EpisodeInSeason); if (existingEpisode == null) { CreateEpisode(episode); } else if (ShouldUpdateEpisode(existingEpisode, episode)) { UpdateEpisode(episode); } }
public async Task <Result <IReadOnlyList <IEpisode> > > FindEpisodes(IShow show) { if (!show.MazeId.HasValue) { return(Result <IReadOnlyList <IEpisode> > .Failure($"Failed to fetch episode data for show {show.Name} since because it is missing a MazeId")); } try { return(Result <IReadOnlyList <IEpisode> > .Successful(await FindEpisodesFromMazeApi(show))); } catch (Exception exception) { Log.Error("Failed to fetch episode data for show {MazeId}: {@Exception}", show.MazeId.Value, exception); return(Result <IReadOnlyList <IEpisode> > .Failure($"Failed to fetch episode data for show {show.MazeId.Value}")); } }
public void Save(IShow show, out bool success) { Checks.Argument.IsNotNull(show, "show"); success = false; if (null == _repo.FindById(show.Id)) { try { _repo.Add(show); success = true; } catch (Exception ex) { success = false; } } }
/// <summary> /// Set the show /// </summary> /// <param name="show">Show</param> public void SetShow(IShow show) { var showToUpdate = User.ShowHistory.FirstOrDefault(a => a.ImdbId == show.ImdbId); if (showToUpdate == null) { User.ShowHistory.Add(new ShowHistory { ImdbId = show.ImdbId, Favorite = show.IsFavorite, }); } else { showToUpdate.Favorite = show.IsFavorite; } }
private void GoToShowCommands() { if ("all" == commands[1].ToLower()) { if (dataStore is IShow) { IShow store = (IShow)dataStore; Console.Clear(); Console.WriteLine("| ID\t| NAME\t|\tAGE\t|\tPHONE\t\t|"); Console.WriteLine(new string('-', 65)); foreach (Person person in store.ShowAll()) { Console.WriteLine(person); } Console.ReadLine(); } else { throw new ArgumentException("Wrong object"); } } else if (Int32.Parse(commands[1]) > 0) { if (dataStore is IShow) { IShow store = (IShow)dataStore; Console.Clear(); Console.WriteLine("| ID\t| NAME\t|\tAGE\t|\tPHONE\t\t|"); Console.WriteLine(new string('-', 65)); Console.WriteLine(store.ShowOnePerson(Int32.Parse(commands[1]))); Console.ReadLine(); } else { throw new ArgumentException("Wrong object"); } } else { throw new ArgumentException("Input command is incorrect"); } }
public void Save(IShow show, out bool success) { Checks.Argument.IsNotNull(show, "show"); success = false; if (null == _repo.FindByShowId(show.ShowId)) { try { _repo.Add(show); success = true; } catch (Exception ex) { success = false; } } }
public async Task <Result> Refresh(IShow show) { if (!show.MazeId.HasValue) { return(Result.Failure($"Could not refresh show {show.Name} because it was missing a maze id")); } var episodesResult = await _mazeShowEpisodeClient.FindEpisodes(show); if (!episodesResult.Success) { return(Result.Failure(episodesResult.ErrorMessage)); } CreateOrUpdateEpisodes(show, episodesResult); MissingEpisodesRequestController.CacheSource.Cancel(); return(Result.Successful); }
public static void Task1() { Circle C = new Circle { R = 1 }; // C.Show(); TestIShow(C); TestICharacterGeometri(C); Rectangle R = new Rectangle { a = 2, b = 5 }; // R.Show(); TestIShow(R); TestICharacterGeometri(R); Human H = new Human { Name = "Petro", Bday = new DateTime(1996, 5, 23) }; // H.Show(); TestIShow(H); // TestICharacterGeometri(H); IShow ishow = H; ishow.Show(); Human H2 = (Human)ishow; if (ishow is Human H3) { H3.Name = "Igor"; } // H2.Name = "Ivan"; // ishow.Name = ""; ishow.Show(); //ishow = C; //ishow = R; }
private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); Assembly ass = Assembly.LoadFrom(openFileDialog1.FileName); foreach (Type type in ass.GetTypes()) { if (type.GetInterface("IShow") != null) { try { IShow ishow = Activator.CreateInstance(type) as IShow; ishow.Show(); } catch (Exception) { throw; } } } }
static void Main() { Rect rt = new Rect(); Console.WriteLine(rt.GetPoint() + "\t" + rt.Points + "\t" + rt[0]); Figure[] fg = { new Rect(), new Rect(), new Circle(), new Hexagon() }; for (int i = 0; i < fg.Length; i++) { if (fg[i] is IPoint) { IPoint ip = fg[i] as IPoint; Console.WriteLine(ip.GetPoint()); } else { Console.WriteLine("Not found "); } } IPoint[] arr = { new Hexagon(), new Rect(), new Knife(), new Mountian(), new Circle() as IPoint, new Knife() }; foreach (var item in arr) { if (item == null) { Console.WriteLine("ArgumentNullException"); } else { Console.WriteLine(item.Points); } } var rty = new Rect(); rty.Show(); IShow ish = rty; ish.Show(); }
private void Bind() { DateTime showDate; Guid showId; var showService = new ShowService(Ioc.GetInstance <IShowRepository>()); IShow show = null; var segment = Request.GetFriendlyUrlSegments().FirstOrDefault(); //Check to see if the show date or show id is passed in then get the IShow for that show if (DateTime.TryParse(segment, out showDate)) { show = showService.GetShow(showDate); } else if (Guid.TryParse(segment, out showId)) { show = showService.GetShow(showId); } //If it is not a valid show then get out of here if (show == null) { Response.Redirect(LinkBuilder.DefaultMainLink()); } hdnShowId.Value = show.Id.ToString(); lnkPhishShows.NavigateUrl = GetPhishowsLink(showDate); lnkPhishTracks.NavigateUrl = GetPhishTracksLink(showDate); //Get the user Id and Bind the notes and tags BindNotes(show); BindTags(show.Id); BindListenedShow(show); BindSetlist(show.ShowDate.Value); }
private void BindNotes(IShow show) { hdnShowTitle.Value = show.GetShowName(); var userId = GetUserId(); var listenedShow = _ListenedShowService.GetByUserAndShowId(userId, show.Id); if (listenedShow == null) { bool success = false; listenedShow = _DomainObjectFactory.CreateListenedShow(show.Id, userId, show.ShowDate.Value, (int)ListenedStatus.None, string.Empty); _ListenedShowService.SaveCommit(listenedShow, out success); if (!success) { _Log.Write("Saving a listened show for user: {0} and show: {1} failed", userId, show.ShowDate.Value); return; } } hdnListenedId.Value = listenedShow.Id.ToString(); txtNotes.Text = listenedShow.Notes; }
//新增餐桌 public Hashtable SaveTable(IShow.ChooseDishes.Data.Table table) { using (ChooseDishesEntities entities = new ChooseDishesEntities()) { try { Hashtable hash = new Hashtable();//返回结果 List<IShow.ChooseDishes.Data.Table> tables; //检查类型编号或者类型名称是否重复 tables = entities.Table.Where(info => info.Name == table.Name || info.Code == table.Code).ToList(); if (tables != null && tables.Count > 0) { hash.Add("code", 1); if (tables[0].Name == table.Name) { hash.Add("message", "餐桌名称已经存在,请重新命名!"); } else if (tables[0].Code == table.Code) { hash.Add("message", "餐桌编号已经存在!"); } return hash; } entities.Table.Add(table); int result = entities.SaveChanges(); if (result == 1) { hash.Add("code", 0); hash.Add("message", "新增成功!"); } else { hash.Add("code", 2); hash.Add("message", "新增失败,请稍后再试!"); } return hash; } catch (Exception e) { throw e; } }; }
public DefaultController(IShow show) { _show = show; }
public bool UpdateTable(IShow.ChooseDishes.Data.Table table) { using (ChooseDishesEntities entities = new ChooseDishesEntities()) { DbEntityEntry<IShow.ChooseDishes.Data.Table> entry = entities.Entry<IShow.ChooseDishes.Data.Table>(table); entry.State = System.Data.Entity.EntityState.Unchanged;//Modified entry.Property("Name").IsModified = true; entry.Property("Seat").IsModified = true; entry.Property("TableTypeId").IsModified = true; entry.Property("LocationId").IsModified = true; entry.Property("Status").IsModified = true; //TODO 是否已经启用,已启用则不能删除 entry.Property("TableId").IsModified = false; try { entities.Configuration.ValidateOnSaveEnabled = false; int result = entities.SaveChanges(); entities.Configuration.ValidateOnSaveEnabled = true; if (result == 1) { return true; } else { return false; } } catch (Exception e) { Console.WriteLine(e.ToString()); return false; } } }
public Displayer() { _show = ServiceContext.Resolve <IShow>(); _export = ServiceContext.Resolve <IFileHandle>(); }
public void AddShowInUser(string token, IShow show) { AddShowInUser(token, show.Url); }
public static void Print(this IShow d) { Console.WriteLine("Printed"); }
public static void TestIShow(IShow ishow) { ishow.Show(); }
public async Task Run(ILoggerFactory loggerFactory) { _logger = loggerFactory.CreateLogger <GreenlightOMatic>(); var shows = new ShowOptions[] { ShowOptions.Simpsons, ShowOptions.Firefly, ShowOptions.Dollhouse, ShowOptions.KVille, ShowOptions.Quit }; Console.CancelKeyPress += (sender, eventArgs) => { _logger.LogCritical($"Awaiting cancelled show {_choice.ToString()} to cancel."); eventArgs.Cancel = true; _tokenSource.Cancel(); }; while (true) { DisplayMenu(shows); _choice = GetSelection(shows); Console.WriteLine($"You have selected {_choice.ToString()}"); if (_choice != ShowOptions.Quit) { _logger.LogInformation($"Beginning pre-production of {_choice.ToString()}"); } _tokenSource = new CancellationTokenSource(); var token = _tokenSource.Token; IShow show = null; switch (_choice) { case ShowOptions.Simpsons: show = new Simpsons(loggerFactory); break; case ShowOptions.Firefly: show = new Firefly(loggerFactory); break; case ShowOptions.Dollhouse: show = new Dollhouse(loggerFactory); break; case ShowOptions.KVille: show = new KVille(loggerFactory); break; case ShowOptions.Quit: return; } _logger.LogInformation("Pre-production complete. Let's make some television, people!"); PromptCancel(); if (null != show) { await show.MakeShow(token).ContinueWith((t) => { _logger.LogCritical($"Show {_choice.ToString()} has been cancelled."); }); } await Task.Delay(1000); // Delay for a second to let the loggers finish up } }
public TicketController(ITicket ticket, IShow show, IMovie movie) { this.ticketrepository = ticket; this.showrepository = show; this.movierepository = movie; }
public ShowController(IShow show) { _show = show; }
public void DelShow(IShow show) { DelShow(show.Url); }
private void BindNotes( IShow show ) { hdnShowTitle.Value = show.GetShowName(); var userId = GetUserId(); var listenedShow = _ListenedShowService.GetByUserAndShowId( userId, show.Id ); if ( listenedShow == null ) { bool success = false; listenedShow = _DomainObjectFactory.CreateListenedShow( show.Id, userId, show.ShowDate.Value, (int)ListenedStatus.None, string.Empty ); _ListenedShowService.SaveCommit( listenedShow, out success ); if ( !success ) { _Log.Write( "Saving a listened show for user: {0} and show: {1} failed", userId, show.ShowDate.Value ); return; } } hdnListenedId.Value = listenedShow.Id.ToString(); txtNotes.Text = listenedShow.Notes; }
private void BindListenedShow( IShow show ) { var listened = _ListenedShowService.GetByUserAndShowId( GetUserId(), show.Id ); if ( listened == null ) return; if ( listened.Attended ) { btnAttended.Text = "Attended"; btnAttended.CssClass.Remove( 0 ); btnAttended.CssClass = "notesAttended"; hdnAttended.Value = "true"; } if ( listened.Stars != null && listened.Stars.HasValue ) { CurrentRating = listened.Stars.Value; } else { CurrentRating = 0; } lblCreatedDate.Text = _LocalZone.ToLocalTime( listened.CreatedDate ).ToString(); lblUpdatedDate.Text = listened.UpdatedDate.HasValue ? _LocalZone.ToLocalTime( listened.UpdatedDate.Value ).ToString() : ""; Button button; switch ( listened.Status ) { case (int)ListenedStatus.InProgress: button = btnInProgress; break; case (int)ListenedStatus.Finished: button = btnFinished; break; case (int)ListenedStatus.NeedToListen: button = btnNeedToListen; break; case (int)ListenedStatus.None: default: button = btnNeverHeard; break; } SetListenedStatusButton( button ); }
public Chief(string name, string position, decimal salary, IShow show, ISearch search) : base(name, position, salary, show, search) { }
public static List <FavoriteSetSong> GenerateFavoriteVersionListByAlbum(string album) { var songService = new SongService(Ioc.GetInstance <ISongRepository>()); var setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>()); var favoriteVersionService = new FavoriteVersionService(Ioc.GetInstance <IFavoriteVersionRepository>()); var showService = new ShowService(Ioc.GetInstance <IShowRepository>()); var setService = new SetService(Ioc.GetInstance <ISetRepository>()); FavoriteVersionSongList songList = new FavoriteVersionSongList(); foreach (var song in songService.GetSongsByAlbum(album)) { var versions = favoriteVersionService.GetAllFavoriteVersions().Where(s => s.SongId == song.SongId).GroupBy(g => g.SetSongId).ToList(); if (versions == null || versions.Count() <= 0) { songList.AddFavoriteSongPair(null, SetSong.FromSong((Song)song), null); continue; } if (versions.Count() == 1) { var version = versions[0].First(); var setSong = setSongService.GetSetSong(version.SetSongId.Value); var set = setService.GetSet(setSong.SetId.Value); var show = showService.GetShow(set.ShowId.Value); songList.AddFavoriteSongPair((FavoriteVersion)version, (SetSong)setSong, (Show)show); } else { int count = 0; Guid? setSongId = null; FavoriteVersion fave = null; SetSong setSong = null; IShow show = null; foreach (var version in versions) { if (version.Count() > count) { fave = (FavoriteVersion)version.First(); setSongId = version.First().SetSongId; } } if (setSongId != null) { setSong = (SetSong)setSongService.GetSetSong(setSongId.Value); var set = setService.GetSet(setSong.SetId.Value); show = showService.GetShow(set.ShowId.Value); } songList.AddFavoriteSongPair(fave, setSong ?? SetSong.FromSong((Song)song), (Show)show); } } return(songList.SongList); }
public override bool Equals(object show) { IShow showToCompare = show as IShow; return(showToCompare != null && this.Id.Equals(showToCompare.Id)); }
static void Main(string[] args) { #region 准备容器 IocContainer container = new IocContainer(); container.Register <IShow, Show>(); //container.Register<IShowContructor, ShowContructor>(); //container.Register<IContructor, Contructor>(); //container.Register<IShowProperty, ShowProperty>(); //container.Register<IShowMultiple, ShowMultiple>(); //container.Register<IShowMultipleOne, ShowMultipleOne>(); //container.Register<IShowMultipleTwo, ShowMultipleTwo>(); #endregion #region 无参数构造/有参数构造注入 { //单层级注入 //IShow show = container.Resolve<IShow>(); //IShowContructor showContructor = container.Resolve<IShowContructor>(); //show.DoSomething(); //showContructor.DoSomething(); //多层级注入 //IShowMultiple showMultiple = container.Resolve<IShowMultiple>(); //showMultiple.DoSomething(); } #endregion #region 属性注入 { //IShowProperty showProperty = container.Resolve<IShowProperty>(); //showProperty.DoSomething(); } #endregion #region 一个接口多个实现的注入 //这个也暂时不处理--->多个参数给别名就好. 不要再register的时候传--->要构造的时候给定特性判断来传!!!!! //不过这个也一般用不到... - -. #endregion #region 生命周期 //1.暂时不弄 --->目前就是每次都构造一个全新的/ //2.单例 ----> 根据key缓存一下type实例就好 //3.scope ----> 需要创建以及copy子容器. 每个容器单例就好 #endregion #region Aop //类型代理 --->class //校验参数 不通过返回自定义的值 //方法前, 方法运行完成时候, 方法后 { //var proxy = (AopClassOne)ClassProxy.ProxyGenerate(typeof(AopClassOne)); //var a = proxy.ActionOne("1323", 22); //Console.WriteLine("*********************************************"); //Console.WriteLine($"返回值:{a}"); //proxy.ActionTwo(); } //接口代理 --->interface 需要结合ioc { //IShow show = container.Resolve<IShow>(); //show.DoSomething(); //show = (IShow)show.AopExtend(typeof(IShow)); //show.DoSomething(); } //上两种是类型注入 //下面是使用特性代理 { IShow show = container.Resolve <IShow>(); show.DoSomething(); } #endregion Console.ReadKey(); }
public void AddShowToShowOrder(IShow show, int index) { _showOrderList.Insert(index, show); }
public void Recommend(IShow show, string friend) { show.Recommend(this, friend); }
public void Display(IShow show, string a) { show.ShowText(a); }
public IShow[] AddShows(string[] paths) { IShow[] shows = new IShow[paths.Length]; for (int i = 0; i < paths.Length; i++ ) shows[i] = AddShow(paths[i]); return shows; }
public ShowTicketStub(IShow show, ITicketStub ticketStub) { Show = show; TicketStub = ticketStub; }
public void DeleteShow(IShow show) { while (_showOrderList.Remove(show)) ; while (_importedShows.Remove(show)) ; }
private void AppendShowToShowOrder(IJointShow jointShow, IShow show) { jointShow.AddShowToShowOrder(show, jointShow.ShowOrderShowsCount); }
public void DelShowInUser(string token, IShow show) { DelShowInUser(token, show.Url); }
public ShowController(IShow show, IMovie movie) { this.showrepository = show; this.movierepository = movie; }
public DataManager(IDatabase database, IShow show) { this._database = database; this._show = show; }
public DashboardController(IMovie movie, IShow show, IOrder order) { this.movierepository = movie; this.showrepository = show; this.orderrepository = order; }
public void AddShow(IShow show) { AddShow(show.Url); }