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


C# List.Contains方法代码示例

本文整理汇总了C#中Entities.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# List.Contains方法的具体用法?C# List.Contains怎么用?C# List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entities.List的用法示例。


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

示例1: ProcessCss

        /// <summary>
        /// Processes and returns a list of images in the CSS file.
        /// </summary>
        /// <param name="downloadString"></param>
        /// <param name="sourceUrl"></param>
        /// <param name="alreadyProcessed"></param>
        public List<SquishedImage> ProcessCss(string downloadString, string sourceUrl, ref List<string> alreadyProcessed)
        {
            IEnumerable<string> imagesInCssString = new List<string>();

            // Retrieve the Css files from the html string
            List<string> extractedCss = _utils.ExtractCssHrefFromHtmlString(downloadString);

            // Loop through the extracted Css and process
            foreach (string cssFile in extractedCss)
            {
                if (_commonUtils.IsValidCssExtension(cssFile))
                {
                    if (!alreadyProcessed.Contains(cssFile))
                    {
                        // Add to already processed list
                        alreadyProcessed.Add(cssFile);

                        // TODO: Fix this
                        List<string> extractImagesFromCssFile = _utils.ExtractImagesFromCssFile(cssFile, sourceUrl);

                        // Join the new list with the existing image list.
                        imagesInCssString = extractImagesFromCssFile.Union(imagesInCssString);
                    }
                }
            }

            // Send the images through to Smush.it
            List<SquishedImage> images = new List<SquishedImage>();
            foreach (var imagePath in imagesInCssString)
            {
                images.Add(ProcessSingleImage(imagePath, sourceUrl, false));
            }

            return images;
        }
开发者ID:deanhume,项目名称:SmushMySite,代码行数:41,代码来源:SmushLogic.cs

示例2: AddBook

        /// <summary>
        /// Adds new book in repository(if it was not there)
        /// </summary>
        /// <param name="book">Some new book</param>
        public void AddBook(Book book)
        {
            try
            {
                if (book == null)
                    throw new ArgumentNullException("Book is null");

                books = repository.LoadToList();
                if (books.Contains(book))
                    throw new ArgumentException("Book is already in booklist");
                else
                {
                    books.Add(book);
                    logger.Info("Book was added successfully");
                    repository.LoadToFile(books);
                }
            }
            catch (Exception e)
            {
                logger.Info(e.Message);
                logger.Error(e.StackTrace);
            }
        }
开发者ID:zzhukanton,项目名称:BSU.ASP1501.Day5.Zhuk,代码行数:27,代码来源:BookList.cs

示例3: GetHeroByNames

 public IEnumerable<Hero> GetHeroByNames(List<string> names)
 {
     return _context.Heroes.Where(x => names.Contains(x.Name));
 }
开发者ID:Lulubul,项目名称:Server,代码行数:4,代码来源:HeroesRepository.cs

示例4: RemoveBook

        /// <summary>
        /// Removes some book from repository (if this book was there)
        /// </summary>
        /// <param name="book">Some book to remove</param>
        public void RemoveBook(Book book)
        {
            try
            {
                if (book == null)
                    throw new ArgumentException("Book is null");

                books = repository.LoadToList();
                if (!books.Contains(book))
                    throw new ArgumentException("There is no this book in booklist");
                else
                {
                    books.Remove(book);
                    logger.Info("Book was removed successfully");
                    repository.LoadToFile(books);
                }
            }
            catch (Exception e)
            {
                logger.Info(e.Message);
                logger.Error(e.StackTrace);
            }
        }
开发者ID:zzhukanton,项目名称:BSU.ASP1501.Day5.Zhuk,代码行数:27,代码来源:BookList.cs

