Пример #1
0
 public void Add(pProximityType action)
 {
     proximityList.Add(action);
 }
Пример #2
0
        /// <summary>
        /// Retrieves a ist of Capabilities
        /// </summary>
        public override Dictionary<string, pCapabilityType> pGetCapabilities()
        {
            // Entered expecting the current Node to be something that encloses a list
            // of Capability definitions
            pCapabilityType capability;
            Dictionary<string, pCapabilityType> capabilities = new Dictionary<string, pCapabilityType>();
            string capabilityName = "Unknown capability";
            try
            {
                pProximityType proximity;
                double range;
                //          pEffectType effect;
                int intensity;
                double probability = 1;
                while ("Capability" == reader.Name)
                {
                    reader.Read();
                    capabilityName = pGetString();
                    if (capabilities.ContainsKey(capabilityName)) throw new ApplicationException("Cannot have two independent capabilities with same name " + capabilityName);
                    capability = new pCapabilityType();
                    while ("Proximity" == reader.Name)
                    {
                        reader.Read(); // pass the 'Proximity'
                        range = pGetDouble();
                        proximity = new pProximityType(range);
                        while ("Effect" == reader.Name)
                        {
                            reader.Read();
                            intensity = pGetInt();
                            if ("Probability" == reader.Name)
                            {
                                probability = pGetDouble();
                            }
                            proximity.Add(new pEffectType(intensity, probability));
                            reader.ReadEndElement(); // end effect
                        }
                        capability.Add(proximity);
                        reader.ReadEndElement();
                    }
                    capabilities[capabilityName] = capability;

                    reader.ReadEndElement(); // pass the close </capability>
                }
            }
            catch (System.Exception e)
            {
                throw new ApplicationException("Error reading Capability named "
                    + capabilityName + ": ", e);
            }



            return capabilities;
        }