示例#1
0
        /// <summary>
        /// Get an iFolder Entry
        /// </summary>
        /// <param name="c">The Collection Object</param>
        /// <param name="n">The Node Object</param>
        /// <returns>An iFolderEntry Object</returns>
        private static iFolderEntry GetEntry(Collection c, Node n)
        {
            iFolderEntry entry = new iFolderEntry();

            entry.ID        = n.ID;
            entry.Name      = n.Name;
            entry.iFolderID = c.ID;

            try
            {
                entry.ParentID = (n.Properties.GetSingleProperty(PropertyTags.Parent).Value as Relationship).NodeID;
            }
            catch
            {
                // ignore
            }

            // file node
            if (n.IsBaseType(NodeTypes.FileNodeType))
            {
                FileNode fileNode = (FileNode)FileNode.NodeFactory(c, n);

                entry.Path         = fileNode.GetRelativePath();
                entry.LastModified = fileNode.LastWriteTime;
                entry.Size         = fileNode.Length;
            }

            // dir node
            else if (n.IsBaseType(NodeTypes.DirNodeType))
            {
                DirNode dirNode = (DirNode)DirNode.NodeFactory(c, n);

                entry.Path         = dirNode.GetRelativePath();
                entry.LastModified = dirNode.CreationTime;
                entry.IsDirectory  = true;
                entry.IsRoot       = dirNode.IsRoot;
                entry.HasChildren  = dirNode.HasChildren(c);

                entry.Size = (long)dirNode.GetSize(c);
            }

            // bad node
            else
            {
                throw new EntryDoesNotExistException(n.ID);
            }

            return(entry);
        }