示例5: GetQueryExp

        private Expression<Func<SalesOrder, bool>> GetQueryExp(int companyId, int customerId, int commodityId, int commodityTypeId, int brandId, int warsehouseId, int status, DateTime? startDate, DateTime? endDate, List<int> listCommodity, List<int> listCompany)
        {
            var clauses = new List<Clause>();
            if (customerId != 0)
            {
                clauses.Add(new Clause
                {
                    PropertyName = "CompanyId",
                    Operator = Operator.Eq,
                    Value = customerId
                });
            }

            if (companyId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.CompanyId",
                    Value = companyId
                });
            }

            if (commodityId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.CommodityId",
                    Value = commodityId
                });
            }

            if (commodityTypeId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.CommodityTypeId",
                    Value = commodityTypeId
                });
            }

            if (brandId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.BrandId",
                    Value = brandId
                });
            }

            if (warsehouseId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.WarehouseId",
                    Value = warsehouseId
                });
            }

            if (status != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Status",
                    Value = status
                });
            }

            if (startDate.HasValue)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Ge,
                    PropertyName = "Date",
                    PropertyType = typeof(DateTime),
                    Value = startDate.Value
                });
            }

            if (endDate.HasValue)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Le,
                    PropertyName = "Date",
                    PropertyType = typeof(DateTime),
                    Value = endDate.Value
                });
            }

            var manager = new QueryManager<SalesOrder>();
            return manager.Compile(clauses, o => listCompany.Contains(o.Stock.CompanyId) && listCommodity.Contains(o.Stock.CommodityId));
        }
开发者ID:jesusblessf6,项目名称:Maike,代码行数:98,代码来源:SalesOrderService.cs

示例6: mostRentedBook

 public static List<Kitap> mostRentedBook(DateTime First, DateTime Last)
 {
     List<Kitap> Value = new List<Kitap>();
     SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
     String CommandString = "select KitapID,COUNT(KitapID) as KiralamaSayisi from dbo.Kiralama" +
         " join dbo.KiralamaDetay on Kiralama.ID = KiralamaDetay.ID" +
         " where KiralamaDetay.KiralamaTarihi between";
     CommandString += " '" + convertToSqlDate(First.ToShortDateString()) + "' and";
     CommandString += " '" + convertToSqlDate(Last.ToShortDateString()) + "' group by KitapID";
     CommandString += " order by KiralamaSayisi desc";
     SqlCommand cmd = new SqlCommand(CommandString, con);
     con.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     int max = 0;
     List<int> Kitaplar = new List<int>();
     if (reader.Read())
     {
         max = reader.GetInt32(1);
         Kitaplar.Add(reader.GetInt32(0));
     }
     while (reader.Read())
     {
         int currentCount = reader.GetInt32(1);
         if (currentCount == max)
         {
             Kitaplar.Add(reader.GetInt32(0));
         }
         else if (currentCount < max)
         {
             break;
         }
     }
     reader.Close();
     con.Close();
     if (Kitaplar.Count > 0)
     {
         CommandString = "select * from dbo.Kitap where ";
         foreach (int item in Kitaplar)
         {
             CommandString += "ID=" + item.ToString() + " or ";
         }
         CommandString = CommandString.Remove(CommandString.Length - 4);
         cmd = new SqlCommand(CommandString, con);
         con.Open();
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             int id = reader.GetInt32(0);
             SqlConnection AuthorCon = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
             SqlCommand AuthorCmd = new SqlCommand("select YazarID from dbo.KitapYazar where KitapID = " + id.ToString(), AuthorCon);
             AuthorCon.Open();
             SqlDataReader AuthorReader = AuthorCmd.ExecuteReader();
             List<Yazar> YazarList = new List<Yazar>();
             while (AuthorReader.Read())
             {
                 YazarList.Add(YazarIslemleri.getAuthor(AuthorReader.GetInt32(0)));
             }
             AuthorReader.Close();
             AuthorCon.Close();
             Yazar[] Yazarlar = null;
             if (YazarList.Count > 0)
             {
                 Yazarlar = new Yazar[YazarList.Count];
                 YazarList.CopyTo(Yazarlar);
             }
             Yayinevi Publisher = YayineviIslemleri.getPublisher(reader.GetInt32(3));
             Kategori Category = KategoriIslemleri.getCategory(reader.GetInt32(4));
             Kitap Current = new Kitap(id, reader.GetString(1), int.Parse(reader.GetString(2)), Yazarlar, Publisher, Category,
                 reader.GetInt32(5), reader.GetBoolean(7), reader.GetBoolean(6), reader.GetDecimal(8));
             try
             {
                 Current.Ozet = reader.GetString(9);
             }
             catch (SqlNullValueException snve)
             {
                 Current.Ozet = "";
             }
             try
             {
                 Current.Kapak = reader.GetString(10);
             }
             catch (SqlNullValueException snve)
             {
                 Current.Kapak = "";
             }
             if (!Value.Contains(Current))
             {
                 Value.Add(Current);
             }
         }
         reader.Close();
         con.Close();
     }
     return Value;
 }
