Beispiel #1
0
        private void SetCredentials()
        {
            if (String.IsNullOrEmpty(UserName) || String.IsNullOrEmpty(Password) || String.IsNullOrEmpty(ServiceUrl))
            {
                var cred = _credentialService.GetCredential();
                UserName   = cred.UserName;
                Password   = cred.Password;
                ServiceUrl = _credentialService.GetUri();
            }

            var exceptions = new List <Exception>();

            if (String.IsNullOrEmpty(UserName))
            {
                exceptions.Add(new Exception(@"UserName wasn't set. Either add it to your project/msbuild file or run Set-OcfDefaultRemoteService"));
            }
            if (String.IsNullOrEmpty(Password))
            {
                exceptions.Add(new ArgumentException(@"Password wasn't set. Either add it to your project/msbuild file or run Set-OcfDefaultRemoteService"));
            }

            if (String.IsNullOrEmpty(ServiceUrl))
            {
                exceptions.Add(new ArgumentException(@"ServiceUrl wasn't set. Either add it to your project/msbuild file or run Set-OcfDefaultRemoteService"));
            }

            if (exceptions.Any())
            {
                throw new AggregateException(exceptions);
            }
        }
Beispiel #2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (String.IsNullOrWhiteSpace(ServiceUrl))
            {
                ServiceUrl = CredentialService.GetUri();
            }

            if (String.IsNullOrWhiteSpace(ServiceUrl))
            {
                ThrowTerminatingError(new ErrorRecord(new ParameterBindingException("ServiceUrl was null or empty"), "", ErrorCategory.InvalidArgument, null));
            }

            if (ServiceUrl.StartsWith("http://127.0.0.1"))
            {
                WebRequest.DefaultWebProxy = new WebProxy("127.0.0.1", 8888);
            }
        }