Raven.Storage.Managed.TransactionStorageActions.AssertValidEtag C# (CSharp) Method

AssertValidEtag() private static method

private static AssertValidEtag ( string key, Table doc, Table docInTx, System.Guid etag ) : void
key string
doc Table
docInTx Table
etag System.Guid
return void
		private static void AssertValidEtag(string key, Table.ReadResult doc, Table.ReadResult docInTx, Guid? etag)
		{
			if (doc == null)
				return;
			var existingEtag =
				docInTx != null
					? new Guid(docInTx.Key.Value<byte[]>("etag"))
					: new Guid(doc.Key.Value<byte[]>("etag"));


			if (etag != null && etag.Value != existingEtag)
			{
				throw new ConcurrencyException("PUT attempted on document '" + key +
											   "' using a non current etag")
				{
					ActualETag = existingEtag,
					ExpectedETag = etag.Value
				};
			}
		}