/// <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); } }
/// <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("ddd, dd MMM yyy HH':'mm':'ss 'GMT'"); } 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); } } }
/// <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": case "creationdate": // Older versions of Windows require date to be sent in this now-obsolete // date format. Dates should also always be sent in rfc1123 format as per the // spec. // http://www.greenbytes.de/tech/webdav/webfolder-client-list.html#issue-date-format // http://lists.xml.org/archives/xml-dev/200101/msg00930.html DavPropertyAttribute propertyAttributeUuid = new DavPropertyAttribute { AttributeNamespace = "xmlns", AttributeName = "b", AttributeValue = "urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" }; DavPropertyAttribute propertyAttributeRfc = new DavPropertyAttribute { AttributeNamespace = "b", AttributeName = "dt", AttributeValue = "dateTime.rfc1123" }; _property.Attributes.Add(propertyAttributeUuid); _property.Attributes.Add(propertyAttributeRfc); _property.Value = _propertyValue.ToString(CultureInfo.InvariantCulture.DateTimeFormat.RFC1123Pattern, CultureInfo.InvariantCulture); 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); } } }