예제 #1
0
        public void PutStatic(string name, Guid?etag, byte[] data, JObject metadata)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (Encoding.Unicode.GetByteCount(name) >= 255)
            {
                throw new ArgumentException("The key must be a maximum of 255 bytes in unicode, 127 characters", "name");
            }

            Guid newEtag = Guid.Empty;

            TransactionalStorage.Batch(actions =>
            {
                AssertAttachmentPutOperationNotVetoed(name, metadata, data);

                AttachmentPutTriggers.Apply(trigger => trigger.OnPut(name, data, metadata));

                newEtag = actions.Attachments.AddAttachment(name, etag, data, metadata);

                AttachmentPutTriggers.Apply(trigger => trigger.AfterPut(name, data, metadata, newEtag));

                workContext.ShouldNotifyAboutWork();
            });

            TransactionalStorage
            .ExecuteImmediatelyOrRegisterForSyncronization(() => AttachmentPutTriggers.Apply(trigger => trigger.AfterCommit(name, data, metadata, newEtag)));
        }
예제 #2
0
        public void PutStatic(string name, Guid?etag, byte[] data, JObject metadata)
        {
            Guid newEtag = Guid.Empty;

            TransactionalStorage.Batch(actions =>
            {
                AssertAttachmentPutOperationNotVetoed(name, metadata, data);

                AttachmentPutTriggers.Apply(trigger => trigger.OnPut(name, data, metadata));

                newEtag = actions.Attachments.AddAttachment(name, etag, data, metadata);

                AttachmentPutTriggers.Apply(trigger => trigger.AfterPut(name, data, metadata, newEtag));

                workContext.ShouldNotifyAboutWork();
            });

            TransactionalStorage
            .ExecuteImmediatelyOrRegisterForSyncronization(() => AttachmentPutTriggers.Apply(trigger => trigger.AfterCommit(name, data, metadata, newEtag)));
        }