/// <summary> /// DavProperty Clone /// </summary> /// <remarks>Deep copy</remarks> /// <returns></returns> public DavProperty Clone() { // Start with a flat, memberwise copy DavProperty _davProperty = (DavProperty)this.MemberwiseClone(); // Then deep-copy everything that needs the _davProperty.__attributes = this.Attributes.Clone(); _davProperty.__nestedProperties = this.NestedProperties.Clone(); return(_davProperty); }
/// <summary> /// Retrieve resource property values /// </summary> /// <param name="requestedProperties"></param> /// <param name="validProperties"></param> /// <param name="invalidProperties"></param> public virtual void GetPropertyValues(DavPropertyCollection requestedProperties, DavPropertyCollection validProperties, DavPropertyCollection invalidProperties) { if (validProperties == null) throw new ArgumentNullException("validProperties", InternalFunctions.GetResourceString("ArgumentNullException", "ValidProperties")); else if (invalidProperties == null) throw new ArgumentNullException("invalidProperties", InternalFunctions.GetResourceString("ArgumentNullException", "InvalidProperties")); //Clear out all the properties validProperties.Clear(); invalidProperties.Clear(); //Requesting ALL available properties DavPropertyCollection _requestedProperties; if (requestedProperties == null) _requestedProperties = this.ResourceProperties.Clone(); else _requestedProperties = requestedProperties.Clone(); //Check to see if there is a valid property foreach (DavProperty _property in _requestedProperties) { string _propertyName = _property.Name ?? ""; if (_propertyName.ToLower(CultureInfo.InvariantCulture).StartsWith("get")) _propertyName = _propertyName.Substring(3); if (this.__classProperties.ContainsKey(_propertyName)) { PropertyInfo _resourceProperty = this.__classProperties[_propertyName] as PropertyInfo; if (_resourceProperty != null) { if (_resourceProperty.PropertyType == typeof(XPathNavigator)) { XPathNavigator _propertyValue = (XPathNavigator)_resourceProperty.GetValue(this, null); if (_propertyValue != null) validProperties.Add(new DavProperty(_propertyValue)); } else if (_resourceProperty.PropertyType == typeof(ResourceType)) { ResourceType _resource = (ResourceType)_resourceProperty.GetValue(this, null); switch (_resource) { case ResourceType.Collection: DavProperty _folderResourceType = new DavProperty("resourcetype", "DAV:"); _folderResourceType.NestedProperties.Add(new DavProperty("collection", "DAV:")); validProperties.Add(_folderResourceType); break; //case ResourceType.Resource: // //DavProperty _fileResourceType = new DavProperty("resourcetype", "DAV:"); // //validProperties.Add(_fileResourceType); // break; } } else if (_resourceProperty.PropertyType == typeof(bool)) { bool _propertyValue = (bool)_resourceProperty.GetValue(this, null); if (_propertyValue) validProperties.Add(_property); else invalidProperties.Add(_property); } else if (_resourceProperty.PropertyType == typeof(DateTime)) { DateTime _propertyValue = (DateTime)_resourceProperty.GetValue(this, null); if (_propertyValue != DateTime.MinValue) { switch (_resourceProperty.Name.ToLower(CultureInfo.InvariantCulture)) { case "lastmodified": { //DavPropertyAttribute _propertyAttribute = new DavPropertyAttribute(); //_propertyAttribute.AttributeName = "dt"; //_propertyAttribute.AttributeNamespace = "b"; //_propertyAttribute.AttributeValue = "dateTime.rfc1123"; //_property.Attributes.Add(_propertyAttribute); //_property.Value = _propertyValue.ToString("r", CultureInfo.InvariantCulture); //_property.Value = _propertyValue.ToString(CultureInfo.InvariantCulture.DateTimeFormat.RFC1123Pattern, CultureInfo.InvariantCulture); _property.Value = _propertyValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"); } break; case "creationdate": { //DavPropertyAttribute _propertyAttribute = new DavPropertyAttribute(); //_propertyAttribute.AttributeName = "dt"; //_propertyAttribute.AttributeNamespace = "b"; //_propertyAttribute.AttributeValue = "dateTime.tz"; //_property.Attributes.Add(_propertyAttribute); //_property.Value = this.__creationDate.ToString("s", CultureInfo.InvariantCulture); _property.Value = _propertyValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"); } break; } validProperties.Add(_property); } else invalidProperties.Add(_property); } else { string _resourceValue = _resourceProperty.GetValue(this, null).ToString(); if (_resourceValue != null && _resourceValue.Length > 0) { _property.Value = _resourceValue; validProperties.Add(_property); } else invalidProperties.Add(_property); } } } else if (this.CustomProperties[_propertyName] != null) validProperties.Add(_property); else invalidProperties.Add(_property); } }