コード例 #1
0
        private static JObject CreateAddress(OfficeAddress officeAddress, JObject createResponse, string field)
        {
            if (String.IsNullOrEmpty(officeAddress.City) && String.IsNullOrEmpty(officeAddress.CountryOrRegion) && String.IsNullOrEmpty(officeAddress.PostalCode) &&
                String.IsNullOrEmpty(officeAddress.State) && String.IsNullOrEmpty(officeAddress.Street))
            {
                return(createResponse);
            }

            JObject address = new JObject();

            if (!String.IsNullOrEmpty(officeAddress.Street))
            {
                address["Street"] = officeAddress.Street;
            }
            if (!String.IsNullOrEmpty(officeAddress.State))
            {
                address["State"] = officeAddress.State;
            }
            if (!String.IsNullOrEmpty(officeAddress.PostalCode))
            {
                address["PostalCode"] = officeAddress.PostalCode;
            }
            if (!String.IsNullOrEmpty(officeAddress.CountryOrRegion))
            {
                address["CountryOrRegion"] = officeAddress.CountryOrRegion;
            }
            if (!String.IsNullOrEmpty(officeAddress.City))
            {
                address["City"] = officeAddress.City;
            }

            createResponse[field] = address;

            return(createResponse);
        }
コード例 #2
0
        private string PrintOfficeAddress(OfficeAddress officeAddress)
        {
            if (officeAddress == null)
            {
                return("\n");
            }

            StringBuilder text = new StringBuilder("\n");

            text.AppendLine("\t\"street\": " + officeAddress.Street);
            text.AppendLine("\t\"City\": " + officeAddress.City);
            text.AppendLine("\t\"State\": " + officeAddress.State);
            text.AppendLine("\t\"PostalCode\": " + officeAddress.PostalCode);
            text.AppendLine("\t\"CountryOrRegion\": " + officeAddress.CountryOrRegion);

            return(text.ToString());
        }