Example #1
0
        public Dictionary <string, IDictionary <string, string> > Get()
        {
            var testAddress = new Dictionary <string, IDictionary <string, string> >();

            // Well known canadaian address
            var canadaianAddressFinder = _addressManager.GetAddressFinder("CAN");

            if (canadaianAddressFinder != null)
            {
                var stringAddress = @"ANIRBAN GHOSH
                             Marketing Department
                             10-123 1/2 MAIN ST SE
                             MONTREAL QC   H3Z 2Y7";

                var addressDetails = canadaianAddressFinder.GetAddressFromMultilineString(stringAddress);
                testAddress.Add("CAN", addressDetails);
            }
            else
            {
                throw new HttpRequestException("Please provide a valid country code or country name.");
            }

            // NETHERLANDS address
            var generalAddressFinder1 = _addressManager.GetAddressFinder("NETHERLANDS");

            if (generalAddressFinder1 != null)
            {
                var stringAddress = @"ARJEN ROBBEN
                             ROTERDAM 7B
                             3053  ES ROTTERDAM
                             NETHERLANDS";

                var addressDetails = generalAddressFinder1.GetAddressFromMultilineString(stringAddress);
                testAddress.Add("NETHERLANDS", addressDetails);
            }
            else
            {
                throw new HttpRequestException("Please provide a valid country code or country name.");
            }

            // USA
            var generalAddressFinder2 = _addressManager.GetAddressFinder("USA");

            if (generalAddressFinder2 != null)
            {
                var stringAddress = @"ELON MASK
                             101 W MAIN ST S APT 101
                             WASHINGTON DC 20019-4649
                             USA";

                var addressDetails = generalAddressFinder2.GetAddressFromMultilineString(stringAddress);
                testAddress.Add("USA", addressDetails);
            }
            else
            {
                throw new HttpRequestException("Please provide a valid country code or country name.");
            }

            return(testAddress);
        }