Exemple #1
0
        public ModelingOptionsViewModel(
            IVisualStudioAccess visualStudioAccess,
            Func <IAdvancedModelingOptionsDialog> advancedModelingOptionsDialogFactory)
        {
            this.visualStudioAccess = visualStudioAccess;
            this.advancedModelingOptionsDialogFactory = advancedModelingOptionsDialogFactory;

            Title = string.Empty;
            MayIncludeConnectionString = true;

            OkCommand       = new RelayCommand(Ok_Executed);
            CancelCommand   = new RelayCommand(Cancel_Executed);
            AdvancedCommand = new RelayCommand(Advanced_Executed);

            Model = new ModelingOptionsModel();
            Model.PropertyChanged += Model_PropertyChanged;
            GenerationModeList     = new[]
            {
                ReverseEngineerLocale.EntityTypesAndContext,
                ReverseEngineerLocale.DbContextOnly,
                ReverseEngineerLocale.EntityTypesOnly,
            };
            HandlebarsLanguageList = new[]
            {
                "C#",
                "TypeScript",
            };
        }
        public PickServerDatabaseViewModel(
            IVisualStudioAccess visualStudioAccess,
            ICredentialStore credentialStore,
            Func <IPickSchemasDialog> pickSchemasDialogFactory,
            Func <IPickConnectionDialog> pickConnectionDialogFactory)
        {
            this.visualStudioAccess          = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
            this.pickSchemasDialogFactory    = pickSchemasDialogFactory ?? throw new ArgumentNullException(nameof(pickSchemasDialogFactory));
            this.pickConnectionDialogFactory = pickConnectionDialogFactory ?? throw new ArgumentNullException(nameof(pickConnectionDialogFactory));
            this.credentialStore             = credentialStore ?? throw new ArgumentNullException(nameof(credentialStore));

            LoadedCommand = new RelayCommand(Loaded_Executed);
            AddDatabaseConnectionCommand      = new RelayCommand(AddDatabaseConnection_Executed);
            AddAdhocDatabaseConnectionCommand = new RelayCommand(AddAdhocDatabaseConnection_Executed);
            AddDatabaseDefinitionCommand      = new RelayCommand(AddDatabaseDefinition_Executed);
            RemoveDatabaseConnectionCommand   = new RelayCommand(RemoveDatabaseConnection_Executed, RemoveDatabaseConnection_CanExecute);
            OkCommand            = new RelayCommand(Ok_Executed, Ok_CanExecute);
            CancelCommand        = new RelayCommand(Cancel_Executed);
            FilterSchemasCommand = new RelayCommand(FilterSchemas_Executed, FilterSchemas_CanExecute);

            CodeGenerationModeList = new[]
            {
                "EF Core 5",
                "EF Core 3",
                "EF Core 6",
            };

            DatabaseConnections = new ObservableCollection <DatabaseConnectionModel>();
            DatabaseDefinitions = new ObservableCollection <DatabaseDefinitionModel>();
            Schemas             = new List <SchemaInfo>();
            DatabaseDefinitions.CollectionChanged += (sender, args) => RaisePropertyChanged(nameof(DatabaseDefinitions));
        }
