Ejemplo n.º 1
0
        public static IPackageRepository CreateRepository(string source, ICredentialManager credentialManager)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            Uri uri;

            try
            {
                uri = new Uri(source);
            }
            catch (UriFormatException)
            {
                return(null);
            }


            if (uri.IsFile)
            {
                return(new LocalPackageRepository(source));
            }
            else
            {
                credentialManager.TryAddUriCredentials(uri);
                return(new DataServicePackageRepository(uri, credentialManager.Get(uri)));
            }
        }
Ejemplo n.º 2
0
        private void TryConnect()
        {
            var uri = DefaultUri;

            if (uri == null)
            {
                return;
            }

            var credentials = _credentialManager.Get(uri);

            if (credentials == null)
            {
                return;
            }

            try
            {
                _server.Connect(uri, credentials);
            }
            catch (DeployitServerConnectionException)
            {
                // do nothing with it
            }
        }
        public Task <CredentialResponse> GetAsync(Uri uri, IWebProxy proxy, CredentialRequestType type, string message, bool isRetry, bool nonInteractive, CancellationToken cancellationToken)
        {
            if (isRetry)
            {
                return(Task.FromResult(new CredentialResponse(CredentialStatus.UserCanceled)));
            }

            var credentials = _credentialManager.Get(uri);

            if (credentials != null)
            {
                return(Task.FromResult(new CredentialResponse(credentials)));
            }
            return(Task.FromResult(new CredentialResponse(CredentialStatus.UserCanceled)));
        }