Exemple #1
0
        private ActiveLock CreateActiveLock(List <XElement> properties)
        {
            var activeLock =
                new ActiveLock.Builder()
                .WithApplyTo(PropertyValueParser.ParseLockDepth(FindProp("depth", properties)))
                .WithLockScope(PropertyValueParser.ParseLockScope(FindProp("lockscope", properties)))
                .WithLockToken(PropertyValueParser.ParseString(FindProp("locktoken", properties)))
                .WithOwner(PropertyValueParser.ParseOwner(FindProp("owner", properties)))
                .WithLockRoot(PropertyValueParser.ParseString(FindProp("lockroot", properties)))
                .WithTimeout(PropertyValueParser.ParseLockTimeout(FindProp("timeout", properties)))
                .Build();

            return(activeLock);
        }
        private WebDavResource CreateResource(string uri, List <MultiStatusParser.Propstat> propstats)
        {
            var properties      = MultiStatusParser.GetProperties(propstats);
            var resourceBuilder = new WebDavResource.Builder()
                                  .WithActiveLocks(_lockResponseParser.ParseLockDiscovery(FindProp("{DAV:}lockdiscovery", properties)))
                                  .WithContentLanguage(PropertyValueParser.ParseString(FindProp("{DAV:}getcontentlanguage", properties)))
                                  .WithContentLength(PropertyValueParser.ParseLong(FindProp("{DAV:}getcontentlength", properties)))
                                  .WithContentType(PropertyValueParser.ParseString(FindProp("{DAV:}getcontenttype", properties)))
                                  .WithCreationDate(PropertyValueParser.ParseDateTime(FindProp("{DAV:}creationdate", properties)))
                                  .WithDisplayName(PropertyValueParser.ParseString(FindProp("{DAV:}displayname", properties)))
                                  .WithETag(PropertyValueParser.ParseString(FindProp("{DAV:}getetag", properties)))
                                  .WithLastModifiedDate(PropertyValueParser.ParseDateTime(FindProp("{DAV:}getlastmodified", properties)))
                                  .WithProperties(properties.Select(x => new WebDavProperty(x.Name, x.GetInnerXml())).ToList())
                                  .WithPropertyStatuses(MultiStatusParser.GetPropertyStatuses(propstats));

            var isHidden = PropertyValueParser.ParseInteger(FindProp("{DAV:}ishidden", properties)) > 0;

            if (isHidden)
            {
                resourceBuilder.IsHidden();
            }

            var isCollection = PropertyValueParser.ParseInteger(FindProp("{DAV:}iscollection", properties)) > 0 ||
                               PropertyValueParser.ParseResourceType(FindProp("{DAV:}resourcetype", properties)) == ResourceType.Collection;

            if (isCollection)
            {
                resourceBuilder.IsCollection();
                resourceBuilder.WithUri(uri.TrimEnd('/') + "/");
            }
            else
            {
                resourceBuilder.WithUri(uri);
            }
            return(resourceBuilder.Build());
        }