public static string Xmlify(GeographicallyIndependentTerritory geographicallyIndependentTerritory)
        {
            var xml = "";

            xml += "<geographicallyindependentterritory>";
            xml += "<territoryoutline>";
            xml  = geographicallyIndependentTerritory.TerritoryOutline.Aggregate(xml, (current, coordinate) => current + Coordinate.Xmlify(coordinate));
            xml += "</territoryoutline>";
            xml += "</geographicallyindependentterritory>";
            return(xml);
        }
Exemplo n.º 2
0
        public static Country Objectify(string xml)
        {
            var country = Stringy.ExtractSubStringFromBetween(xml, "<country>", "</country>");

            var name       = Stringy.ExtractSubStringFromBetween(country, "<name>", "</name>");
            var alpha2code = Stringy.ExtractSubStringFromBetween(country, "<alpha2code>", "</alpha2code>");
            ColorDifferentiator differentiator = (ColorDifferentiator)Int32.Parse(Stringy.ExtractSubStringFromBetween(country, "<differentiator>", "</differentiator>"));


            var patternCountryoutline = @"<countryoutline>.*?<\/countryoutline>";
            var rCountryoutline       = new Regex(patternCountryoutline);
            var countryoutlineXmls    = (from object match in rCountryoutline.Matches(country) select match.ToString()).ToList();
            var countryOutline        = new List <GeographicallyIndependentTerritory>();

            foreach (var countryOutlineXml in countryoutlineXmls)
            {
                var geographicallyIndependentTerritoryXml = Stringy.ExtractSubStringFromBetween(countryOutlineXml, "<countryoutline>", "</countryoutline>");
                var geographicallyIndependentTerritory    = GeographicallyIndependentTerritory.Objectify(geographicallyIndependentTerritoryXml);
                countryOutline.Add(geographicallyIndependentTerritory);
            }
            return(new Country(name, alpha2code, differentiator, countryOutline));
        }
Exemplo n.º 3
0
        public static string Xmlify(Country country)
        {
            var xml = "";

            xml += "<country>";
            xml += "<name>" + country.Name + "</name>";
            xml += "<alpha2code>" + country.Alpha2Code + "</alpha2code>";
            xml += "<differentiator>" + country.Differentiator + "</differentiator>";
            xml += "<countryoutline>";
            xml  = country.CountryOutline.Aggregate(xml, (current, gibr) => current + GeographicallyIndependentTerritory.Xmlify(gibr));
            xml += "</countryoutline>";
            xml += "</country>";
            return(xml);
        }