コード例 #1
0
        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;
        }
コード例 #2
0
 internal FileSystemConnection(FileSystemSharedConnection sharedConnection, FileSystemConnectionManager manager)
 {
     this.sharedConnection = sharedConnection;
     this.manager = manager;
 }
コード例 #3
0
 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);
 }