Ejemplo n.º 1
0
        /// <summary>
        /// Gets the DirNode object that represents the parent relationship to this directory entry.
        /// </summary>
        /// <param name="collection">Collection object that this object belongs to.</param>
        /// <returns>A DirNode object that represents the parent relationship or null if the DirNode
        /// object exists at the collection root.</returns>
        public DirNode GetParent(Collection collection)
        {
            DirNode parent = null;

            Property property = properties.FindSingleValue(PropertyTags.Parent);

            if (property != null)
            {
                Relationship relationship = property.Value as Relationship;
                if (!relationship.IsRoot)
                {
                    parent = collection.GetNodeByID(relationship.NodeID) as DirNode;
                }
            }
            else
            {
                throw new DoesNotExistException(String.Format("Parent relationship property for Node object: {0} - ID: {1} does not exist.", name, id));
            }

            return(parent);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor used to create a new DirNode object.
 /// </summary>
 /// <param name="collection">Collection that this DirNode object will be associated with.</param>
 /// <param name="parentNode">The DirNode object that will be the parent to this object or null
 /// if this directory exists at the collection root.</param>
 /// <param name="dirName">Name of the directory entry.</param>
 public DirNode(Collection collection, DirNode parentNode, string dirName) :
     this(collection, parentNode, dirName, Guid.NewGuid().ToString())
 {
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Node factory method that constructs a derived Node object type from the specified Node object.
        /// </summary>
        /// <param name="store">Store object.</param>
        /// <param name="document">Xml document to construct new Node from.</param>
        /// <returns>Downcasts the derived Node object back to a Node that can then be explicitly casted back up.</returns>
        static public Node NodeFactory(Store store, XmlDocument document)
        {
            XmlElement nodeObject = document.DocumentElement[XmlTags.ObjectTag];
            Node       rNode      = null;

            switch (nodeObject.GetAttribute(XmlTags.TypeAttr))
            {
            case "Node":
                rNode = new Node(document);
                break;

            case "DirNode":
                rNode = new DirNode(document);
                break;

            case "FileNode":
                rNode = new FileNode(document);
                break;

            case "LinkNode":
                rNode = new LinkNode(document);
                break;

            case "StoreFileNode":
                rNode = new StoreFileNode(document);
                break;

            case "Collection":
                rNode = new Collection(store, document);
                break;

            case "Tombstone":
                rNode = new Node(document);
                break;

            case "LocalDatabase":
                rNode = new LocalDatabase(store, document);
                break;

            case "Identity":
                rNode = new Identity(document);
                break;

            case "Member":
                rNode = new Member(document);
                break;

            case "Domain":
                rNode = new Domain(store, document);
                break;

            case "Policy":
                rNode = new Policy.Policy(document);
                break;

            case "POBox":
                rNode = new POBox.POBox(store, document);
                break;

            case "Subscription":
                rNode = new Subscription(document);
                break;

            case "NotificationLog":
                rNode = new NotificationLog(store, document);
                break;

            default:
                rNode = new Node(document);
                break;
            }

            return(rNode);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Node factory method that constructs a derived Node object type from the specified ShallowNode object.
        /// </summary>
        /// <param name="collection">Collection object associated with the specified Node object.</param>
        /// <param name="shallowNode">ShallowNode object to construct new Node from.</param>
        /// <returns>Downcasts the derived Node object back to a Node that can then be explicitly casted back up.</returns>
        static public Node NodeFactory(Collection collection, ShallowNode shallowNode)
        {
            Node rNode = null;

            switch (shallowNode.Type)
            {
            case "Node":
                rNode = new Node(collection, shallowNode);
                break;

            case "DirNode":
                rNode = new DirNode(collection, shallowNode);
                break;

            case "FileNode":
                rNode = new FileNode(collection, shallowNode);
                break;

            case "LinkNode":
                rNode = new LinkNode(collection, shallowNode);
                break;

            case "StoreFileNode":
                rNode = new StoreFileNode(collection, shallowNode);
                break;

            case "Collection":
                rNode = new Collection(collection.StoreReference, shallowNode);
                break;

            case "Tombstone":
                rNode = new Node(collection, shallowNode);
                break;

            case "LocalDatabase":
                rNode = new LocalDatabase(collection.StoreReference, shallowNode);
                break;

            case "Identity":
                rNode = new Identity(collection, shallowNode);
                break;

            case "Member":
                rNode = new Member(collection, shallowNode);
                break;

            case "Domain":
                rNode = new Domain(collection.StoreReference, shallowNode);
                break;

            case "Policy":
                rNode = new Policy.Policy(collection, shallowNode);
                break;

            case "POBox":
                rNode = new POBox.POBox(collection.StoreReference, shallowNode);
                break;

            case "Subscription":
                rNode = new Subscription(collection, shallowNode);
                break;

            case "NotificationLog":
                rNode = new NotificationLog(collection.StoreReference, shallowNode);
                break;

            default:
                rNode = new Node(collection, shallowNode);
                break;
            }

            return(rNode);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor used to create a new FileNode object.
 /// </summary>
 /// <param name="collection">Collection that this FileNode object will be associated with.</param>
 /// <param name="parentNode">The DirNode object that will be the parent to this object.</param>
 /// <param name="fileName">Friendly name of the FileNode object.</param>
 public FileNode(Collection collection, DirNode parentNode, string fileName) :
     this(collection, parentNode, fileName, Guid.NewGuid().ToString())
 {
 }