コード例 #1
0
        /// <exception cref="System.IO.IOException"></exception>
        public override bool IsNameConflicting(string name)
        {
            RefList <Ref> packed = GetPackedRefs();
            RefList <RefDirectory.LooseRef> loose = GetLooseRefs();
            // Cannot be nested within an existing reference.
            int lastSlash = name.LastIndexOf('/');

            while (0 < lastSlash)
            {
                string needle = Sharpen.Runtime.Substring(name, 0, lastSlash);
                if (loose.Contains(needle) || packed.Contains(needle))
                {
                    return(true);
                }
                lastSlash = name.LastIndexOf('/', lastSlash - 1);
            }
            // Cannot be the container of an existing reference.
            string prefix = name + '/';
            int    idx;

            idx = -(packed.Find(prefix) + 1);
            if (idx < packed.Size() && packed.Get(idx).GetName().StartsWith(prefix))
            {
                return(true);
            }
            idx = -(loose.Find(prefix) + 1);
            if (idx < loose.Size() && loose.Get(idx).GetName().StartsWith(prefix))
            {
                return(true);
            }
            return(false);
        }
コード例 #2
0
 /// <summary>
 /// Привязан ли элемент к коллекции
 /// </summary>
 /// <param name="links">Коллекция привязок</param>
 /// <param name="chekedElementID">ИД элемента, который проверяется на привязку</param>
 /// <param name="includeNotLinked">Считать, что элемент привязан, если коллекция с привязками null или пуста</param>
 /// <returns></returns>
 private bool IsLinked(RefList <int> links, int chekedElementID, bool includeNotLinked)
 {
     if (links == null || links.Count == 0)
     {
         return(includeNotLinked);
     }
     else
     {
         return(links.Contains(chekedElementID));
     }
 }