Beispiel #1
0
        private void InitPredefinedFieldValues()
        {
            PredefinedFieldValues = new List <InsertFieldViewModel>
            {
                // Basic
                InsertFieldViewModel.Create(Container, "Name", "System.String", "Bare name, without suffix.", "Sample"),
                InsertFieldViewModel.Create(Container, "ViewSuffix", "System.String", "The view suffix.", "View"),
                InsertFieldViewModel.Create(Container, "ViewModelSuffix", "System.String", "The view model suffix.", "ViewModel"),

                // View
                InsertFieldViewModel.Create(Container, "ViewName", "System.String", "The view class.", "SampleView"),
                InsertFieldViewModel.Create(Container, "ViewNamespace", "System.String", "The view namespace.", "SampleProject.Views"),
                InsertFieldViewModel.Create(Container, "ViewFullName", "System.String", "Full name of view class, including namespace.", "SampleProject.Views.SampleView"),
                InsertFieldViewModel.Create(Container, "XamlFilePath", "System.String", "Full path of the xaml file.", "C:\\source\\SampleSolution\\SampleProject\\Views\\SampleView.xaml"),
                InsertFieldViewModel.Create(Container, "CodeBehindFilePath", "System.String", "Full path of the xaml.cs file.", "C:\\source\\SampleSolution\\SampleProject\\Views\\SampleView.xaml.cs"),

                // View Model
                InsertFieldViewModel.Create(Container, "ViewModelName", "System.String", "The view model class.", "SampleViewModel"),
                InsertFieldViewModel.Create(Container, "ViewModelNamespace", "System.String", "The view model namespace.", "SampleProject.ViewModels"),
                InsertFieldViewModel.Create(Container, "ViewModelFullName", "System.String", "Full name of view model class, including namespace.", "SampleProject.ViewModels.SampleViewModel"),
                InsertFieldViewModel.Create(Container, "ViewModelFilePath", "System.String", "Full path of the view model class file.", "C:\\source\\SampleSolution\\SampleProject\\Views\\SampleViewModel.cs"),
            };
        }
Beispiel #2
0
        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(Container, 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(Container, "Name", "System.String", "Bare name, without suffix.", Name));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "OrgSubfolfer", "System.String", "Organizational subfolder (optional).", SubLocation));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "ViewSuffix", "System.String", "The view suffix.", SelectedViewSuffix));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "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(Container, "ViewName", "System.String", "The view class.", name));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "ViewNamespace", "System.String", "The view namespace.", @namespace));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "ViewFullName", "System.String", "Full name of view class, including namespace.", fullName));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "XamlFilePath", "System.String", "Full path of the xaml file.", Path.Combine(path, name + ".xaml")));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "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(Container, "ViewModelName", "System.String", "View model class.", name));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "ViewModelNamespace", "System.String", "View model namespace.", @namespace));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "ViewModelFullName", "System.String", "Full name of view model class, including namespace.", fullName));
            _predefinedFields.Add(InsertFieldViewModel.Create(Container, "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(Container, f.Name, type, f.Description, val));
            }
        }