شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Queue

Public general use code classes and xml files that we've compiled and used over the years:

Queue Support class.

   1:  using System.Collections.Generic;
   2:   
   3:  namespace Ia.Cl.Model.Db
   4:  {
   5:      ////////////////////////////////////////////////////////////////////////////
   6:   
   7:      /// <summary publish="true">
   8:      /// Queue Support class.
   9:      /// </summary>
  10:      /// <remarks> 
  11:      /// Copyright © 2015-2016 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  12:      ///
  13:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  14:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  15:      ///
  16:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  17:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  18:      /// 
  19:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  20:      /// 
  21:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  22:      /// </remarks> 
  23:   
  24:      ////////////////////////////////////////////////////////////////////////////
  25:   
  26:      /// <summary>
  27:      ///
  28:      /// </summary>
  29:      public static class Queue
  30:      {
  31:          private static Dictionary<string, System.Collections.Generic.Queue<string>> queueDictionary = new Dictionary<string, System.Collections.Generic.Queue<string>>();
  32:   
  33:          ////////////////////////////////////////////////////////////////////////////
  34:   
  35:          /// <summary>
  36:          ///
  37:          /// </summary>
  38:          public static void Enqueue(string queueName, string value)
  39:          {
  40:              System.Collections.Generic.Queue<string> q;
  41:   
  42:              if (!string.IsNullOrEmpty(queueName))
  43:              {
  44:                  if (!queueDictionary.ContainsKey(queueName))
  45:                  {
  46:                      q = new Queue<string>();
  47:   
  48:                      queueDictionary[queueName] = q;
  49:                  }
  50:   
  51:                  queueDictionary[queueName].Enqueue(value);
  52:              }
  53:          }
  54:   
  55:          ////////////////////////////////////////////////////////////////////////////
  56:   
  57:          /// <summary>
  58:          ///
  59:          /// </summary>
  60:          public static string Dequeue(string queueName)
  61:          {
  62:              string value;
  63:              //System.Collections.Generic.Queue<string> q;
  64:   
  65:              value = null;
  66:   
  67:              if (!string.IsNullOrEmpty(queueName))
  68:              {
  69:                  if (queueDictionary.ContainsKey(queueName))
  70:                  {
  71:                      value = queueDictionary[queueName].Dequeue();
  72:                  }
  73:              }
  74:   
  75:              return value;
  76:          }
  77:   
  78:          ////////////////////////////////////////////////////////////////////////////
  79:   
  80:          /// <summary>
  81:          ///
  82:          /// </summary>
  83:          public static int Count(string queueName)
  84:          {
  85:              int c;
  86:              //System.Collections.Generic.Queue<string> q;
  87:   
  88:              c = 0;
  89:   
  90:              if (!string.IsNullOrEmpty(queueName))
  91:              {
  92:                  if (queueDictionary.ContainsKey(queueName))
  93:                  {
  94:                      c = queueDictionary[queueName].Count;
  95:                  }
  96:              }
  97:   
  98:              return c;
  99:          }
 100:   
 101:          ////////////////////////////////////////////////////////////////////////////
 102:          ////////////////////////////////////////////////////////////////////////////
 103:      }
 104:   
 105:      ////////////////////////////////////////////////////////////////////////////
 106:      ////////////////////////////////////////////////////////////////////////////
 107:  }
 108: