当前位置: 首页>>代码示例>>C#>>正文


C# Genre类代码示例

本文整理汇总了C#中Genre的典型用法代码示例。如果您正苦于以下问题:C# Genre类的具体用法?C# Genre怎么用?C# Genre使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Genre类属于命名空间,在下文中一共展示了Genre类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSameTypeBonus

    /// <summary>
    /// Given a player's Genre and the Genre of their attack, determines what Same Type Attack Bonus the player will get.
    /// </summary>
    /// <param name="ofPlayer">The Genre of the player.</param>
    /// <param name="ofAttack">The Genre of the weapon held by that player</param>
    /// <returns>Some bonus/penalty based on the inputs.</returns>
    public static float GetSameTypeBonus(Genre ofPlayer, Genre ofAttack)
    {
        switch (ofPlayer)
        {
            // Each case returns a STAB bonus based on how the attack's type compares to the user's.
            // Same type results in a 1.7x mult, the type that either counters or is countered by the player's type results
            // in a 0.6x mult, and the last "neutral" type results in a 1x mult (no change).
            case Genre.Fantasy:
                if(ofAttack == Genre.Fantasy)
                { return m_positiveSTABBonus; }
                else
                { return m_neutralSTABBonus; }

            case Genre.GraphicNovel:
                if(ofAttack == Genre.GraphicNovel)
                { return m_positiveSTABBonus; }
                else
                { return m_neutralSTABBonus; }

            case Genre.Horror:
                if (ofAttack == Genre.Horror)
                { return m_positiveSTABBonus; }
                else
                { return m_neutralSTABBonus; }

            case Genre.SciFi:
                if (ofAttack == Genre.SciFi)
                { return m_positiveSTABBonus; }
                else 
                { return m_neutralSTABBonus; }

            default:
                return 1f;
        }
    }
开发者ID:Awesome-MQP,项目名称:Storybook,代码行数:41,代码来源:StatsManager.cs

示例2: Update

        public Genre Update(Genre genre)
        {
            dbContext.Entry(genre).State = EntityState.Modified;
            dbContext.SaveChanges();

            return genre;
        }
开发者ID:natalija-sirobaba,项目名称:Library,代码行数:7,代码来源:GenreSqlCeDAOImpl.cs

示例3: btnAdd_Click

 protected void btnAdd_Click(object sender, EventArgs e)
 {
     bool isAlreadyExists;
     using (var context = new MyMoviesContext())
     {
         var genre = new Genre
         {
             Name = tbName.Text,
         };
         isAlreadyExists = context.Genres.FirstOrDefault(x => x.Name == genre.Name) != null;
         if (!isAlreadyExists)
         {
             context.Genres.Add(genre);
             context.SaveChanges();
         }
     }
     if (isAlreadyExists)
     {
         Response.Redirect(Request.Url.AbsoluteUri.Substring(0,
             Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count()) + "?genreAction=exist");
     }
     else
     {
         Response.Redirect("~/Default.aspx");
     }
 }
开发者ID:nancy-bree,项目名称:MyMovies,代码行数:26,代码来源:NewGenre.aspx.cs

示例4: ShouldCreateGenreWithArtists

        public void ShouldCreateGenreWithArtists()
        {
            Genre savedGenre = new Genre { Name = "Pop" };
            List<Artist> artists = new List<Artist> {
                    new Artist { Name = "1" },
                    new Artist { Name = "2" }
                };
            savedGenre.AddArtists(artists);
            Session.SaveOrUpdate(savedGenre);
            m_uow.Commit();
            Session.Clear();

            Genre retrievedGenre = Session.Get<Genre>(1);

            Assert.AreNotEqual(null, retrievedGenre);
            Assert.IsFalse(ReferenceEquals(savedGenre, retrievedGenre));
            Assert.AreEqual(savedGenre.Name, retrievedGenre.Name);
            Assert.AreEqual(savedGenre.Artists.Count, retrievedGenre.Artists.Count);
            Assert.IsFalse(ReferenceEquals(savedGenre.Artists[0], retrievedGenre.Artists[0]));
            Assert.AreEqual(savedGenre.Artists[0].Name, retrievedGenre.Artists[0].Name);
            Assert.IsFalse(ReferenceEquals(savedGenre.Artists[1], retrievedGenre.Artists[1]));
            Assert.AreEqual(savedGenre.Artists[1].Name, retrievedGenre.Artists[1].Name);

            //new PersistenceSpecification<Genre>(Session)
            //    .CheckProperty(g => g.Id, 1) //identity starts at 1 - can't reset to zero
            //    .CheckProperty(g => g.Name, "Genre")
            //    .CheckList(g => g.Artists, artists, (g, a) => g.AddArtist(a))
            //    .VerifyTheMappings();
        }
