Beispiel #1
0
        internal static PopulationDataEntry Load(XmlNode iNode)
        {
            PopulationDataEntry RetVal = null;

            if (iNode != null && iNode.Name.Equals("entity"))
            {
                RetVal            = new PopulationDataEntry();
                RetVal.Name       = TambonHelper.GetAttributeOptionalString(iNode, "name").Trim();
                RetVal.English    = TambonHelper.GetAttributeOptionalString(iNode, "english").Trim();
                RetVal.Total      = TambonHelper.GetAttributeOptionalInt(iNode, "total", 0);
                RetVal.Obsolete   = TambonHelper.GetAttributeOptionalBool(iNode, "obsolete", false);
                RetVal.Male       = TambonHelper.GetAttributeOptionalInt(iNode, "male", 0);
                RetVal.Female     = TambonHelper.GetAttributeOptionalInt(iNode, "female", 0);
                RetVal.Households = TambonHelper.GetAttributeOptionalInt(iNode, "households", 0);
                RetVal.Geocode    = TambonHelper.GetAttributeOptionalInt(iNode, "geocode", 0);
                RetVal.GeocodeOfCorrespondingTambon = TambonHelper.GetAttributeOptionalInt(iNode, "tambon", 0);
                RetVal.Comment = TambonHelper.GetAttributeOptionalString(iNode, "comment");
                string lNewGeocode = TambonHelper.GetAttributeOptionalString(iNode, "newgeocode");
                foreach (string lSubString in lNewGeocode.Split(new Char[] { ' ' }))
                {
                    if (!string.IsNullOrEmpty(lSubString))
                    {
                        RetVal.NewGeocode.Add(Convert.ToInt32(lSubString));
                    }
                }
                string s = TambonHelper.GetAttributeOptionalString(iNode, "type");
                if (!String.IsNullOrEmpty(s))
                {
                    RetVal.Type = (EntityType)Enum.Parse(typeof(EntityType), s);
                }
                string lGeocodeParent = TambonHelper.GetAttributeOptionalString(iNode, "parent");
                foreach (string lSubString in lGeocodeParent.Split(new Char[] { ' ' }))
                {
                    if (!string.IsNullOrEmpty(lSubString))
                    {
                        RetVal.GeocodeParent.Add(Convert.ToInt32(lSubString));
                    }
                }
                if (iNode.HasChildNodes)
                {
                    foreach (XmlNode lChildNode in iNode.ChildNodes)
                    {
                        if (lChildNode.Name == "office")
                        {
                            EntityOffice lOffice = EntityOffice.Load(lChildNode);
                            RetVal.Offices.Add(lOffice);
                        }
                        if (lChildNode.Name == "history")
                        {
                            RetVal.ParseHistory(lChildNode);
                        }
                        if (lChildNode.Name == "entity")
                        {
                            RetVal.SubEntities.Add(PopulationDataEntry.Load(lChildNode));
                        }
                        if (lChildNode.Name == "constituencies")
                        {
                            RetVal.ConstituencyList.ReadFromXml(lChildNode);
                        }
                    }
                }
            }
            return(RetVal);
        }
        internal static PopulationDataEntry Load(XmlNode iNode)
        {
            PopulationDataEntry RetVal = null;

            if ( iNode != null && iNode.Name.Equals("entity") )
            {
                RetVal = new PopulationDataEntry();
                RetVal.Name = TambonHelper.GetAttributeOptionalString(iNode, "name").Trim();
                RetVal.English = TambonHelper.GetAttributeOptionalString(iNode, "english").Trim();
                RetVal.Total = TambonHelper.GetAttributeOptionalInt(iNode, "total", 0);
                RetVal.Obsolete = TambonHelper.GetAttributeOptionalBool(iNode, "obsolete", false);
                RetVal.Male = TambonHelper.GetAttributeOptionalInt(iNode, "male", 0);
                RetVal.Female = TambonHelper.GetAttributeOptionalInt(iNode, "female", 0);
                RetVal.Households = TambonHelper.GetAttributeOptionalInt(iNode, "households", 0);
                RetVal.Geocode = TambonHelper.GetAttributeOptionalInt(iNode, "geocode", 0);
                RetVal.GeocodeOfCorrespondingTambon = TambonHelper.GetAttributeOptionalInt(iNode, "tambon", 0);
                RetVal.Comment = TambonHelper.GetAttributeOptionalString(iNode, "comment");
                string lNewGeocode = TambonHelper.GetAttributeOptionalString(iNode, "newgeocode");
                foreach ( string lSubString in lNewGeocode.Split(new Char[] { ' ' }) )
                {
                    if ( !string.IsNullOrEmpty(lSubString) )
                    {
                        RetVal.NewGeocode.Add(Convert.ToInt32(lSubString));
                    }
                }
                string s = TambonHelper.GetAttributeOptionalString(iNode, "type");
                if ( !String.IsNullOrEmpty(s) )
                {
                    RetVal.Type = (EntityType)Enum.Parse(typeof(EntityType), s);
                }
                string lGeocodeParent = TambonHelper.GetAttributeOptionalString(iNode, "parent");
                foreach ( string lSubString in lGeocodeParent.Split(new Char[] { ' ' }) )
                {
                    if ( !string.IsNullOrEmpty(lSubString) )
                    {
                        RetVal.GeocodeParent.Add(Convert.ToInt32(lSubString));
                    }
                }
                if ( iNode.HasChildNodes )
                {
                    foreach ( XmlNode lChildNode in iNode.ChildNodes )
                    {
                        if ( lChildNode.Name == "office" )
                        {
                            EntityOffice lOffice = EntityOffice.Load(lChildNode);
                            RetVal.Offices.Add(lOffice);
                        }
                        if ( lChildNode.Name == "history" )
                        {
                            RetVal.ParseHistory(lChildNode);
                        }
                        if ( lChildNode.Name == "entity" )
                        {
                            RetVal.SubEntities.Add(PopulationDataEntry.Load(lChildNode));
                        }
                        if ( lChildNode.Name == "constituencies" )
                        {
                            RetVal.ConstituencyList.ReadFromXml(lChildNode);
                        }
                    }
                }
            }
            return RetVal;
        }