开发者ID:ErelOzcakirlar,项目名称:KutuphaneOtomasyon,代码行数:95,代码来源:RaporIslemleri.cs

示例7: search

 public static List<Kitap> search(string kitapAdi, Yazar[] yazarlar, int[] yillar)
 {
     List<Kitap> Value = new List<Kitap>();
     SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
     String CommandString = "select ID,Adi,BasimYili,YayineviID,KategoriID,SayfaSayisi,HasarDurumu,KiralamaDurumu,Ucret,Ozet,Kapak ";
     CommandString += "from dbo.Kitap join dbo.KitapYazar on dbo.Kitap.ID = dbo.KitapYazar.KitapID where ";
     CommandString += "(Adi like '%" + kitapAdi + "%') and (";
     int counter = 0;
     foreach (Yazar item in yazarlar)
     {
         if (item.ID != 0)
         {
             CommandString += "dbo.KitapYazar.YazarID=" + item.ID.ToString() + " or ";
             counter++;
         }
     }
     if (counter > 0)
     {
         CommandString = CommandString.Remove(CommandString.Length - 4);
         CommandString += ") and (";
     }
     foreach (int item in yillar)
     {
         CommandString += "dbo.Kitap.BasimYili='" + item.ToString() + "' or ";
     }
     CommandString = CommandString.Remove(CommandString.Length - 4);
     CommandString += ")";
     SqlCommand cmd = new SqlCommand(CommandString, con);
     con.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     while (reader.Read())
     {
         int id = reader.GetInt32(0);
         SqlConnection AuthorCon = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
         SqlCommand AuthorCmd = new SqlCommand("select YazarID from dbo.KitapYazar where KitapID = " + id.ToString(), AuthorCon);
         AuthorCon.Open();
         SqlDataReader AuthorReader = AuthorCmd.ExecuteReader();
         List<Yazar> YazarList = new List<Yazar>();
         while (AuthorReader.Read())
         {
             YazarList.Add(YazarIslemleri.getAuthor(AuthorReader.GetInt32(0)));
         }
         AuthorReader.Close();
         AuthorCon.Close();
         Yazar[] Yazarlar = null;
         if (YazarList.Count > 0)
         {
             Yazarlar = new Yazar[YazarList.Count];
             YazarList.CopyTo(Yazarlar);
         }
         Yayinevi Publisher = YayineviIslemleri.getPublisher(reader.GetInt32(3));
         Kategori Category = KategoriIslemleri.getCategory(reader.GetInt32(4));
         Kitap Current = new Kitap(id, reader.GetString(1), int.Parse(reader.GetString(2)), Yazarlar, Publisher, Category,
             reader.GetInt32(5), reader.GetBoolean(7), reader.GetBoolean(6), reader.GetDecimal(8));
         try
         {
             Current.Ozet = reader.GetString(9);
         }
         catch (SqlNullValueException snve)
         {
             Current.Ozet = "";
         }
         try
         {
             Current.Kapak = reader.GetString(10);
         }
         catch (SqlNullValueException snve)
         {
             Current.Kapak = "";
         }
         if (!Value.Contains(Current))
         {
             Value.Add(Current);
         }
     }
     reader.Close();
     con.Close();
     return Value;
 }
开发者ID:ErelOzcakirlar,项目名称:KutuphaneOtomasyon,代码行数:79,代码来源:KitapIslemleri.cs

示例8: GetAllTags

        public static List<string> GetAllTags()
        {
            List<string> result = new List<string>();

            List<Book> books = GetBooks(0);

            foreach (Book book in books)
                foreach (string tag in book.Tags)
                    if (result.Contains(tag) == false)
                        result.Add(tag);

            return result;
        }
开发者ID:Ozerich,项目名称:labs,代码行数:13,代码来源:Books.cs


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