/// <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); }
/// <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); }