AddRef() private method

private AddRef ( ) : void
return void
        static void OnExtensionChanged(object s, ExtensionNodeEventArgs args)
        {
            VersionControlSystem vcs;

            try {
                vcs = (VersionControlSystem)args.ExtensionObject;
            } catch (Exception e) {
                LoggingService.LogError("Failed to initialize VersionControlSystem type.", e);
                return;
            }

            if (args.Change == ExtensionChange.Add)
            {
                handlers.Add(vcs);
                try {
                    // Include the repository type in the serialization context, so repositories
                    // of this type can be deserialized from the configuration file.
                    Repository r = vcs.CreateRepositoryInstance();
                    r.AddRef();
                    dataContext.IncludeType(r.GetType());
                    r.Unref();
                } catch (Exception e) {
                    LoggingService.LogError("Error while adding version control system.", e);
                }
            }
            else
            {
                handlers.Remove(vcs);
            }
        }
        public static Repository GetRepository(WorkspaceObject entry)
        {
            if (IsGloballyDisabled)
            {
                return(null);
            }

            InternalRepositoryReference repoRef = (InternalRepositoryReference)entry.ExtendedProperties [typeof(InternalRepositoryReference)];

            if (repoRef != null && !repoRef.Repo.Disposed)
            {
                return(repoRef.Repo);
            }

            Repository repo = GetRepositoryReference(entry.BaseDirectory, entry.Name);
            InternalRepositoryReference rref = null;

            if (repo != null)
            {
                repo.AddRef();
                if (!referenceCache.TryGetValue(repo, out rref))
                {
                    rref = new InternalRepositoryReference(repo);
                    referenceCache [repo] = rref;
                }
            }
            entry.ExtendedProperties [typeof(InternalRepositoryReference)] = rref;

            return(repo);
        }
Beispiel #3
0
        public static Repository GetRepository(IWorkspaceObject entry)
        {
            InternalRepositoryReference repoRef = (InternalRepositoryReference)entry.ExtendedProperties [typeof(InternalRepositoryReference)];

            if (repoRef != null)
            {
                return(repoRef.Repo);
            }

            Repository repo = VersionControlService.GetRepositoryReference(entry.BaseDirectory, entry.Name);
            InternalRepositoryReference rref = null;

            if (repo != null)
            {
                repo.AddRef();
                if (!referenceCache.TryGetValue(repo, out rref))
                {
                    rref = new InternalRepositoryReference(repo);
                    referenceCache [repo] = rref;
                }
            }
            entry.ExtendedProperties [typeof(InternalRepositoryReference)] = rref;

            return(repo);
        }
Beispiel #4
0
        static void OnExtensionChanged(object s, ExtensionNodeEventArgs args)
        {
            VersionControlSystem vcs;

            try {
                vcs = (VersionControlSystem)args.ExtensionObject;
            } catch (Exception e) {
                LoggingService.LogError("Failed to initialize VersionControlSystem type.", e);
                return;
            }

            if (args.Change == ExtensionChange.Add)
            {
                IComparer <VersionControlSystem> compare = new CompareVersionControlSystem();

                int search = handlers.BinarySearch(vcs, compare);

                if (search < 0)
                {
                    handlers.Insert(~search, vcs);
                }
                else
                {
                    LoggingService.LogError("Adding new version control system {0} failed, the name {1} is already reserved.", vcs.GetType().Name, vcs.Name);
                    return;
                }
                try {
                    // Include the repository type in the serialization context, so repositories
                    // of this type can be deserialized from the configuration file.
                    Repository r = vcs.CreateRepositoryInstance();
                    r.AddRef();
                    dataContext.IncludeType(r.GetType());
                    r.Unref();
                } catch (Exception e) {
                    LoggingService.LogError("Error while adding version control system.", e);
                }
            }
            else
            {
                handlers.Remove(vcs);
            }
        }