예제 #1
0
        public override void Bind(IEditorService service)
        {
            _bChangedUsername       = false;
            _bChangedPassword       = false;
            _service                = service;
            _service.BeforeSave    += OnBeforeSave;
            _service.BeforePreview += OnBeforePreview;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            //Set the field values
            txtService.Text = _fs.GetConnectionProperty("Service"); //NOXLATE

            //We're gonna follow MG Studio behaviour here which is: Never load the password
            //and auto trigger dirty state.
            if (!_service.IsNew)
            {
                txtUsername.Text = _fs.GetEncryptedUsername(_service.CurrentConnection) ?? _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = GenerateRandomFakeString();
            }

            //Set initial value of data store if possible
            var dstore = _fs.GetConnectionProperty("DataStore"); //NOXLATE

            txtDataStore.Text = dstore;

            //As our connection properties are not CLR properties,
            //"manually" bind these fields
            txtService.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("Service", txtService.Text); //NOXLATE
            };

            txtUsername.TextChanged += (s, e) =>
            {
                _bChangedUsername = true;
                if (string.IsNullOrEmpty(txtUsername.Text))
                {
                    _fs.SetConnectionProperty("Username", null); //NOXLATE
                }
                else
                {
                    _fs.SetConnectionProperty("Username", txtUsername.Text); //NOXLATE
                }
            };

            txtPassword.TextChanged += (s, e) =>
            {
                _bChangedPassword = true;
                if (string.IsNullOrEmpty(txtPassword.Text))
                {
                    _fs.SetConnectionProperty("Password", null); //NOXLATE
                }
                else
                {
                    _fs.SetConnectionProperty("Password", txtPassword.Text); //NOXLATE
                }
            };

            txtDataStore.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("DataStore", txtDataStore.Text); //NOXLATE
            };
        }
예제 #2
0
        public override void Bind(IEditorService service)
        {
            _bChangedUsername = false;
            _bChangedPassword = false;
            _service = service;
            _service.BeforeSave += OnBeforeSave;
            _service.BeforePreview += OnBeforePreview;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            //Set the field values
            txtService.Text = _fs.GetConnectionProperty("Service"); //NOXLATE

            //We're gonna follow MG Studio behaviour here which is: Never load the password
            //and auto trigger dirty state.
            if (!_service.IsNew)
            {
                txtUsername.Text = _fs.GetEncryptedUsername() ?? _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = GenerateRandomFakeString();
            }

            //Set initial value of data store if possible
            var dstore = _fs.GetConnectionProperty("DataStore"); //NOXLATE
            txtDataStore.Text = dstore;

            //As our connection properties are not CLR properties,
            //"manually" bind these fields
            txtService.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("Service", txtService.Text); //NOXLATE
            };

            txtUsername.TextChanged += (s, e) =>
            {
                _bChangedUsername = true;
                if (string.IsNullOrEmpty(txtUsername.Text))
                    _fs.SetConnectionProperty("Username", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Username", txtUsername.Text); //NOXLATE
            };

            txtPassword.TextChanged += (s, e) =>
            {
                _bChangedPassword = true;
                if (string.IsNullOrEmpty(txtPassword.Text))
                    _fs.SetConnectionProperty("Password", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Password", txtPassword.Text); //NOXLATE
            };

            txtDataStore.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("DataStore", txtDataStore.Text); //NOXLATE
            };
        }