开发者ID:triggerfish,项目名称:MvcTemplate,代码行数:29,代码来源:GenreTests.cs

示例5: Create

        public Genre Create(Genre genre)
        {
            dbContext.Genres.Add(genre);
            dbContext.SaveChanges();

            return genre;
        }
开发者ID:natalija-sirobaba,项目名称:Library,代码行数:7,代码来源:GenreSqlCeDAOImpl.cs

示例6: TestGenreDelete

        public void TestGenreDelete()
        {
            using (var ctx = new CDCatalogEntities())
            {
                //Test init
                Genre g = new Genre();
                g.GenreID = 0;  // auto incremented and set by add
                g.GenreName = "Test Genre W6YderKT";
                //add it to the context and save to database
                ctx.Genres.Add(g);
                ctx.SaveChanges();

                //Find the list of "Test Genre"
                //in case duplicates were added in the previous tests, delete them all
                var list = ctx.Genres
                .Where(n => n.GenreName.ToLower().Equals("test genre w6yderkt"))
                .Where(n => n.GenreID > 1000);

                ctx.Genres.RemoveRange(list);
                int count = ctx.SaveChanges();
                Assert.IsTrue(count > 0, "No Record Deleted");

                //Test clean-up (none)

            }
        }
开发者ID:WA4OSH,项目名称:CsharpCapstone,代码行数:26,代码来源:UnitTestGenre.cs

示例7: Movie

 public Movie()
 {
     Genres = new Genre[0];
     ProductionCompanies = new ProductionCompanyInfo[0];
     ProductionCountries = new Country[0];
     SpokenLanguages = new Language[0];
 }
开发者ID:Rhada,项目名称:TheMovieDbWrapper,代码行数:7,代码来源:Movie.cs

示例8: TestGenreAdd

        public void TestGenreAdd()
        {
            //create a new context
            using (var ctx = new CDCatalogEntities())
            {
                //Test init

                //Create a test genre
                Genre g = new Genre();
                g.GenreID = 0;  // auto incremented and set by add
                g.GenreName = "Test Genre W6YderKT";
                //add it to the context
                ctx.Genres.Add(g);
                //verify that records were changed
                int count = ctx.SaveChanges();
                Assert.IsTrue(count > 0 && g.GenreID > 0, "No Records Changed");

                //Test clean-up
                if (count > 0)
                {
                    var list = ctx.Genres
                        .Where(n => n.GenreName.ToLower().Equals("test genre w6yderkt"))
                        .Where(n => n.GenreID > 0);

                    ctx.Genres.RemoveRange(list);
                    ctx.SaveChanges();
                }
            }
        }
开发者ID:WA4OSH,项目名称:CsharpCapstone,代码行数:29,代码来源:UnitTestGenre.cs

示例9: GetGenres

		public async Task<Genre> GetGenres( CancellationToken cancellationToken )
		{
			if( _genres == null )
			{
				DateTime cacheModificationDate = await _dataCacheService.GetItemModificationDate( CacheItemName );

				if( (DateTime.Now - cacheModificationDate) < TimeSpan.FromDays( CacheAgeInDays ) )
				{
					try
					{
						_genres = _dataCacheService.GetItem<Genre>( CacheItemName );
					}
					catch (Exception ex)
					{
					    Debug.WriteLine(ex.Message);
					}
				}

				if( _genres == null )
				{
					_genres = await _client.GetGenres( cancellationToken );

					_dataCacheService.PutItem<Genre>( _genres, CacheItemName, cancellationToken );
				}
			}

			return _genres;
		}
