Пример #1
0
        /// <summary>
        /// Retrieves the definition of a species
        /// </summary>
        /// <returns></returns>
        public override pSpeciesType pGetSpecies()
        {
            //     Dictionary<string, pStateBody> states = new Dictionary<string, pStateBody>();
            //Dictionary<string, object> parameters;
            string name = "Unknown Species";
            pStateBody ff;
            pSpeciesType species = new pSpeciesType();

            try
            {
                reader.Read();
                name = pGetString();

                species.Name = name;
                species.BasedOn = pGetString();


                if ("Size" == reader.Name)
                {
                    species.Size = pGetDouble();
                }


                if ("IsWeapon" == reader.Name)
                {
                    species.IsWeapon = pGetBoolean();
                }
                if ("RemoveOnDestruction" == reader.Name)
                {
                    species.RemoveOnDestruction = pGetBoolean();
                }
                if ("DefaultClassification" == reader.Name)
                {
                    species.DefaultClassification = pGetString();
                }
                //species.ClassificationDisplayRules = new ClassificationDisplayRulesValue();
                if ("ClassificationDisplayRules" == reader.Name)
                {
                    species.ClassificationDisplayRules = pGetClassificationDisplayRules();
                }
                if ("CanOwn" == reader.Name)
                {
                    species.AddOwners(pGetStringList(commaRegex));
                }
                if ("LaunchedByOwner" == reader.Name)
                {
                    species.LaunchedByOwner = pGetBoolean();
                }
                //if ("SubplatformLimit" == reader.Name)
               // {
               //     species.SubplatformLimit = pGetInt();
                //}
                String speciesName = String.Empty;
                int speciesCount = 0;
                while ("SubplatformCapacity" == reader.Name)
                {
                    reader.Read();
                    if ("SpeciesName" == reader.Name)
                    {
                        speciesName = pGetString();
                    }
                    if ("Count" == reader.Name)
                    {
                        speciesCount = pGetInt();
                    }
                    species.AddSubplatformCapacity(speciesName, speciesCount);

                    reader.ReadEndElement();
                }

                if (reader.Name != "FullyFunctional")
                {
                    throw new ApplicationException("State FullyFunctional missing from species "
                        + species.Name);
                }
                reader.Read();

                ff = pGetStateBody(false);// Icon had been required
                species.States["FullyFunctional"] = ff;
                reader.ReadEndElement();

                while ("DefineState" == reader.Name)
                {
                    reader.Read();
                    if ("State" != reader.Name)
                    {
                        throw new ApplicationException("State name missing from state definition for species " + name);
                    }
                    {
                        pStateType s = pGetState();
                        species.States[s.Name] = s.Body;
                        reader.ReadEndElement(); // this is the </DefineState>

                    }

                }



                reader.ReadEndElement();
            }
            catch (System.Exception e)
            {
                throw new ApplicationException("Error reading Species named " +
                    name + ": ", e);
            }

            return species;
        }
Пример #2
0
        /// <summary>
        /// Retrieves the definition of a species
        /// </summary>
        /// <returns></returns>
        public override pSpeciesType pGetSpecies()
        {
            //     Dictionary<string, pStateBody> states = new Dictionary<string, pStateBody>();
            //Dictionary<string, object> parameters;
            string name = "Unknown Species";
            pStateBody ff;
            pSpeciesType species = new pSpeciesType();

            try
            {
                reader.Read();
                name = pGetString();

                species.Name = name;
                species.BasedOn = pGetString();


                if ("Size" == reader.Name)
                {
                    species.Size = pGetDouble();
                }


                if ("IsWeapon" == reader.Name)
                {
                    species.IsWeapon = pGetBoolean();
                }
                if ("RemoveOnDestruction" == reader.Name)
                {
                    species.RemoveOnDestruction = pGetBoolean();
                }

                if (reader.Name != "FullyFunctional")
                {
                    throw new ApplicationException("State FullyFunctional missing from species "
                        + species.Name);
                }
                reader.Read();

                ff = pGetStateBody(false);// Icon had been required
                species.States["FullyFunctional"] = ff;
                reader.ReadEndElement();

                while ("DefineState" == reader.Name)
                {
                    reader.Read();
                    if ("State" != reader.Name)
                    {
                        throw new ApplicationException("State name missing from state definition for species " + name);
                    }
                    {
                        pStateType s = pGetState();
                        species.States[s.Name] = s.Body;
                        reader.ReadEndElement(); // this is the </DefineState>

                    }

                }



                reader.ReadEndElement();
            }
            catch (System.Exception e)
            {
                throw new ApplicationException("Error reading Species named " +
                    name + ": ", e);
            }

            return species;
        }