private FileSystemSharedConnection GetSharedConnection(string sharePath, string user, string password) { var sharedConn = pool.FirstOrDefault(c => c.SharePath == sharePath); if (sharedConn == null) { // not yet in pool; create shared connection and add to pool string error = null; UncAccessWithCredentials unc = null; if (sharePath != LocalSharePath) { unc = Util.ConnectUnc(user, password, sharePath, out error); } sharedConn = new FileSystemSharedConnection(this, sharePath, unc, error); pool.Add(sharedConn); } return sharedConn; }
internal FileSystemConnection(FileSystemSharedConnection sharedConnection, FileSystemConnectionManager manager) { this.sharedConnection = sharedConnection; this.manager = manager; }
internal void ReleaseShared(FileSystemSharedConnection fileSystemSharedConnection) { // Visual Studio (or Resharper) shows a warning that I don't think is true: // "The field is sometimes used inside synchronized block and sometimes used without synchronization" // Doing a code read, I verified that the following line is only called inside a lock (threadlock). pool.Remove(fileSystemSharedConnection); }