public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { // Get referenced types var dte2 = (DTE2)automationObject; List <Type> modelTypes = GetReferencedTypes(dte2).ToList(); // Prompt user for Entity and DbContext names var dialog = new ModelTypesDialog(modelTypes, "Trackable WCF Service Type", "Add WCF service contract and type with CRUD operations using Trackable Entities."); if (dialog.ShowDialog() == DialogResult.Cancel) { throw new WizardBackoutException(); } string entityNamespace = dialog.ModelTypesInfo.EntityNamespace; string entityName = dialog.ModelTypesInfo.EntityName; string entitySetName = dialog.ModelTypesInfo.EntitySetName; string dbContextName = dialog.ModelTypesInfo.DbContextName; replacementsDictionary.Add("$entityNamespace$", entityNamespace); replacementsDictionary.Add("$entityName$", entityName); replacementsDictionary.Add("$entitySetName$", entitySetName); replacementsDictionary.Add("$dbContextName$", dbContextName); }
public static void AddCustomParameters(object automationObject, Dictionary <string, string> replacementsDictionary, string dialogTitle, string dialogMessage, bool getDbContextName, int dialogWidth) { // Get referenced types var dte2 = (DTE2)automationObject; List <ModelTypeInfo> modelTypes = GetReferencedTypes(dte2).ToList(); const string noEntitiesMessage = "Referenced projects do not contain any {0}." + "\r\nAdd service entities by reverse engineering Code First classes from an existing database, then re-build the solution."; // Check for trackable entities in referenced projects if (modelTypes.Count(t => t.ModelType == ModelType.Trackable) == 0) { MessageBox.Show(string.Format(noEntitiesMessage, "Trackable model classes"), "Trackable Entities Not Found"); throw new WizardBackoutException(); } // Check for DbContext types in referenced projects if (getDbContextName && modelTypes.Count(t => t.ModelType == ModelType.DbContext) == 0) { MessageBox.Show(string.Format(noEntitiesMessage, "DbContext classes"), "DbContext Class Not Found"); throw new WizardBackoutException(); } // Prompt user for Entity and DbContext names Form dialog; if (getDbContextName) { dialog = new ModelTypesContextDialog(modelTypes, dialogTitle, dialogMessage, dialogWidth); } else { dialog = new ModelTypesDialog(modelTypes, dialogTitle, dialogMessage, dialogWidth); } if (dialog.ShowDialog() == DialogResult.Cancel) { throw new WizardBackoutException(); } var modelTypesDialog = ((IModelTypes)dialog); string entityName = modelTypesDialog.ModelTypesDialogInfo.EntityName; string entitySetName = modelTypesDialog.ModelTypesDialogInfo.EntitySetName; string dbContextName = modelTypesDialog.ModelTypesDialogInfo.DbContextName; string baseNamespace = modelTypesDialog.ModelTypesDialogInfo.BaseNamespace; string entitiesNamespace = modelTypesDialog.ModelTypesDialogInfo.EntitiesNamespace; replacementsDictionary.Add("$entityName$", entityName); replacementsDictionary.Add("$entitySetName$", entitySetName); replacementsDictionary.Add("$dbContextName$", dbContextName); replacementsDictionary.Add("$baseNamespace$", baseNamespace); replacementsDictionary.Add("$entitiesNamespace$", entitiesNamespace); }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { // Get referenced types var dte2 = (DTE2)automationObject; List<Type> modelTypes = GetReferencedTypes(dte2).ToList(); // Prompt user for Entity and DbContext names var dialog = new ModelTypesDialog(modelTypes, "Trackable WCF Service Type", "Add WCF service contract and type with CRUD operations using Trackable Entities."); if (dialog.ShowDialog() == DialogResult.Cancel) throw new WizardBackoutException(); string entityNamespace = dialog.ModelTypesInfo.EntityNamespace; string entityName = dialog.ModelTypesInfo.EntityName; string entitySetName = dialog.ModelTypesInfo.EntitySetName; string dbContextName = dialog.ModelTypesInfo.DbContextName; replacementsDictionary.Add("$entityNamespace$", entityNamespace); replacementsDictionary.Add("$entityName$", entityName); replacementsDictionary.Add("$entitySetName$", entitySetName); replacementsDictionary.Add("$dbContextName$", dbContextName); }