Exemple #3
0
 public ToolWindowInitializer([NotNull] IVisualStudioAccess visualStudioAccess,
                              [NotNull] DependencyResolver dependencyResolver)
 {
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _dependencyResolver = dependencyResolver ?? throw new ArgumentNullException(nameof(dependencyResolver));
     _visualStudioAccess.SolutionClosed += (sender, args) => _dependencyResolver.HandleSolutionClosed();
 }
        public void Constructor_ArgumentNullException()
        {
            // Arrange
            IVisualStudioAccess vsa = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => new PickServerDatabaseViewModel(vsa));
        }
 public ScriptCreationService([NotNull] IWorkUnitFactory workUnitFactory,
                              [NotNull] IVisualStudioAccess visualStudioAccess,
                              [NotNull] ILogger logger)
     : base(logger)
 {
     _workUnitFactory    = workUnitFactory ?? throw new ArgumentNullException(nameof(workUnitFactory));
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
 }
 public DeleteRefactorLogUnit([NotNull] IFileSystemAccess fileSystemAccess,
                              [NotNull] IVisualStudioAccess visualStudioAccess,
                              [NotNull] ILogger logger)
 {
     _fileSystemAccess   = fileSystemAccess ?? throw new ArgumentNullException(nameof(fileSystemAccess));
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemple #7
0
 public ConfigurationService(IFileSystemAccess fileSystemAccess,
                             IVisualStudioAccess visualStudioAccess,
                             ILogger logger)
 {
     _fileSystemAccess   = fileSystemAccess ?? throw new ArgumentNullException(nameof(fileSystemAccess));
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public CommandAvailabilityService(IVisualStudioAccess visualStudioAccess,
                                   IScaffoldingService scaffoldingService,
                                   IScriptCreationService scriptCreationService)
 {
     _visualStudioAccess    = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _scaffoldingService    = scaffoldingService ?? throw new ArgumentNullException(nameof(scaffoldingService));
     _scriptCreationService = scriptCreationService ?? throw new ArgumentNullException(nameof(scriptCreationService));
 }
Exemple #9
0
 public InstalledComponentsService(IVisualStudioAccess visualStudioAccess,
                                   IFileSystemAccess fileSystemAccess,
                                   IDotNetAccess dotNetAccess)
 {
     _visualStudioAccess = visualStudioAccess;
     _fileSystemAccess   = fileSystemAccess;
     _dotNetAccess       = dotNetAccess;
 }
Exemple #10
0
 public InstalledComponentsService(IVisualStudioAccess visualStudioAccess,
                                   IFileSystemAccess fileSystemAccess,
                                   IDotNetAccess dotNetAccess)
 {
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _fileSystemAccess   = fileSystemAccess ?? throw new ArgumentNullException(nameof(fileSystemAccess));
     _dotNetAccess       = dotNetAccess ?? throw new ArgumentNullException(nameof(dotNetAccess));
 }
        public void Constructor_ArgumentNullException()
        {
            // Arrange
            IVisualStudioAccess vsa = null;
            var psdFactory          = Mock.Of <Func <IPickSchemasDialog> >();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => new PickServerDatabaseViewModel(vsa, psdFactory));
        }
Exemple #12
0
        public CompareOptionsViewModel(IVisualStudioAccess visualStudioAccess)
        {
            this.visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));

            AddDatabaseConnectionCommand    = new RelayCommand(AddDatabaseConnection_Executed);
            RemoveDatabaseConnectionCommand = new RelayCommand(RemoveDatabaseConnection_Executed, RemoveDatabaseConnection_CanExecute);
            OkCommand     = new RelayCommand(Ok_Executed, Ok_CanExecute);
            CancelCommand = new RelayCommand(Cancel_Executed);
        }
Exemple #13
0
        public void Constructor_ArgumentNullException_VisualStudioAccess()
        {
            // Arrange
            IVisualStudioAccess vsa = null;
            IDotNetAccess       dna = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => new InstalledComponentsService(vsa, dna));
        }
        public MigrationOptionsViewModel(IVisualStudioAccess visualStudioAccess)
        {
            this.visualStudioAccess = visualStudioAccess;

#pragma warning disable VSTHRD101 // Avoid unsupported async delegates
            LoadedCommand = new RelayCommand(async() => await Loaded_ExecutedAsync());
            applyCommand  = new RelayCommand(async() => await Apply_ExecutedAsync(), () => !applying);
#pragma warning restore VSTHRD101 // Avoid unsupported async delegates
            CancelCommand = new RelayCommand(Cancel_Executed);
        }
Exemple #15
0
        public PickConfigViewModel(IVisualStudioAccess visualStudioAccess, Func <IPickSchemasDialog> pickSchemasDialogFactory)
        {
            LoadedCommand = new RelayCommand(Loaded_Executed);
            OkCommand     = new RelayCommand(Ok_Executed, Ok_CanExecute);
            CancelCommand = new RelayCommand(Cancel_Executed);

            Configurations = new ObservableCollection <ConfigModel>();

            Configurations.CollectionChanged += (sender, args) => RaisePropertyChanged(nameof(Configurations));
        }
        public void Constructor_ArgumentNullException_VisualStudioAccess()
        {
            // Arrange
            var aem = new AboutExtensionModel();
            var evs = Mock.Of <IExtensionVersionService>();
            var ics = Mock.Of <IInstalledComponentsService>();
            var osa = Mock.Of <IOperatingSystemAccess>();
            IVisualStudioAccess vsa = null;
            IMessenger          m   = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => new AboutViewModel(aem, evs, ics, osa, vsa, m));
        }
