public GeneratorDriver(GeneratorConfig config, string outputDir, string outputDir45, string outputDirRT, string outputDirPortable, string testDirectory) { this.config = config; this.outputDirectory = outputDir; this.outputDirectory45 = outputDir45; this.outputDirectoryRT = outputDirRT; this.outputDirPortable = outputDirPortable; this.testDirectory = testDirectory; }
public GeneratorDriver(GeneratorConfig config, string outputDir, string outputDir45, string outputDirRT, string outputDirPortable, string testDirectory) { this.config = config; this.outputDirectory = outputDir; this.outputDirectory45 = outputDir45; this.outputDirectoryRT = outputDirRT; this.outputDirPortable = outputDirPortable; this.testDirectory = testDirectory; }
/// <summary> /// Sets the properties of a GeneratorConfig for a service model /// </summary> /// <param name="manifestPath">Path to the manifest file to pull basic info from</param> /// <param name="modelsFolder">Path to the service models to be parsed</param> /// <returns></returns> static IEnumerable<GeneratorConfig> LoadGeneratorConfigs(string manifestPath, string modelsFolder) { JsonData document; using (StreamReader reader = new StreamReader(manifestPath)) document = JsonMapper.ToObject(reader); var modelsNode = document["models"]; foreach (JsonData modelNode in modelsNode) { var activeNode = modelNode["active"]; if (activeNode != null && activeNode.IsBoolean && !(bool)activeNode) // skip models with active set to false continue; // A new config that the api generates from var config = new GeneratorConfig { ModelPath = DetermineModelPath(modelNode["model"].ToString(), modelsFolder), // Path to the file servicename-*-.normal.json Namespace = modelNode["namespace"] != null ? modelNode["namespace"].ToString() : null, // Namespace of the service if it's different from basename LockedAPIVersion = modelNode["locked-api-version"] != null ? modelNode["locked-api-version"].ToString() : null, BaseName = modelNode["base-name"].ToString(), // The name that is used as the client name and base request name RegionLookupName = modelNode["region-lookup-name"].ToString(), AuthenticationServiceName = modelNode["authentication-service-name"] != null ? modelNode["authentication-service-name"].ToString() : null, ServiceUrl = modelNode["service-url"] != null ? modelNode["service-url"].ToString() : null, DefaultRegion = modelNode["default-region"] != null ? modelNode["default-region"].ToString() : null, GenerateConstructors = modelNode["generate-client-constructors"] != null ? (bool)modelNode["generate-client-constructors"] : true // A way to prevent generating basic constructors }; if (modelNode["mobile-platforms"] != null && modelNode["mobile-platforms"].IsArray) { IList<string> mobilePlatforms = new List<string>(); foreach (var platform in modelNode["mobile-platforms"]) mobilePlatforms.Add(platform.ToString()); config.SetSupportedMobilePlatforms(mobilePlatforms); } if (modelNode["customization-file"] == null) // Provides a way to specify a customizations file rather than using a generated one config.CustomizationsPath = DetermineCustomizationsPath(modelNode["model"].ToString()); else config.CustomizationsPath = Path.Combine(modelsFolder, modelNode["customization-file"].ToString()); if (modelNode["append-service"] != null && (bool)modelNode["append-service"]) config.BaseName += "Service"; if (modelNode["max-retries"] != null && modelNode["max-retries"].IsInt) config.OverrideMaxRetries = Convert.ToInt32(modelNode["max-retries"].ToString()); yield return config; } }
/// <summary> /// Sets the properties of a GeneratorConfig for a service model /// </summary> /// <param name="manifestPath">Path to the manifest file to pull basic info from</param> /// <param name="modelsFolder">Path to the service models to be parsed</param> /// <returns></returns> static IEnumerable <GeneratorConfig> LoadGeneratorConfigs(string manifestPath, string modelsFolder) { JsonData document; using (StreamReader reader = new StreamReader(manifestPath)) document = JsonMapper.ToObject(reader); var modelsNode = document["models"]; foreach (JsonData modelNode in modelsNode) { var activeNode = modelNode["active"]; if (activeNode != null && activeNode.IsBoolean && !(bool)activeNode) // skip models with active set to false { continue; } // A new config that the api generates from var config = new GeneratorConfig { ModelPath = DetermineModelPath(modelNode["model"].ToString(), modelsFolder), // Path to the file servicename-*-.normal.json Namespace = modelNode["namespace"] != null ? modelNode["namespace"].ToString() : null, // Namespace of the service if it's different from basename LockedAPIVersion = modelNode["locked-api-version"] != null ? modelNode["locked-api-version"].ToString() : null, BaseName = modelNode["base-name"].ToString(), // The name that is used as the client name and base request name RegionLookupName = modelNode["region-lookup-name"].ToString(), AuthenticationServiceName = modelNode["authentication-service-name"] != null ? modelNode["authentication-service-name"].ToString() : null, ServiceUrl = modelNode["service-url"] != null ? modelNode["service-url"].ToString() : null, DefaultRegion = modelNode["default-region"] != null ? modelNode["default-region"].ToString() : null, GenerateConstructors = modelNode["generate-client-constructors"] != null ? (bool)modelNode["generate-client-constructors"] : true // A way to prevent generating basic constructors }; if (modelNode["mobile-platforms"] != null && modelNode["mobile-platforms"].IsArray) { IList <string> mobilePlatforms = new List <string>(); foreach (var platform in modelNode["mobile-platforms"]) { mobilePlatforms.Add(platform.ToString()); } config.SetSupportedMobilePlatforms(mobilePlatforms); } if (modelNode["customization-file"] == null) // Provides a way to specify a customizations file rather than using a generated one { config.CustomizationsPath = DetermineCustomizationsPath(modelNode["model"].ToString()); } else { config.CustomizationsPath = Path.Combine(modelsFolder, modelNode["customization-file"].ToString()); } if (modelNode["append-service"] != null && (bool)modelNode["append-service"]) { config.BaseName += "Service"; } if (modelNode["max-retries"] != null && modelNode["max-retries"].IsInt) { config.OverrideMaxRetries = Convert.ToInt32(modelNode["max-retries"].ToString()); } yield return(config); } }