コード例 #1
0
        /// <inheritdoc />
        protected override Task <EntityTag> GetDeadETagAsync(IEntry entry, CancellationToken cancellationToken)
        {
            var       storeData = Load(entry, false, cancellationToken);
            var       entryKey  = GetEntryKey(entry);
            EntryInfo info;

            if (!storeData.Entries.TryGetValue(entryKey, out info))
            {
                info = new EntryInfo();
                storeData.Entries.Add(entryKey, info);
            }

            XElement etagElement;

            if (!info.Attributes.TryGetValue(_etagKey, out etagElement))
            {
                var etag = new EntityTag(false);
                etagElement = etag.ToXml();
                info.Attributes[_etagKey] = etagElement;

                Save(entry, storeData, cancellationToken);

                return(Task.FromResult(etag));
            }

            return(Task.FromResult(EntityTag.FromXml(etagElement)));
        }
コード例 #2
0
        /// <inheritdoc />
        protected override Task <EntityTag> GetDeadETagAsync(IEntry entry, CancellationToken cancellationToken)
        {
            var key  = GetETagProperty.PropertyName;
            var prop = _connection
                       .CreateCommand("SELECT * FROM props WHERE id=?", key)
                       .ExecuteQuery <PropertyEntry>()
                       .FirstOrDefault();

            if (prop == null)
            {
                var etag = new EntityTag(false);
                prop = new PropertyEntry()
                {
                    Id       = CreateId(key, entry),
                    Language = null,
                    Path     = entry.Path.ToString(),
                    XmlName  = key.ToString(),
                    Value    = etag.ToXml().ToString(SaveOptions.OmitDuplicateNamespaces),
                };

                _connection.Insert(prop);
                return(Task.FromResult(etag));
            }

            var result = EntityTag.FromXml(XElement.Parse(prop.Value));

            return(Task.FromResult(result));
        }
コード例 #3
0
        /// <inheritdoc />
        protected override Task <EntityTag> UpdateDeadETagAsync(IEntry entry, CancellationToken cancellationToken)
        {
            var etag = new EntityTag(false);
            var key  = GetETagProperty.PropertyName;
            var prop = new PropertyEntry()
            {
                Id       = CreateId(key, entry),
                Language = null,
                Path     = entry.Path.ToString(),
                XmlName  = key.ToString(),
                Value    = etag.ToXml().ToString(SaveOptions.OmitDuplicateNamespaces),
            };

            _connection.InsertOrReplace(prop);
            return(Task.FromResult(etag));
        }