private static McLockElement GetMcLockElement(OpaqueLockToken lockToken, PropertyInfoCollection propInfoColl) { if (propInfoColl == null) { throw new ArgumentNullException("propInfoColl"); } McLockElement retVal = null; PropertyInfo mcLockDateProp = propInfoColl[PropertyInfo.McLockDateProperty]; if (mcLockDateProp != null) { WebDavDocument document = WebDavDocument.CreateDocument(); McLockDateElement mcLockDateEl = (McLockDateElement) document.ImportNode((XmlElement)mcLockDateProp.Value, true); //Try to find McLock element with same token as lockToken foreach (McLockElement lockEl in mcLockDateEl.GetLocks()) { if (lockEl.Token == lockToken.ToString()) { retVal = lockEl; break; } } } return(retVal); }
/// <summary> /// Gets the properties. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public override Mediachase.Net.Wdom.PropertyInfoCollection GetProperties(Mediachase.Net.Wdom.WebDavElementInfo element) { PropertyInfoCollection retVal = null; PropertyInfo prop = null; WebDavDocument tmpDoc = WebDavDocument.CreateDocument(); if (element == null) { return(retVal); } retVal = new PropertyInfoCollection(); //FileInfo fileInfo = !!!!(FileInfo)element.Tag;!!! WebDavTicket ticket = WebDavTicket.Parse(element.AbsolutePath); WebDavStorageElementPropertiesRow row = GetWebDavStoragePropertyRow(ticket.AbsolutePath.StorageType, ticket.AbsolutePath.UniqueId); if (row != null) { retVal = Mediachase.Ibn.Data.McXmlSerializer.GetObject <PropertyInfoCollection>(row.Value); } #region CreateDefaultProperties foreach (PropertyInfo defaultProp in PropertyInfo.CreateDefaultProperties(element)) { SetPropertyAndSave(retVal, defaultProp, false, false); } #endregion //Add <supportedlock> property if (((int)(WebDavApplication.Class & WebDavServerClass.Class2)) != 0) { prop = PropertyInfo.CreateSupportedLockProperty(); prop.Calculated = false; SetPropertyAndSave(retVal, prop, false, false); } //Add <resourcetype> property prop = PropertyInfo.CreateResourceTypeProperty(element); SetPropertyAndSave(retVal, prop, false, false); //Assign context and set closure to class member retVal.ElementInfo = element; return(retVal); }
/// <summary> /// Gets the active locks. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public override IEnumerable <ActiveLockElement> GetActiveLocks(WebDavElementInfo element) { List <ActiveLockElement> retVal = new List <ActiveLockElement>(); WebDavDocument document = WebDavDocument.CreateDocument(); PropertyInfoCollection collection = GetProperties(element); //Remove obsolete lock WebDavLockManager.RemoveObsoleteLock(this, collection); PropertyInfo lockDiscoveryProp = collection[PropertyInfo.LockDiscoveryProperty]; if (lockDiscoveryProp != null) { LockDiscoveryPropertyElement lockDiscoveryEl = (LockDiscoveryPropertyElement) document.ImportNode((XmlElement)lockDiscoveryProp.Value, true); foreach (ActiveLockElement activeLockEl in lockDiscoveryEl.GetActiveLocks()) { yield return(activeLockEl); } } }