public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { string itemName = replacementsDictionary["$rootname$"]; itemName = Regex.Replace(itemName, @"\W?(api)?(service)?(.ts)?$", "", RegexOptions.IgnoreCase); if (string.IsNullOrWhiteSpace(itemName)) { itemName = "service1"; } IEnumerable<string> itemParts = Utilities.Naming.SplitName(itemName); string modelName = Utilities.Naming.ToPascalCase(itemParts); CommonOptionsDialog optionsDialog = new CommonOptionsDialog { Text = "Angular API Service Class Options", ShowDialogs = false }; if (!ShowOptionDialog(optionsDialog, replacementsDictionary)) return; _createFiles = true; //TODO just create from the selected models, should include both load and save // if the model wasn't selected to be included, automatically add it to the imports. It may be incorrect but the sample code requires it. //if (!optionsDialog.SelectedModels.Any(e => e.Name == modelName)) // optionsDialog.SelectedModels.Add(new Utilities.ClassModel() // { // Name = modelName, // ImportPath = Utilities.Path.ImportPath($"{Utilities.Path.ModelsPath(replacementsDictionary)}\\{modelName}.ts") // }); ; CreateOptionalImports(optionsDialog); // the name of the data model replacementsDictionary.Add("$modelName$", modelName); // the plural name of the data model replacementsDictionary.Add("$modelNamePlural$", Utilities.Naming.Pluralize(modelName)); // the name of the data model formatted as a parameter replacementsDictionary.Add("$modelNameAsParameter$", $"{modelName.Substring(0, 1).ToLower()}{modelName.Substring(1)}"); // the name of the class replacementsDictionary.Add("$className$", $"{modelName}ApiService"); // the name of the file replacementsDictionary.Add("$fileName$", $"{string.Join("-", itemParts)}.api-service.ts"); // the name of the file to use when importing replacementsDictionary.Add("$importFileName$", $"{string.Join("-", itemParts)}.api-service"); // the name of the unit test file replacementsDictionary.Add("$specFileName$", $"{string.Join("-", itemParts)}.api-service.spec.ts"); AddCommonReplacements(replacementsDictionary); // additional constructor items replacementsDictionary.Add("$constructorInjects$", _ctorInjections); }
public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { string itemName = replacementsDictionary["$rootname$"]; itemName = Regex.Replace(itemName, @"\W?(dialog)?(component)?(.ts)?$", "", RegexOptions.IgnoreCase); if (string.IsNullOrWhiteSpace(itemName)) { itemName = "component1"; } string fullItemName = itemName + "Dialog"; IEnumerable <string> itemParts = Utilities.Naming.SplitName(itemName); IEnumerable <string> fullItemParts = Utilities.Naming.SplitName(fullItemName); using (CommonOptionsDialog optionsDialog = new CommonOptionsDialog { Text = "Angular Material Dialog Component Options", ShowDialogs = false }) { if (!ShowOptionDialog(optionsDialog, replacementsDictionary)) { return; } _createFiles = true; CreateOptionalImports(optionsDialog); // if they have selected more than one model, could show second custom dialog to select which is input and which is output(?) // the input data type replacementsDictionary.Add("$dataInputModelType$", optionsDialog.SelectedModels.Count == 1 ? optionsDialog.SelectedModels.First().Name : "any"); //TODO how to pull this in common dialog // the output data type, if any replacementsDictionary.Add("$dataOutputModelType$", (optionsDialog.SelectedModels.Count == 1 ? optionsDialog.SelectedModels.First().Name : "any")); //TODO how to pull this in common dialog } // folder name replacementsDictionary.Add("$folderName$", $"{string.Join("-", fullItemParts)}"); // component selector replacementsDictionary.Add("$selector$", $"app-{string.Join("-", fullItemParts)}"); // the name of the class replacementsDictionary.Add("$className$", $"{Utilities.Naming.ToPascalCase(fullItemParts)}Component"); // the name of the files replacementsDictionary.Add("$tsFileName$", $"{string.Join("-", itemParts)}.dialog-component.ts"); replacementsDictionary.Add("$htmlFileName$", $"{string.Join("-", itemParts)}.dialog-component.html"); replacementsDictionary.Add("$cssFileName$", $"{string.Join("-", itemParts)}.dialog-component.{Settings.StylesheetFormat.ToString().ToLower()}"); AddCommonReplacements(replacementsDictionary); // additional constructor items replacementsDictionary.Add("$constructorInjects$", _ctorInjections); }
public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { string itemName = replacementsDictionary["$rootname$"]; itemName = Regex.Replace(itemName, @"\W?(page)?(component)?(.ts)?$", "", RegexOptions.IgnoreCase); if (string.IsNullOrWhiteSpace(itemName)) { itemName = "component1"; } string fullItemName = itemName + "Page"; IEnumerable <string> itemParts = Utilities.Naming.SplitName(itemName); IEnumerable <string> fullItemParts = Utilities.Naming.SplitName(fullItemName); CommonOptionsDialog optionsDialog = new CommonOptionsDialog { Text = "Angular Page Component Options" }; if (!ShowOptionDialog(optionsDialog, replacementsDictionary)) { return; } _createFiles = true; CreateOptionalImports(optionsDialog); // folder name replacementsDictionary.Add("$folderName$", $"{string.Join("-", fullItemParts)}"); // component selector replacementsDictionary.Add("$selector$", $"app-{string.Join("-", fullItemParts)}"); // the name of the class replacementsDictionary.Add("$className$", $"{Utilities.Naming.ToPascalCase(fullItemParts)}Component"); // the name of the files replacementsDictionary.Add("$tsFileName$", $"{string.Join("-", itemParts)}.page-component.ts"); replacementsDictionary.Add("$htmlFileName$", $"{string.Join("-", itemParts)}.page-component.html"); replacementsDictionary.Add("$cssFileName$", $"{string.Join("-", itemParts)}.page-component.{Settings.StylesheetFormat.ToString().ToLower()}"); AddCommonReplacements(replacementsDictionary); // additional constructor items - since we have no default items, remove the initial comma replacementsDictionary.Add("$constructorInjects$", (string.IsNullOrWhiteSpace(_ctorInjections) ? _ctorInjections : _ctorInjections.Substring(1))); }
public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { string itemName = replacementsDictionary["$rootname$"]; itemName = Regex.Replace(itemName, @"\W?(service)?(.ts)?$", "", RegexOptions.IgnoreCase); if (string.IsNullOrWhiteSpace(itemName)) { itemName = "service1"; } IEnumerable <string> itemParts = Utilities.Naming.SplitName(itemName); using (CommonOptionsDialog optionsDialog = new CommonOptionsDialog { Text = "Angular Service Class Options", ShowDialogs = false }) { if (!ShowOptionDialog(optionsDialog, replacementsDictionary)) { return; } _createFiles = true; CreateOptionalImports(optionsDialog); } // the name of the class replacementsDictionary.Add("$className$", $"{Utilities.Naming.ToPascalCase(itemParts)}Service"); // the name of the file replacementsDictionary.Add("$fileName$", $"{string.Join("-", itemParts)}.service.ts"); // the name of the file to use when importing replacementsDictionary.Add("$importFileName$", $"{string.Join("-", itemParts)}.service"); // the name of the unit test file replacementsDictionary.Add("$specFileName$", $"{string.Join("-", itemParts)}.service.spec.ts"); AddCommonReplacements(replacementsDictionary); // additional constructor items - since we have no default items, remove the initial comma replacementsDictionary.Add("$constructorInjects$", (string.IsNullOrWhiteSpace(_ctorInjections) ? _ctorInjections : _ctorInjections.Substring(1))); }