protected virtual void NotifySelectedChanged(IWritableLaunchProfile oldProfile)
        {
            // we need to keep the property page control from setting IsDirty when we are just switching between profiles.
            // we still need to notify the display of the changes though
            PushIgnoreEvents();
            try
            {
                // these have no backing store in the viewmodel, we need to send notifications when we change selected profiles
                // consider a better way of doing this
                OnPropertyChanged(nameof(SelectedDebugProfile));
                OnPropertyChanged(nameof(CommandLineArguments));
                OnPropertyChanged(nameof(ExecutablePath));
                OnPropertyChanged(nameof(LaunchPage));
                OnPropertyChanged(nameof(HasLaunchOption));
                OnPropertyChanged(nameof(NativeCodeDebugging));
                OnPropertyChanged(nameof(SqlDebugging));
                OnPropertyChanged(nameof(WorkingDirectory));

                UpdateLaunchTypes();

                ActiveProvider?.ProfileSelected(CurrentLaunchSettings);

                OnPropertyChanged(nameof(IsProfileSelected));
                OnPropertyChanged(nameof(DeleteProfileEnabled));

                SetEnvironmentGrid(oldProfile);

                UpdateActiveProfile();
            }
            finally
            {
                PopIgnoreEvents();
            }
        }
        public void SwitchProviders(ILaunchSettingsUIProvider oldProvider)
        {
            // Get the old custom control and disconnect from notifications
            if (oldProvider?.CustomUI?.DataContext is INotifyPropertyChanged context)
            {
                context.PropertyChanged -= OnCustomUIStateChanged;

                if (context is INotifyDataErrorInfo notifyDataErrorInfo)
                {
                    notifyDataErrorInfo.ErrorsChanged -= OnCustomUIErrorsChanged;
                }
            }

            // Now hook into the current providers notifications. We do that after having set the profile on the provider
            // so that we don't get notifications while the control is initializing. Note that this is likely the first time the
            // custom control is asked for and we want to call it and have it created prior to setting the active profile
            UserControl customControl = ActiveProvider?.CustomUI;

            if (customControl != null)
            {
                ActiveProvider.ProfileSelected(CurrentLaunchSettings);

                context = customControl.DataContext as INotifyPropertyChanged;
                if (context != null)
                {
                    context.PropertyChanged += OnCustomUIStateChanged;
                }

                if (context is INotifyDataErrorInfo notifyDataErrorInfo)
                {
                    notifyDataErrorInfo.ErrorsChanged += OnCustomUIErrorsChanged;
                }
            }
        }
示例#3
0
 protected override void Up(MigrationBuilder migrationBuilder)
 {
     if (ActiveProvider.EndsWith("Sqlite"))
     {
         migrationBuilder.Sql("ALTER TABLE DatabaseConnections ADD COLUMN SshServer TEXT;");
     }
     else
     {
         migrationBuilder.AddColumn <string>(
             table: "DatabaseConnections",
             name: "SshServer",
             nullable: true
             );
     }
 }
 private bool ActiveProviderSupportsProperty(string propertyName)
 {
     return(ActiveProvider?.ShouldEnableProperty(propertyName) ?? false);
 }
示例#5
0
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            if (ActiveProvider.EndsWith("Sqlite"))
            {
                // Rename old table, create newer version, copy data and drop old table
                migrationBuilder.Sql(@"

PRAGMA foreign_keys=off;
 
ALTER TABLE DatabaseConnections RENAME TO temp_DatabaseConnections;
 
CREATE TABLE DatabaseConnections
(
  DatabaseConnectionID INTEGER NOT NULL
    CONSTRAINT PK_DatabaseConnections
    PRIMARY KEY
  AUTOINCREMENT,
  CreatedOn            TEXT    NOT NULL,
  DatabaseName         TEXT    NOT NULL,
  Description          TEXT,
  Name                 TEXT    NOT NULL,
  OrganisationId       INTEGER NOT NULL
    CONSTRAINT FK_DatabaseConnections_Organisations_OrganisationId
    REFERENCES Organisations
      ON DELETE CASCADE,
  Port                 INTEGER NOT NULL,
  Server               TEXT    NOT NULL,
  SshKeyFileID         INTEGER
    CONSTRAINT FK_DatabaseConnections_SshKeyFiles_SshKeyFileID
    REFERENCES SshKeyFiles
      ON DELETE RESTRICT,
  SshPort              INTEGER,
  SshUsername          TEXT,
  Type                 INTEGER NOT NULL,
  UseSsh               INTEGER NOT NULL,
  UseSshKey            INTEGER NOT NULL,
  Username             TEXT    NOT NULL
);
 
INSERT INTO DatabaseConnections (
    DatabaseConnectionID,
    CreatedOn,
    DatabaseName,
    Description,
    Name,
    OrganisationId,
    Port,
    Server,
    SshKeyFileID,
    SshPort,
    SshUsername,
    Type,
    UseSsh,
    UseSshKey,
    Username
  )
  SELECT
    DatabaseConnectionID,
    CreatedOn,
    DatabaseName,
    Description,
    Name,
    OrganisationId,
    Port,
    Server,
    SshKeyFileID,
    SshPort,
    SshUsername,
    Type,
    UseSsh,
    UseSshKey,
    Username
  FROM temp_DatabaseConnections;
 
DROP TABLE temp_DatabaseConnections;
 
PRAGMA foreign_keys=on;
                
                ");
            }
            else
            {
                migrationBuilder.DropColumn(
                    name: "SshServer",
                    table: "DatabaseConnections");
            }
        }