Exemple #1
0
        internal string LinkRef(int hvo)
        {
            ICmObjectRepository repo = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>();

            if (!repo.IsValidObjectId(hvo))
            {
                return(null);
            }
            Guid       guid = repo.GetObject(hvo).Guid;
            FwLinkArgs link = new FwLinkArgs("lexiconEdit", guid);

            return(link.ToString());
        }
 protected Guid WriteGuidAttributeForObj(int hvo)
 {
     if (m_repoObj.IsValidObjectId(hvo))
     {
         ICmObject obj  = m_repoObj.GetObject(hvo);
         Guid      guid = obj.Guid;
         m_writer.WriteAttributeString("guid", guid.ToString());
         return(guid);
     }
     else
     {
         return(Guid.Empty);
     }
 }
Exemple #3
0
        /// <summary>
        /// Determine whether this UOW can safely Undo.
        /// Higher-level methods are responsible for determining whether this UOW conflicts with
        /// those in other stacks. This method is mainly focused on whether referential integrity will be broken.
        /// </summary>
        internal bool CanUndo(ICmObjectRepository objRepo)
        {
            var deletedGuids = new HashSet <Guid>(from obj in m_deletedObjects select obj.Guid);

            if (m_changes.OfType <FdoStateChangeBase>().Any(change => change.CreatesProblemReferenceOnUndo(objRepo, deletedGuids)))
            {
                return(false);
            }

            // Now verify that none of the new objects which this action creates will leave a dangling
            // reference if deleted.
            if (m_newObjects.Count == 0)
            {
                return(true);
            }
            // If any of the new objects is has already been deleted, we don't have to worry about leaving refs to it!
            var newObjects = new HashSet <ICmObject>(from id in m_newObjects where objRepo.IsValidObjectId(id.Guid)
                                                     select objRepo.GetObject(id));
            int externalIncomingRefs = newObjects.Sum(obj => ((ICmObjectInternal)obj).IncomingRefsNotFrom(newObjects));

            if (externalIncomingRefs == 0)
            {
                return(true);
            }
            // OK, there are problem references AFTER the change...will undoing it fix them?
            var newGuids = new HashSet <Guid>(from id in m_newObjects select id.Guid);

            foreach (var item in m_changes)
            {
                var change = item as FdoStateChangeBase;
                if (change != null)
                {
                    externalIncomingRefs -= change.CountDeletedRefsToOnUndo(newGuids);
                }
            }
            return(externalIncomingRefs == 0);
        }