开发者ID:Korshunoved,项目名称:Win10reader,代码行数:28,代码来源:GenresProvider.cs

示例10: Create

        public Story Create(string storyName, string creatorId, IEnumerable<string> genreNames)
        {
            var existingGenres = this.genreRepository.All()
                .Where(x => genreNames.Contains(x.Name))
                .ToList();

            foreach (var genre in genreNames)
            {
                if (!existingGenres.AsQueryable().Select(x => x.Name).Contains(genre))
                {
                    var newGenre = new Genre
                    {
                        Name = genre
                    };

                    existingGenres.Add(newGenre);
                    this.genreRepository.Add(newGenre);
                }
            }

            this.genreRepository.Save();

            var story = new Story
            {
                AuthorId = creatorId,
                Name = storyName,
                Genres = existingGenres
            };

            this.storyRepository.Add(story);
            this.storyRepository.Save();

            return this.storyRepository.All()
                .FirstOrDefault(x => x.Name == story.Name);
        }
开发者ID:newmast,项目名称:Steep,代码行数:35,代码来源:StoryService.cs

示例11: AddGenre

 public void AddGenre(GenreDto dto)
 {
     Genre entity = new Genre();
     entity.Name = dto.Name;
     _genreRepository.Add(entity);
     _genreRepository.Save();
 }
开发者ID:oliverdanilov,项目名称:eMovie,代码行数:7,代码来源:GenreService.cs

示例12: delete

        public static Boolean delete(Genre genre)
        {
            Boolean isDelete = false;
            //Connection
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["EntretienSPPPConnectionString"];
            SqlConnection connection = new SqlConnection(connectionStringSettings.ToString());

            String requete = @"DELETE FROM genre WHERE Identifiant = @Identifiant ; ";

            SqlCommand commande = new SqlCommand(requete, connection);

            commande.Parameters.AddWithValue("Identifiant", genre.Identifiant);

            try
            {
                connection.Open();
                commande.ExecuteNonQuery();
                isDelete = true;
            }

            catch (Exception)
            {
                isDelete = false;
            }

            finally
            {
                connection.Close();
            }

            return isDelete;
        }
开发者ID:GroupeStageSPPP,项目名称:STAGE,代码行数:32,代码来源:GenreDB.cs

示例13: Author

 public Author(string aFirstName, string aLastName, Genre aGenre)
     : this()
 {
     FirstName = aFirstName;
     LastName = aLastName;
     Genre = aGenre;
 }
开发者ID:Zigi34,项目名称:SquirrelReaderDiary,代码行数:7,代码来源:Author.cs

示例14: OnRoomMusicChange

 public void OnRoomMusicChange(Genre roomGenre)
 {
     foreach (IMusicEventListener listener in IterateListeners<IMusicEventListener>())
     {
         listener.OnRoomMusicChange(roomGenre);
     }
 }
开发者ID:Awesome-MQP,项目名称:Storybook,代码行数:7,代码来源:MusicEventDispatcher.cs

示例15: Create

        public IActionResult Create(
            string title,
            Genre genre,
            DateTime releaseDate,
            string description,
            decimal price,
            bool preorder)
        {
            var modifiedReleaseDate = releaseDate;
            if (releaseDate == null)
            {
                modifiedReleaseDate = DateTime.Today;
            }

            var movie = new Movie
            {
                Title = title,
                Genre = genre,
                ReleaseDate = modifiedReleaseDate,
                Description = description,
                Price = price,
                Preorder = preorder,
            };

            TryValidateModel(movie);
            if (ModelState.IsValid)
            {
                _context.AddMovie(movie);
                _context.SaveChanges();

                return RedirectToAction(actionName: nameof(Index));
            }

            return View(movie);
        }
开发者ID:CIPop,项目名称:Docs,代码行数:35,代码来源:MoviesController.cs


注:本文中的Genre类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。