MonoDevelop.VersionControl.Repository.GetDirectoryVersionInfo C# (CSharp) Méthode

GetDirectoryVersionInfo() public méthode

public GetDirectoryVersionInfo ( FilePath localDirectory, bool getRemoteStatus, bool recursive ) : MonoDevelop.VersionControl.VersionInfo[]
localDirectory FilePath
getRemoteStatus bool
recursive bool
Résultat MonoDevelop.VersionControl.VersionInfo[]
		public VersionInfo[] GetDirectoryVersionInfo (FilePath localDirectory, bool getRemoteStatus, bool recursive)
		{
			try {
				if (recursive) {
					RecursiveDirectoryInfoQuery rq = AcquireLockForQuery (localDirectory, getRemoteStatus);
					rq.ResetEvent.WaitOne ();

					lock (queryLock)
						if (Interlocked.Decrement (ref rq.Count) == 0)
							rq.ResetEvent.Dispose ();
					return rq.Result;
				}

				var status = infoCache.GetDirectoryStatus (localDirectory);
				if (status != null && !status.RequiresRefresh && (!getRemoteStatus || status.HasRemoteStatus))
					return status.FileInfo;

				// If there is no cached status, query it asynchronously
				DirectoryInfoQuery q = new DirectoryInfoQuery () {
					Directory = localDirectory,
					GetRemoteStatus = getRemoteStatus
				};
				AddQuery (q);

				// If we have a status value but the value was invalidated (RequiresRefresh == true)
				// then we return the invalidated value while we start an async query to get the new one

				if (status != null && status.RequiresRefresh && (!getRemoteStatus || status.HasRemoteStatus))
					return status.FileInfo;
				return new VersionInfo[0];
			} finally {
				//Console.WriteLine ("GetDirectoryVersionInfo " + localDirectory + " - " + (DateTime.Now - now).TotalMilliseconds);
			}
		}

Usage Example

Exemple #1
0
        static void OnEntryAdded(object o, SolutionItemEventArgs args)
        {
            if (args is SolutionItemChangeEventArgs && ((SolutionItemChangeEventArgs)args).Reloading)
            {
                return;
            }

            // handles addition of solutions and projects
            SolutionItem parent = (SolutionItem)args.SolutionItem.ParentFolder;

            if (parent == null)
            {
                return;
            }

            Repository repo = GetRepository(parent);

            if (repo == null)
            {
                return;
            }

            SolutionItem entry       = args.SolutionItem;
            Repository   currentRepo = GetRepository(entry);

            if (currentRepo != null && currentRepo.VersionControlSystem != repo.VersionControlSystem)
            {
                // If the item is already under version control using a different version control system
                // don't add it to the parent repo.
                return;
            }

            string path = entry.BaseDirectory;

            // While we /could/ call repo.Add with `recursive = true', we don't
            // necessarily want to add files under the project/solution directory
            // that may not be a part of this project/solution.

            var files = new HashSet <string> {
                path
            };

            SolutionItemAddFiles(path, entry, files);

            using (IProgressMonitor monitor = GetStatusMonitor()) {
                var status = repo.GetDirectoryVersionInfo(path, false, true);
                foreach (var v in status)
                {
                    if (!v.IsVersioned && files.Contains(v.LocalPath))
                    {
                        repo.Add(v.LocalPath, false, monitor);
                    }
                }
            }

            NotifyFileStatusChanged(new FileUpdateEventArgs(repo, parent.BaseDirectory, true));
        }
All Usage Examples Of MonoDevelop.VersionControl.Repository::GetDirectoryVersionInfo