コード例 #1
0
        public PrintersItem AddUniqueItem(string strPrinter)
        {
            if (!string.IsNullOrEmpty(strPrinter) && strPrinter.Trim() != string.Empty)
            {
                var printersItem = new PrintersItem();
                printersItem.Printer = strPrinter.Trim();
                if (Items.Contains(printersItem, new CaseInsensitivePrinterItemComparer <PrintersItem>()))
                {
                    return(Items.FirstOrDefault(i => i.Printer.ToLower() == printersItem.Printer.ToLower()));
                }

                Items.Add(printersItem);
                return(printersItem);
            }
            return(null);
        }
コード例 #2
0
 public override int GetHashCode(PrintersItem obj)
 {
     return(obj.GetHashCode());
 }
コード例 #3
0
 public override bool Equals(PrintersItem x, PrintersItem y)
 {
     return(StringComparer.OrdinalIgnoreCase.Equals(x.Printer.Trim(), y.Printer.Trim()));
 }