예제 #1
0
        public DocumentLock LockDocument(string path, DocumentLockType lockType)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            return(LockDocuments(new string[] { path }, lockType));
        }
예제 #2
0
        public DocumentLock LockDocuments(IEnumerable <string> paths, DocumentLockType lockType)
        {
            if (paths == null)
            {
                throw new ArgumentNullException("paths");
            }

            HybridCollection <string> locked   = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
            HybridCollection <string> ignoring = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
            HybridCollection <string> readOnly = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);

            foreach (string path in paths)
            {
                SccDocumentData dd;
                if (_docMap.TryGetValue(path, out dd))
                {
                    if (!locked.Contains(path))
                    {
                        locked.Add(path);
                    }

                    if (!ignoring.Contains(path) && dd.IgnoreFileChanges(true))
                    {
                        ignoring.Add(path);
                    }

                    if (lockType >= DocumentLockType.ReadOnly && !readOnly.Contains(path) && !dd.IsReadOnly())
                    {
                        // Don't set read-only twice!!!
                        if (dd.SetReadOnly(true))
                        {
                            readOnly.Add(path);
                        }
                    }
                }
            }
            return(new SccDocumentLock(this, locked, ignoring, readOnly));
        }
예제 #3
0
        public DocumentLock LockDocuments(IEnumerable<string> paths, DocumentLockType lockType)
        {
            if (paths == null)
                throw new ArgumentNullException("paths");

            HybridCollection<string> locked = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);
            HybridCollection<string> ignoring = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);
            HybridCollection<string> readOnly = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);
            foreach (string path in paths)
            {
                SccDocumentData dd;
                if (_docMap.TryGetValue(path, out dd))
                {
                    if (!locked.Contains(path))
                        locked.Add(path);

                    if (!ignoring.Contains(path) && dd.IgnoreFileChanges(true))
                        ignoring.Add(path);

                    if (lockType >= DocumentLockType.ReadOnly && !readOnly.Contains(path) && !dd.IsReadOnly())
                    {
                        // Don't set read-only twice!!!
                        if (dd.SetReadOnly(true))
                            readOnly.Add(path);
                    }
                }
            }
            return new SccDocumentLock(this, locked, ignoring, readOnly);
        }
예제 #4
0
        public DocumentLock LockDocument(string path, DocumentLockType lockType)
        {
            if (string.IsNullOrEmpty(path))
                throw new ArgumentNullException("path");

            return LockDocuments(new string[] { path }, lockType);
        }