/// <summary>
        /// This method gets the metadata for the entity.
        /// </summary>
        /// <param name="blob">The blob.</param>
        /// <param name="response">The response to set the necessary parameters.</param>
        protected virtual void MetadataGet(CloudBlockBlob blob, StorageHolderBase holder)
        {
            holder.Fields = blob.Metadata.ToDictionary((k) => k.Key, (k) => k.Value);

            if (holder.Fields.ContainsKey(cnMetaContentId))
            {
                holder.Id = holder.Fields[cnMetaContentId];
            }

            if (holder.Fields.ContainsKey(cnMetaVersionId))
            {
                holder.VersionId = holder.Fields[cnMetaVersionId];
            }

            if (blob.Properties.LastModified.HasValue)
            {
                holder.LastUpdated = blob.Properties.LastModified.Value.UtcDateTime;
            }

            if (holder.Fields.ContainsKey(cnMetaDeleted))
            {
                holder.IsDeleted = holder.Fields[cnMetaDeleted] == "true";
            }

            holder.ETag            = blob.Properties.ETag;
            holder.ContentType     = blob.Properties.ContentType;
            holder.ContentEncoding = blob.Properties.ContentEncoding;
        }
        /// <summary>
        /// This method sets the appropriate metadata for an entity.
        /// </summary>
        /// <param name="holder">The storage request holder.</param>
        /// <param name="deleted">A property indicating whether the entity has been deleted.</param>
        protected virtual void MetadataSet(CloudBlockBlob blob
                                           , StorageHolderBase holder
                                           , bool deleted = false)
        {
            blob.Metadata.Clear();

            if (holder.Fields != null)
            {
                holder.Fields
                .Where((k) => !(new[] { cnMetaContentId, cnMetaDeleted }).Contains(k.Key))
                .ForEach((k) => MetadataSetItemOrCreate(blob, k.Key, k.Value));
            }

            MetadataSetItemOrCreate(blob, cnMetaContentId, holder.Id);

            if (holder.VersionId != null)
            {
                MetadataSetItemOrCreate(blob, cnMetaVersionId, holder.VersionId);
            }

            blob.Properties.ContentType = holder.ContentType ?? cnDefaultContentType;

            blob.Properties.ContentEncoding = holder.ContentEncoding;

            if (deleted)
            {
                MetadataSetItemOrCreate(blob, cnMetaDeleted, "true");
            }
        }
 public void CopyTo(StorageHolderBase copyto)
 {
     copyto.Id              = Id;
     copyto.VersionId       = VersionId;
     copyto.ContentType     = ContentType;
     copyto.ContentEncoding = ContentEncoding;
     copyto.Fields          = Fields.Select((k) => new { k.Key, k.Value }).ToDictionary((l) => l.Key, (l) => l.Value);
 }