public Customer GetCustomer(CustomerIdentifier customerId) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Got message: {0}", customerId.Id); var typeNameSerialzier = new TypeNameSerializer(); Console.WriteLine("Response Type: {0}", typeNameSerialzier.Serialize(typeof(Customer))); Console.WriteLine("Request Type: {0}", typeNameSerialzier.Serialize(typeof(CustomerIdentifier))); Console.ResetColor(); var messageDescription = MessageDescriptionFormat.Json; var translationFileUri = "./Translations/Json/JavascriptTranslations/GetCustomerTranslation.js"; var translationReturnType = typeof(Customer); var configurationJsonUri = "./ServiceConfigurations/GetCustomerConfiguration.json"; // Wrap the message var wrappedMessage = MessageDescription.Create( customerId, messageDescription, translationFileUri, translationReturnType); // Get Params var @params = translationService.GetMessageParts(wrappedMessage); // Known the appropriate Adaptor var adapter = new RestAdapter(); adapter.Initialize(configurationJsonUri, @params); var result = adapter.Send<Customer>(); return result; }
public void AddCustomer(Customer customer) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Got message: {0}", customer.Id); Console.WriteLine("First Name: {0}", customer.Name.FirstName); Console.WriteLine("First Last Name: {0}", customer.Name.LastName); Console.ResetColor(); var messageDescription = MessageDescriptionFormat.Json; var translationFileUri = "./Translations/Json/JavascriptTranslations/CustomerToCustomerTranslation.js"; var translationReturnType = typeof(Customer); var configurationJsonUri = "./ServiceConfigurations/CustomerConfiguration.json"; // Wrap the message var wrappedMessage = MessageDescription.Create( customer, messageDescription, translationFileUri, translationReturnType); // Get Params var @params = translationService.GetMessageParts(wrappedMessage); // Call the translation on customer var translated = translationService.Translate<Customer, Customer>(wrappedMessage); // Known the appropriate Adaptor var adapter = new RestAdapter(); adapter.Initialize(configurationJsonUri); // Send to the Adaptor adapter.SendAsync(translated); }