示例#1
0
        internal void AddLink(FsStructureFile structureFile)
        {
            if (structureFile == null)
            {
                throw new ArgumentNullException("structureFile");
            }

            Monitor.Enter(((ICollection)Links).SyncRoot);
            try
            {
                if (_links.Contains(structureFile))
                {
                    return;
                }
                if (!ReferenceEquals(structureFile.Data, this))
                {
                    throw new InvalidOperationException("File does not reference this data");
                }
                if (structureFile.Parent == null)
                {
                    throw new InvalidOperationException("File does not have a parent");
                }
                _links.Add(structureFile);
            }
            finally { Monitor.Exit(((ICollection)Links).SyncRoot); }
        }
示例#2
0
 internal void RemoveLink(FsStructureFile structureFile)
 {
     Monitor.Enter(((ICollection)Links).SyncRoot);
     try
     {
         if (!_links.Contains(structureFile))
         {
             return;
         }
         if (structureFile.Parent != null)
         {
             throw new InvalidOperationException("File still has a parent");
         }
         if (ReferenceEquals(structureFile.Data, this))
         {
             throw new InvalidOperationException("File still references this data");
         }
         _links.Remove(structureFile);
     }
     finally { Monitor.Exit(((ICollection)Links).SyncRoot); }
 }