using System.Xml; namespace WebDAVSharp.Server { /// /// This class implements the core WebDAV server. /// internal class WebDavProperty { /// /// This class implements the core WebDAV server. /// public string Name; /// /// This class implements the core WebDAV server. /// public string Namespace; /// /// This class implements the core WebDAV server. /// public string Value; /// /// Standard constructor /// public WebDavProperty() { Namespace = string.Empty; Name = string.Empty; Value = string.Empty; } /// /// Constructor for the WebDAVProperty class with "DAV:" as namespace and an empty value /// /// The name of the WebDAV property public WebDavProperty(string name) { Name = name; Value = string.Empty; Namespace = "DAV:"; } /// /// Constructor for the WebDAVProperty class with "DAV:" as namespace /// /// The name of the WebDAV property /// The value of the WebDAV property public WebDavProperty(string name, string value) { Name = name; Value = value; Namespace = "DAV:"; } /// /// Constructor for the WebDAVProperty class /// /// The name of the WebDAV property /// The value of the WebDAV property /// The namespace of the WebDAV property public WebDavProperty(string name, string value, string ns) { Name = name; Value = value; Namespace = ns; } /// /// This class implements the core WebDAV server. /// /// /// A that represents this instance. /// public override string ToString() { return StartString() + Value + EndString(); } /// /// This class implements the core WebDAV server. /// /// The begin tag of an XML element as a string public string StartString() { if (Namespace == "DAV:") return ""; return "<" + Name + " xmlns=\"" + Namespace + "\">"; } /// /// This class implements the core WebDAV server. /// /// An empty XML element as a string public string EmptyString() { if (Namespace == "DAV:") return ""; return "<" + Name + " xmlns=\"" + Namespace + "\"/>"; } /// /// This class implements the core WebDAV server. /// /// The closing tag of an XML element as a string public string EndString() { if (Namespace == "DAV:") return ""; return ""; } /// /// Creates an XmlDocumentFragment from the current WebDAVProperty /// /// The XmlDocument where a XmlDocumentFragment is needed /// /// The XmlDocumentFragment of the current WebDAVProperty object /// public XmlDocumentFragment ToXmlDocumentFragment(XmlDocument doc) { XmlDocumentFragment fragment = doc.CreateDocumentFragment(); fragment.InnerXml = ToString(); return fragment; } /// /// reates an XmlElement from the current WebDAVProperty /// /// The XmlDocument where a XmlElement is needed /// /// The XmlElement of the current WebDAVProperty object /// public XmlElement ToXmlElement(XmlDocument doc) { // if the DocumentElement is not null, return the XmlElement with namespace if (doc.DocumentElement == null) return doc.CreateElement(Name); // Get the prefix of the namespace string prefix = doc.DocumentElement.GetPrefixOfNamespace(Namespace); // Create the element XmlElement element = doc.CreateElement(prefix, Name, Namespace); element.InnerText = Value; return element; // else, return XmlElement without namespace } } }