Example #1
0
 /// <summary>
 /// 获取DriverOrderPrint单例
 /// </summary>
 /// <returns></returns>
 public static DriverOrderPrint GetInstance(string printerName, string paperName, string paperType)
 {
     if (string.IsNullOrEmpty(printerName))
     {
         throw new ArgumentNullException("Printer name is null.");
     }
     if (string.IsNullOrEmpty(paperName))
     {
         throw new ArgumentNullException("Paper name is null.");
     }
     if (string.IsNullOrEmpty(paperType))
     {
         throw new ArgumentNullException("Paper type is null.");
     }
     lock (Obj)
     {
         string           key = printerName + "_" + paperName + "_" + paperType;
         DriverOrderPrint instance;
         if (DicInstance.ContainsKey(key))
         {
             instance = DicInstance[key];
         }
         else
         {
             instance = new DriverOrderPrint(printerName, paperName, paperType);
             DicInstance.Add(key, instance);
         }
         return(instance);
     }
 }
 /// <summary>
 /// 获取DriverOrderPrint单例
 /// </summary>
 /// <returns></returns>
 public static DriverOrderPrint GetInstance(string printerName, string paperName, string paperType)
 {
     if (string.IsNullOrEmpty(printerName))
     {
         throw new ArgumentNullException("Printer name is null.");
     }
     if (string.IsNullOrEmpty(paperName))
     {
         throw new ArgumentNullException("Paper name is null.");
     }
     if (string.IsNullOrEmpty(paperType))
     {
         throw new ArgumentNullException("Paper type is null.");
     }
     lock (Obj)
     {
         string key = printerName + "_" + paperName + "_" + paperType;
         DriverOrderPrint instance;
         if (DicInstance.ContainsKey(key))
         {
             instance = DicInstance[key];
         }
         else
         {
             instance = new DriverOrderPrint(printerName, paperName, paperType);
             DicInstance.Add(key, instance);
         }
         return instance;
     }
 }