public void Execute()
{
this.FilesWrittenToGeneratorFolder.Clear();
if (Options.Clean && !Configuration.IsChildConfig)
{
Console.WriteLine(@"-clean option set, deleting previously-generated code under .\Generated subfolders");
Directory.Delete(GeneratedFilesRoot, true);
Directory.CreateDirectory(GeneratedFilesRoot);
}
// .NET Framework 3.5 version
ExecuteGenerator(new ServiceClients(), "Amazon" + Configuration.BaseName + "Client.cs", Bcl35SubFolder);
ExecuteGenerator(new ServiceInterface(), "IAmazon" + Configuration.BaseName + ".cs", Bcl35SubFolder);
// .NET Framework 4.5 version
ExecuteGenerator(new ServiceClients45(), "Amazon" + Configuration.BaseName + "Client.cs", Bcl45SubFolder);
ExecuteGenerator(new ServiceInterface45(), "IAmazon" + Configuration.BaseName + ".cs", Bcl45SubFolder);
// Phone/Rt/Portable version
ExecuteGenerator(new ServiceClientsMobile(), "Amazon" + Configuration.BaseName + "Client.cs", MobileSubFolder);
ExecuteGenerator(new ServiceInterfaceMobile(), "IAmazon" + Configuration.BaseName + ".cs", MobileSubFolder);
if (string.IsNullOrEmpty(Options.SelfServiceModel))
{
//unity version
if (Configuration.SupportedInUnity)
{
ExecuteGenerator(new ServiceInterfaceUnity(), "IAmazon" + Configuration.BaseName + ".cs", UnitySubFolder);
ExecuteGenerator(new ServiceClientUnity(), "Amazon" + Configuration.BaseName + "Client.cs", UnitySubFolder);
}
// Do not generate AssemblyInfo.cs and nuspec file for child model.
// Use the one generated for the parent model.
if (!this.Configuration.IsChildConfig)
{
ExecuteNugetFileGenerators();
if (this.Configuration.EnableXamarinComponent)
GenerateXamarinComponents();
GenerateCodeAnalysisProject();
}
}
if (!this.Configuration.IsChildConfig)
{
ExecuteGeneratorAssemblyInfo();
}
// Client config object
ExecuteGenerator(new ServiceConfig(), "Amazon" + Configuration.BaseName + "Config.cs");
if (Configuration.Namespace == "Amazon.S3")
{
ExecuteProjectFileGenerators();
return;
}
// The top level request that all operation requests are children of
ExecuteGenerator(new BaseRequest(), "Amazon" + Configuration.BaseName + "Request.cs", "Model");
var enumFileName = this.Configuration.IsChildConfig ?
string.Format("ServiceEnumerations.{0}.cs", Configuration.BaseName) : "ServiceEnumerations.cs";
// Any enumerations for the service
this.ExecuteGenerator(new ServiceEnumerations(), enumFileName);
// Do not generate base exception if this is a child model.
// We use the base exceptions generated for the parent model.
if (!this.Configuration.IsChildConfig)
{
this.ExecuteGenerator(new BaseServiceException(), "Amazon" + this.Configuration.BaseName + "Exception.cs");
}
// Generates the Request, Responce, Marshaller, Unmarshaller, and Exception objects for a given client operation
foreach (var operation in Configuration.ServiceModel.Operations)
{
GenerateRequest(operation);
GenerateResponse(operation);
GenerateRequestMarshaller(operation);
GenerateResponseUnmarshaller(operation);
GenerateExceptions(operation);
}
if (Configuration.ServiceModel.Customizations.GenerateCustomUnmarshaller)
{
GenerateUnmarshaller(Configuration.ServiceModel.Customizations.CustomUnmarshaller);
}
// Generate any missed structures that are not defined or referenced by a request, response, marshaller, unmarshaller, or exception of an operation
GenerateStructures();
var fileName = Configuration.LockedApiVersion != null
? string.Format("{0}_{1}_MarshallingTests.cs", Configuration.BaseName, Configuration.LockedApiVersion)
: string.Format("{0}MarshallingTests.cs", Configuration.BaseName);
// Generate tests based on the type of request it is
if (Configuration.ServiceModel.Type == ServiceType.Json)
ExecuteTestGenerator(new JsonMarshallingTests(), fileName);
else if (Configuration.ServiceModel.Type == ServiceType.Query)
{
if (Configuration.ServiceModel.IsEC2Protocol)
ExecuteTestGenerator(new AWSQueryEC2MarshallingTests(), fileName);
else
ExecuteTestGenerator(new AWSQueryMarshallingTests(), fileName);
}
else if (Configuration.ServiceModel.Type == ServiceType.Rest_Xml || Configuration.ServiceModel.Type == ServiceType.Rest_Json)
ExecuteTestGenerator(new RestMarshallingTests(), fileName);
// Test that simple customizations were generated correctly
GenerateCustomizationTests();
ExecuteProjectFileGenerators();
if (this.Configuration.ServiceModel.Customizations.HasExamples)
{
var servicename = Configuration.Namespace.Split('.').Last();
ExecuteExampleGenerator(new ExampleCode(), servicename + ".GeneratedSamples.cs", servicename);
ExecuteExampleGenerator(new ExampleMetadata(), servicename + ".GeneratedSamples.extra.xml");
}
}