Esempio n. 1
0
 private bool remove(IOType type)
 {
     if (type == IOType.Protocol)
     {
         throw new Exception("Cannot remove Protocol as IOType");
     }
     if (ioDictionary.ContainsKey(type))
     {
         TECIO io = ioDictionary[type];
         io.Quantity--;
         if (io.Quantity < 1)
         {
             ioDictionary.Remove(io.Type);
         }
         return(true);
     }
     else
     {
         if (TECIO.PointIO.Contains(type))
         {
             IOType universalType = TECIO.GetUniversalType(type);
             if (ioDictionary.ContainsKey(universalType))
             {
                 TECIO universalIO = ioDictionary[universalType];
                 universalIO.Quantity--;
                 if (universalIO.Quantity < 1)
                 {
                     ioDictionary.Remove(universalIO.Type);
                 }
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 2
0
 public bool Contains(TECIO io)
 {
     if (TECIO.UniversalIO.Contains(io.Type))
     {
         return(ioDictionary.ContainsKey(io.Type) ? ioDictionary[io.Type].Quantity >= io.Quantity : false);
     }
     else if (io.Protocol != null)
     {
         return(protocolDictionary.ContainsKey(io.Protocol) ? protocolDictionary[io.Protocol].Quantity >= io.Quantity : false);
     }
     else if (TECIO.PointIO.Contains(io.Type))
     {
         IOType universalType = TECIO.GetUniversalType(io.Type);
         int    quantity      = ioDictionary.ContainsKey(io.Type) ? ioDictionary[io.Type].Quantity : 0;
         quantity += ioDictionary.ContainsKey(universalType) ? ioDictionary[universalType].Quantity : 0;
         return(quantity >= io.Quantity);
     }
     else
     {
         throw new Exception("IO condition not recognized.");
     }
 }