Esempio n. 1
0
 public RangeRingInfo(RangeRingDisplayValue rrdv)
 {
     this.Name = rrdv.name;
     this.Type = rrdv.type;
     this.IsWeapon = rrdv.isWeapon;
     this.rangeIntensities = new Dictionary<int, int>();// (rrdv.rangeIntensities);
     Console.Write("Ranges: ");
     foreach (int range in rrdv.rangeIntensities.Keys)
     {
         Console.Write("({0}:{1}) ", range, rrdv.rangeIntensities[range]);
         this.rangeIntensities.Add(range, rrdv.rangeIntensities[range]);
     }
     Console.WriteLine();
 }
Esempio n. 2
0
        /// <summary>
        /// Takes an xml string, and returns a DataValue object.
        /// Returns null if the xml doesn't represent a DataValue.
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static DataValue XMLDeserialize(string xml)
        {
            Match m = typeregex.Match(xml);
            if (m.Success)
            {
                Group g = m.Groups[1];

                string dataType = g.ToString();
                switch (dataType)
                {
                    case "StringType":
                        StringValue sv = new StringValue();
                        sv.FromXML(xml);
                        return sv;
                    case "DoubleType":
                        DoubleValue dv = new DoubleValue();
                        dv.FromXML(xml);
                        return dv;
                    case "IntegerType":
                        IntegerValue iv = new IntegerValue();
                        iv.FromXML(xml);
                        return iv;
                    case "BooleanType":
                        BooleanValue bv = new BooleanValue();
                        bv.FromXML(xml);
                        return bv;
                    case "LocationType":
                        LocationValue lv = new LocationValue();
                        lv.FromXML(xml);
                        return lv;
                    case "VelocityType":
                        VelocityValue vv = new VelocityValue();
                        vv.FromXML(xml);
                        return vv;
                    case "AttributeCollectionType":
                        AttributeCollectionValue av = new AttributeCollectionValue();
                        av.FromXML(xml);
                        return av;
                    case "CustomAttributesType":
                        CustomAttributesValue cav = new CustomAttributesValue();
                        cav.FromXML(xml);
                        return cav;
                    case "StringListType":
                        StringListValue slv = new StringListValue();
                        slv.FromXML(xml);
                        return slv;
                    case "PolygonType":
                        PolygonValue polyv = new PolygonValue();
                        polyv.FromXML(xml);
                        return polyv;
                    case "StateTableType":
                        StateTableValue stv = new StateTableValue();
                        stv.FromXML(xml);
                        return stv;
                    case "CapabilityType":
                        CapabilityValue cv = new CapabilityValue();
                        cv.FromXML(xml);
                        return cv;
                    case "VulnerabilityType":
                        VulnerabilityValue vv2 = new VulnerabilityValue();
                        vv2.FromXML(xml);
                        return vv2;
                    case "ConeType":
                        ConeValue cv2 = new ConeValue();
                        cv2.FromXML(xml);
                        return cv2;
                    case "SensorType":
                        SensorValue sv2 = new SensorValue();
                        sv2.FromXML(xml);
                        return sv2;
                    case "SensorArrayType":
                        SensorArrayValue sav = new SensorArrayValue();
                        sav.FromXML(xml);
                        return sav;
                    case "EmitterType":
                        EmitterValue ev = new EmitterValue();
                        ev.FromXML(xml);
                        return ev;
                    case "RangeRingDisplayType":
                        RangeRingDisplayValue rrdv = new RangeRingDisplayValue();
                        rrdv.FromXML(xml);
                        return rrdv;
                    case "AttackCollectionType":
                        AttackCollectionValue attCV = new AttackCollectionValue();
                        attCV.FromXML(xml);
                        return attCV;
                    case "WrapperType":
                        WrapperValue wrapper = new WrapperValue();
                        wrapper.FromXML(xml);
                        return wrapper;
                    case "ClassificationDisplayRulesType":
                        ClassificationDisplayRulesValue cdrv = new ClassificationDisplayRulesValue();
                        cdrv.FromXML(xml);
                        return cdrv;
                    default:
                        return null;
                }
            }
            else
            {
                return null;
            }

        }
Esempio n. 3
0
        /// <summary>
        /// A helper method for building and populating a RangeRingDisplayValue object.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="isWeapon"></param>
        /// <param name="rangeIntensities"></param>
        /// <returns></returns>
        public static DataValue BuildRangeRingDisplayValue(string name, string type, bool isWeapon, Dictionary<int, int> rangeIntensities)
        {
            DataValue rrdv = new RangeRingDisplayValue() as DataValue;
            ((RangeRingDisplayValue)rrdv).name = name;
            ((RangeRingDisplayValue)rrdv).type = type;
            ((RangeRingDisplayValue)rrdv).isWeapon = isWeapon;
            ((RangeRingDisplayValue)rrdv).rangeIntensities = new Dictionary<int,int>();

            foreach (KeyValuePair<int, int> kvp in rangeIntensities)
            {
                ((RangeRingDisplayValue)rrdv).rangeIntensities.Add(kvp.Key, kvp.Value);
            }
            return rrdv;
        }