Exemple #17
0
        private IUnityContainer CreateContainer(IVisualStudioAccess visualStudioAccess,
                                                ILogger logger,
                                                OleMenuCommandService commandService)
        {
            return(new UnityContainer()

                   // Register self
                   .RegisterInstance(typeof(IDependencyResolver), this, new ContainerControlledLifetimeManager())

                   // Visual Studio dependencies
                   .RegisterInstance(commandService, new ContainerControlledLifetimeManager()) // The command service

                   // Tool window initialization
                   .RegisterSingleton <ToolWindowInitializer>()

                   // ViewModels
                   .RegisterType <ScriptCreationViewModel>()
                   .RegisterType <VersionHistoryViewModel>()
                   .RegisterType <ConfigurationViewModel>()

                   // Services with state / events
                   .RegisterSingleton <IConfigurationService, ConfigurationService>()
                   .RegisterSingleton <IScaffoldingService, ScaffoldingService>()
                   .RegisterSingleton <IScriptCreationService, ScriptCreationService>()

                   // Stateless services
                   .RegisterType <ICommandAvailabilityService, CommandAvailabilityService>()
                   .RegisterType <IBuildService, BuildService>()
                   .RegisterType <IVersionService, VersionService>()
                   .RegisterType <ISqlProjectService, SqlProjectService>()
                   .RegisterType <IXmlFormatService, XmlFormatService>()
                   .RegisterType <IArtifactsService, ArtifactsService>()
                   .RegisterType <IScriptModifierProviderService, ScriptModifierProviderService>()

                   // Data Access
                   .RegisterSingleton <IFileSystemAccess, FileSystemAccess>()
                   .RegisterInstance(visualStudioAccess, new ContainerControlledLifetimeManager())
                   .RegisterInstance(logger, new ContainerControlledLifetimeManager())
                   .RegisterType <IDacAccess, DacAccess>()

                   // Factories
                   .RegisterSingleton <IScriptModifierFactory, ScriptModifierFactory>()
                   .RegisterSingleton <IWorkUnitFactory, WorkUnitFactory>());
        }
Exemple #18
0
        internal DependencyResolver([NotNull] IVisualStudioAccess visualStudioAccess,
                                    [NotNull] ILogger logger,
                                    [NotNull] OleMenuCommandService commandService)
        {
            if (visualStudioAccess == null)
            {
                throw new ArgumentNullException(nameof(visualStudioAccess));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (commandService == null)
            {
                throw new ArgumentNullException(nameof(commandService));
            }

            _container = CreateContainer(visualStudioAccess,
                                         logger,
                                         commandService);
        }
Exemple #19
0
        internal DependencyResolver([NotNull] IVisualStudioAccess visualStudioAccess,
                                    [NotNull] ILogger logger,
                                    [NotNull] OleMenuCommandService commandService)
        {
            if (visualStudioAccess == null)
            {
                throw new ArgumentNullException(nameof(visualStudioAccess));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (commandService == null)
            {
                throw new ArgumentNullException(nameof(commandService));
            }

            _container = CreateContainer(visualStudioAccess,
                                         logger,
                                         commandService);
            _viewModels = new Dictionary <Type, Dictionary <string, object> >();
        }
 public ValidateTargetVersionUnit([NotNull] IVisualStudioAccess visualStudioAccess,
                                  [NotNull] ILogger logger)
 {
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public ToolWindowInitializer([NotNull] IVisualStudioAccess visualStudioAccess,
                              [NotNull] DependencyResolver dependencyResolver)
 {
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _dependencyResolver = dependencyResolver ?? throw new ArgumentNullException(nameof(dependencyResolver));
 }
 public ArtifactsService([NotNull] IVisualStudioAccess visualStudioAccess,
                         [NotNull] IFileSystemAccess fileSystemAccess)
 {
     _visualStudioAccess = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _fileSystemAccess   = fileSystemAccess ?? throw new ArgumentNullException(nameof(fileSystemAccess));
 }
 public VisualStudioLogger([NotNull] IVisualStudioAccess visualStudioAccess,
                           [NotNull] string documentationBaseUrl)
 {
     _visualStudioAccess   = visualStudioAccess ?? throw new ArgumentNullException(nameof(visualStudioAccess));
     _documentationBaseUrl = documentationBaseUrl ?? throw new ArgumentNullException(nameof(documentationBaseUrl));
 }