public static IDisposable TryConnect(this INetworkConnectionFactory factory, ILogger logger, string directory, string username, string password, string domain = "")
        {
            // ignore if the username, password or directory is not set
            if (string.IsNullOrEmpty(directory) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                logger.WarnFormat("Username ('{0}'), password ('{1}') or domain ('{2}') empty; not connecting to network share.", username,
                                  string.IsNullOrEmpty(password) ? "<empty>" : "<not empty>", domain);

                return(null);
            }

            // ensure we can connect to the remote network connection
            if (directory.StartsWith(@"\\"))
            {
                try
                {
                    logger.DebugFormat("Connecting network share to '{0}' with user '{1}\\{2}'.", directory, domain, username);
                    return(factory.Connect(directory, username, password, domain));
                }
                catch (Exception ex)
                {
                    // sigh, let's just log it and hope the connection works, for example because it was already connected
                    var msg = string.Format("Error when connecting to '{0}' with user '{1}\\{2}'.", directory, domain, username);
                    logger.Error(msg, ex);
                }
            }

            return(null);
        }
Пример #2
0
        public ServerDispatcher( INetworkConnectionFactory factory )
        {
            Contract.Requires( factory != null );

            Logger = new DefaultSessionLogger();

            _factory = factory;
            _serverConnections = new List<IHttpServer>();
        }
Пример #3
0
        internal Service(INetworkConnectionFactory factory, ICoreSettings settings, IAccessLog accessLog)
        {
            Contract.Requires( factory != null );
            Contract.Requires(settings!=null);
            Contract.Requires(accessLog!=null);

            _accessLog = accessLog;
            _factory = factory;
            _settings = settings;
        }
Пример #4
0
        public NativeSyncProvider(IFileSystem fileSystem, INetworkConnectionFactory connectionFactory, WindowsFileSystemOptions options)
        {
            this.FileSystem = fileSystem;
            this.ConnectionFactory = connectionFactory;
            this.UserName = options.UserName;
            this.Password = options.Password;

            if (this.UserName == null)
                this.BaseDirectory = options.Path.WithTrailingPathSeparator();
            else
                this.BaseDirectory = options.Path.WithoutTrailingPathSeparator();
        }
Пример #5
0
 public ConnectionListener(INetworkConnectionFactory clientFactory)
 {
     _Factory = clientFactory;
 }
Пример #6
0
        public HttpsTunnel( INetworkConnectionFactory factory )
        {
            Contract.Requires(factory!=null);

            _factory = factory;
        }