private void InitPredefinedFieldValues() { PredefinedFieldValues = new List <InsertFieldViewModel> { // Basic InsertFieldViewModel.Create(Kernel, "Name", "System.String", "Bare name, without suffix.", "Sample"), InsertFieldViewModel.Create(Kernel, "ViewSuffix", "System.String", "The view suffix.", "View"), InsertFieldViewModel.Create(Kernel, "ViewModelSuffix", "System.String", "The view model suffix.", "ViewModel"), // View InsertFieldViewModel.Create(Kernel, "ViewName", "System.String", "The view class.", "SampleView"), InsertFieldViewModel.Create(Kernel, "ViewNamespace", "System.String", "The view namespace.", "SampleProject.Views"), InsertFieldViewModel.Create(Kernel, "ViewFullName", "System.String", "Full name of view class, including namespace.", "SampleProject.Views.SampleView"), InsertFieldViewModel.Create(Kernel, "XamlFilePath", "System.String", "Full path of the xaml file.", "C:\\source\\SampleSolution\\SampleProject\\Views\\SampleView.xaml"), InsertFieldViewModel.Create(Kernel, "CodeBehindFilePath", "System.String", "Full path of the xaml.cs file.", "C:\\source\\SampleSolution\\SampleProject\\Views\\SampleView.xaml.cs"), // View Model InsertFieldViewModel.Create(Kernel, "ViewModelName", "System.String", "The view model class.", "SampleViewModel"), InsertFieldViewModel.Create(Kernel, "ViewModelNamespace", "System.String", "The view model namespace.", "SampleProject.ViewModels"), InsertFieldViewModel.Create(Kernel, "ViewModelFullName", "System.String", "Full name of view model class, including namespace.", "SampleProject.ViewModels.SampleViewModel"), InsertFieldViewModel.Create(Kernel, "ViewModelFilePath", "System.String", "Full path of the view model class file.", "C:\\source\\SampleSolution\\SampleProject\\Views\\SampleViewModel.cs"), }; }
private void ResetFieldValuesForAllBuffers() { CustomFieldValues = new List <InsertFieldViewModel>(); foreach (var f in (ObservableCollection <FieldDialogViewModel>)Fields.SourceCollection) { object val; string type; // ReSharper disable once PossibleInvalidOperationException switch (f.SelectedFieldType.Value) { case FieldType.TextBox: case FieldType.TextBoxMultiLine: case FieldType.ComboBox: case FieldType.ComboBoxOpen: case FieldType.Class: val = f.DefaultString; type = "System.String"; break; case FieldType.CheckBox: val = f.DefaultBoolean; type = "System.Boolean"; break; default: throw new ArgumentOutOfRangeException(); } CustomFieldValues.Add(InsertFieldViewModel.Create(Kernel, f.Name, type, f.Description, val)); } View.ResetFieldValues(PredefinedFieldValues, CustomFieldValues); CodeBehindCSharp.ResetFieldValues(PredefinedFieldValues, CustomFieldValues); ViewModelCSharp.ResetFieldValues(PredefinedFieldValues, CustomFieldValues); CodeBehindVisualBasic.ResetFieldValues(PredefinedFieldValues, CustomFieldValues); ViewModelVisualBasic.ResetFieldValues(PredefinedFieldValues, CustomFieldValues); }
private void GetFieldValues() { _predefinedFields = new List <InsertFieldViewModel>(); // Basic _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "Name", "System.String", "Bare name, without suffix.", Name)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "OrgSubfolfer", "System.String", "Organizational subfolder (optional).", SubLocation)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewSuffix", "System.String", "The view suffix.", SelectedViewSuffix)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewModelSuffix", "System.String", "The view model suffix.", ViewModelSuffix)); _viewProject = SolutionService.GetProject(LocationForView.ProjectIdentifier); var projModel = SolutionService.GetFullProjectModel(_viewProject); var name = Name + SelectedViewSuffix; string @namespace; if (LocationForView.Namespace.StartsWith(".")) { @namespace = projModel.RootNamespace + LocationForView.Namespace; } else { @namespace = LocationForView.Namespace; } var path = Path.GetDirectoryName(projModel.FullPath); // ReSharper disable once AssignNullToNotNullAttribute path = Path.Combine(path, LocationForView.PathOffProject); if (!string.IsNullOrEmpty(SubLocation)) { path = Path.Combine(path, SubLocation); @namespace += "." + SubLocation.Replace("/", "."); } var fullName = @namespace + '.' + name; path = path.Replace("/", "\\"); // View _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewName", "System.String", "The view class.", name)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewNamespace", "System.String", "The view namespace.", @namespace)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewFullName", "System.String", "Full name of view class, including namespace.", fullName)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "XamlFilePath", "System.String", "Full path of the xaml file.", Path.Combine(path, name + ".xaml"))); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "CodeBehindFilePath", "System.String", "Full path of the xaml.cs file.", Path.Combine(path, name + ".xaml.cs"))); _viewModelProject = SolutionService.GetProject(LocationForViewModel.ProjectIdentifier); projModel = SolutionService.GetFullProjectModel(_viewModelProject); name = Name + ViewModelSuffix; if (LocationForView.Namespace.StartsWith(".")) { @namespace = projModel.RootNamespace + LocationForViewModel.Namespace; } else { @namespace = LocationForViewModel.Namespace; } path = Path.GetDirectoryName(projModel.FullPath); // ReSharper disable once AssignNullToNotNullAttribute path = Path.Combine(path, LocationForViewModel.PathOffProject); if (!string.IsNullOrEmpty(SubLocation)) { path = Path.Combine(path, SubLocation); @namespace += "." + SubLocation.Replace("/", "."); } fullName = @namespace + '.' + name; path = path.Replace("/", "\\"); // View Model _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewModelName", "System.String", "View model class.", name)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewModelNamespace", "System.String", "View model namespace.", @namespace)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewModelFullName", "System.String", "Full name of view model class, including namespace.", fullName)); _predefinedFields.Add(InsertFieldViewModel.Create(Kernel, "ViewModelFilePath", "System.String", "Full path of the view model class file.", Path.Combine(path, name + ".cs"))); // Custom fields _customFields = new List <InsertFieldViewModel>(); foreach (var f in FieldValues.Fields) { object val; string type; // ReSharper disable once PossibleInvalidOperationException switch (f.SelectedFieldType.Value) { case FieldType.TextBox: case FieldType.TextBoxMultiLine: case FieldType.ComboBox: case FieldType.ComboBoxOpen: case FieldType.Class: val = f.DefaultString; type = "System.String"; break; case FieldType.CheckBox: val = f.DefaultBoolean; type = "System.Boolean"; break; default: throw new ArgumentOutOfRangeException(); } _customFields.Add(InsertFieldViewModel.Create(Kernel, f.Name, type, f.Description, val)); } }