コード例 #1
0
        /// <summary>
        /// Processes a record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Starting a new server connection");
            var client = ClientHelpers.GenerateClient(this.Address, this);

            this.WriteVerbose("Retrieving server version");
            var version = client.GetServerVersion();

            if (!string.IsNullOrEmpty(this.UserName))
            {
                this.WriteVerbose("Logging in");
                var credentials = new List <NameValuePair>
                {
                    new NameValuePair(LoginRequest.UserNameCredential, this.UserName)
                };
                if (!string.IsNullOrEmpty(this.Password))
                {
                    credentials.Add(new NameValuePair(LoginRequest.PasswordCredential, this.Password));
                }

                client.Login(credentials);
            }

            var connection = new CCConnection(client, new Version(version));

            this.WriteObject(connection);
        }
コード例 #2
0
        /// <summary>
        /// Processes a record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Starting a new server connection");
            var client = ClientHelpers.GenerateClient(this.Address, this);

            this.WriteVerbose("Retrieving server version");
            var version = client.GetServerVersion();

            if (!string.IsNullOrEmpty(this.UserName))
            {
                this.WriteVerbose("Logging in");
                var credentials = new List<NameValuePair>
                    { 
                        new NameValuePair(LoginRequest.UserNameCredential, this.UserName) 
                    };
                if (!string.IsNullOrEmpty(this.Password))
                {
                    credentials.Add(new NameValuePair(LoginRequest.PasswordCredential, this.Password));
                }

                client.Login(credentials);
            }

            var connection = new CCConnection(client, new Version(version));
            this.WriteObject(connection);
        }