Beispiel #1
0
        /// <summary>
        /// Gets all templates with simplified keys: testFramework_mockFramework_templateType
        /// </summary>
        /// <returns></returns>
        public IDictionary <string, string> GetAllTemplates()
        {
            var result = new Dictionary <string, string>();

            foreach (TestFramework testFramework in TestFrameworks.List)
            {
                foreach (MockFramework mockFramework in MockFrameworks.List)
                {
                    foreach (TemplateType templateType in Enum.GetValues(typeof(TemplateType)))
                    {
                        string personalTemplateSettingKey = GetPersonalTemplateSettingsKey(testFramework, mockFramework, templateType);
                        if (this.store.PropertyExists(CollectionPath, personalTemplateSettingKey))
                        {
                            string template = this.store.GetString(CollectionPath, personalTemplateSettingKey);
                            if (template != BoilerplateSettings.GetDefaultTemplate(testFramework, mockFramework, templateType))
                            {
                                string normalTemplateSettingKey = BoilerplateSettings.GetTemplateSettingsKey(testFramework, mockFramework, templateType);
                                result.Add(normalTemplateSettingKey, this.store.GetString(CollectionPath, personalTemplateSettingKey));
                            }
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
 public void RevertTemplateToDefault(TestFramework testFramework, MockFramework mockFramework)
 {
     foreach (TemplateType templateType in Enum.GetValues(typeof(TemplateType)))
     {
         string templateSettingKey = BoilerplateSettings.GetTemplateSettingsKey(testFramework, mockFramework, templateType);
         this.jsonObject.Templates.Remove(templateSettingKey);
     }
 }
		public BoilerplateSettingsFactory()
		{
			this.dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
			this.personalSettings = new BoilerplateSettings(this.personalStore);

			SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
			WritableSettingsStore store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
			store.CreateCollection(PersonalBoilerplateSettingsStore.CollectionPath);
			if (store.PropertyExists(PersonalBoilerplateSettingsStore.CollectionPath, UserBoilerplateSettings))
			{
				UserCreatedSettingsPath = store.GetString(PersonalBoilerplateSettingsStore.CollectionPath, UserBoilerplateSettings);
			}
		}
		private void UpdateSettingsFileStore()
		{
			var solution = this.dte.Solution;
			if (solution == null)
			{
				this.ClearSettingsFileStore();
				return;
			}

			string solutionSettingsFileName;
			if (this.LoadUserCreatedSettings && File.Exists(this.UserCreatedSettingsPath))
			{
				solutionSettingsFileName = UserCreatedSettingsPath;
			}
			else if(File.Exists(solution.FullName + WorkspaceSettingsFileSuffix))
			{
				solutionSettingsFileName = solution.FullName + WorkspaceSettingsFileSuffix;
			}
			else
			{
				this.ClearSettingsFileStore();
				return;
			}

			if (this.settingsFileStore != null && solution.FullName == this.settingsFilePath)
			{
				// We are current. Return.
				return;
			}

			try
			{
				// Initialize the new store from that settings file.
				this.settingsFileStore = new WorkspaceBoilerplateSettingsStore(solutionSettingsFileName);
				this.fileSettings = new BoilerplateSettings(this.settingsFileStore);
				this.settingsFilePath = solution.FullName;
			}
			catch
			{
				this.ClearSettingsFileStore();
			}
		}
Beispiel #5
0
        private void UpdateWorkspaceStore()
        {
            var solution = this.dte.Solution;

            if (solution == null)
            {
                this.ClearWorkspaceStore();
                return;
            }

            string solutionSettingsFileName = solution.FullName + WorkspaceSettingsFileSuffix;

            if (!File.Exists(solutionSettingsFileName))
            {
                this.ClearWorkspaceStore();
                return;
            }

            if (this.workspaceStore != null && solution.FullName == this.workspaceStoreSolutionPath)
            {
                // We are current. Return.
                return;
            }

            try
            {
                // Initialize the new store from that settings file.
                this.workspaceStore             = new WorkspaceBoilerplateSettingsStore(solutionSettingsFileName);
                this.workspaceSettings          = new BoilerplateSettings(this.workspaceStore);
                this.workspaceStoreSolutionPath = solution.FullName;
            }
            catch
            {
                this.ClearWorkspaceStore();
            }
        }
Beispiel #6
0
 private static string GetPersonalTemplateSettingsKey(TestFramework testFramework, MockFramework mockFramework, TemplateType templateType)
 {
     return("Template_" + BoilerplateSettings.GetTemplateSettingsKey(testFramework, mockFramework, templateType));
 }
Beispiel #7
0
 private void ClearWorkspaceStore()
 {
     this.workspaceStoreSolutionPath = null;
     this.workspaceStore             = null;
     this.workspaceSettings          = null;
 }
Beispiel #8
0
 public BoilerplateSettingsFactory()
 {
     this.dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
     this.personalSettings = new BoilerplateSettings(this.personalStore);
 }
		public void ClearSettingsFileStore()
		{
			this.settingsFilePath = null;
			this.settingsFileStore = null;
			this.fileSettings = null;
		}