当前位置: 首页>>代码示例>>C#>>正文


C# Etag类代码示例

本文整理汇总了C#中Etag的典型用法代码示例。如果您正苦于以下问题:C# Etag类的具体用法?C# Etag怎么用?C# Etag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Etag类属于命名空间,在下文中一共展示了Etag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddAttachment

		public Etag AddAttachment(string key, Etag etag, Stream data, RavenJObject headers)
		{
			AssertValidEtag(key, etag, "PUT");

			if(data	== null)
			{
				var attachment = GetAttachment(key);
				if(attachment == null)
					throw new InvalidOperationException("When adding new attachment, the attachment data must be specified");
				attachment.Metadata = headers;
				return AddAttachment(key, etag, attachment.Data(), headers);
			}

			var ms = new MemoryStream();
			headers.WriteTo(ms);
			data.CopyTo(ms);
			var newEtag = generator.CreateSequentialUuid(UuidType.Attachments);
			var result = storage.Attachments.Put(new RavenJObject
			{
				{"key", key},
				{"etag", newEtag.ToByteArray()}
			}, ms.ToArray());
		   if (result == false)
			   throw new ConcurrencyException("PUT attempted on attachment '" + key + "' while it was locked by another transaction");
			logger.Debug("Adding attachment {0}", key);
			return newEtag;
		}
开发者ID:925coder,项目名称:ravendb,代码行数:27,代码来源:AttachmentsStorageActions.cs

示例2: AfterPut

		public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Etag etag, TransactionInformation transactionInformation)
		{
			VersioningConfiguration versioningConfiguration;
			if (TryGetVersioningConfiguration(key, metadata, out versioningConfiguration) == false)
				return;

			using (Database.DisableAllTriggersForCurrentThread())
			{
				var copyMetadata = new RavenJObject(metadata);
				copyMetadata[VersioningUtil.RavenDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
				copyMetadata[Constants.RavenReadOnly] = true;
				copyMetadata.Remove(VersioningUtil.RavenDocumentRevision);
				object parentRevision;
				metadata.__ExternalState.TryGetValue("Parent-Revision", out parentRevision);
				if (parentRevision != null)
				{
					copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
					copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
				}

				object value;
				metadata.__ExternalState.TryGetValue("Next-Revision", out value);
				Database.Put(key + "/revisions/" + value, null, (RavenJObject)document.CreateSnapshot(), copyMetadata,
							 transactionInformation);
			}
		}
开发者ID:nzaugg,项目名称:ravendb,代码行数:26,代码来源:VersioningPutTrigger.cs

示例3: Read

		public IEnumerable<ListItem> Read(string name, Etag start, Etag end, int take)
		{
			var listsByName = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByName);

			using (var iterator = listsByName.MultiRead(Snapshot, CreateKey(name)))
			{
				if (!iterator.Seek(start.ToString()))
					yield break;

				int count = 0;

				do
				{
					var etag = Etag.Parse(iterator.CurrentKey.ToString());
					if (start.CompareTo(etag) >= 0)
						continue;

					if (end != null && end.CompareTo(etag) <= 0)
						yield break;

					count++;
					yield return ReadInternal(etag);
				}
				while (iterator.MoveNext() && count < take);
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:26,代码来源:ListsStorageActions.cs

示例4: RenameFileOperation

 public RenameFileOperation(string name, string rename, Etag currentEtag, RavenJObject metadataAfterOperation)
 {
     Name = name;
     Rename = rename;
     Etag = currentEtag;
     MetadataAfterOperation = metadataAfterOperation;
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:7,代码来源:RenameFileOperation.cs

示例5: AfterCommit

			public virtual void AfterCommit(
				string key,
				RavenJObject document,
				RavenJObject metadata,
				Etag etag)
			{
			}
开发者ID:modulexcite,项目名称:docs-8,代码行数:7,代码来源:Plugins.cs

示例6: GetIndexEtag

        public Etag GetIndexEtag(string indexName, Etag previousEtag, string resultTransformer = null)
        {
            Etag lastDocEtag = Etag.Empty;
            Etag lastReducedEtag = null;
            bool isStale = false;
            int touchCount = 0;
            TransactionalStorage.Batch(accessor =>
            {
                var indexInstance = Database.IndexStorage.GetIndexInstance(indexName);
                if (indexInstance == null)
                    return;
                isStale = (indexInstance.IsMapIndexingInProgress) ||
                          accessor.Staleness.IsIndexStale(indexInstance.indexId, null, null);
                lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
                var indexStats = accessor.Indexing.GetIndexStats(indexInstance.indexId);
                if (indexStats != null)
                {
                    lastReducedEtag = indexStats.LastReducedEtag;
                }
                touchCount = accessor.Staleness.GetIndexTouchCount(indexInstance.indexId);
            });


            var indexDefinition = GetIndexDefinition(indexName);
            if (indexDefinition == null)
                return Etag.Empty; // this ensures that we will get the normal reaction of IndexNotFound later on.
            using (var md5 = MD5.Create())
            {
                var list = new List<byte>();
                list.AddRange(indexDefinition.GetIndexHash());
                list.AddRange(Encoding.Unicode.GetBytes(indexName));
                if (string.IsNullOrWhiteSpace(resultTransformer) == false)
                {
                    var abstractTransformer = IndexDefinitionStorage.GetTransformer(resultTransformer);
                    if (abstractTransformer == null)
                        throw new InvalidOperationException("The result transformer: " + resultTransformer + " was not found");
                    list.AddRange(abstractTransformer.GetHashCodeBytes());
                }
                list.AddRange(lastDocEtag.ToByteArray());
                list.AddRange(BitConverter.GetBytes(touchCount));
                list.AddRange(BitConverter.GetBytes(isStale));
                if (lastReducedEtag != null)
                {
                    list.AddRange(lastReducedEtag.ToByteArray());
                }

                var indexEtag = Etag.Parse(md5.ComputeHash(list.ToArray()));

                if (previousEtag != null && previousEtag != indexEtag)
                {
                    // the index changed between the time when we got it and the time 
                    // we actually call this, we need to return something random so that
                    // the next time we won't get 304

                    return Etag.InvalidEtag;
                }

                return indexEtag;
            }
        }
开发者ID:randacc,项目名称:ravendb,代码行数:60,代码来源:IndexActions.cs

示例7: StreamToClient

        private void StreamToClient(Stream stream, int pageSize, Etag etag, OrderedPartCollection<AbstractFileReadTrigger> readTriggers)
        {
            using (var cts = new CancellationTokenSource())
            using (var timeout = cts.TimeoutAfter(FileSystemsLandlord.SystemConfiguration.DatabaseOperationTimeout))
            using (var writer = new JsonTextWriter(new StreamWriter(stream)))
            {
                writer.WriteStartObject();
                writer.WritePropertyName("Results");
                writer.WriteStartArray();

                Storage.Batch(accessor =>
                {
                    var files = accessor.GetFilesAfter(etag, pageSize);
                    foreach (var file in files)
                    {
                        if (readTriggers.CanReadFile(file.FullPath, file.Metadata, ReadOperation.Load) == false)
                            continue;

                        timeout.Delay();
                        var doc = RavenJObject.FromObject(file);
                        doc.WriteTo(writer);

                        writer.WriteRaw(Environment.NewLine);
                    }
                });

                writer.WriteEndArray();
                writer.WriteEndObject();
                writer.Flush();
            }
        }
开发者ID:hero106wen,项目名称:ravendb,代码行数:31,代码来源:FilesStreamsController.cs

示例8: AfterUpdate

		public void AfterUpdate(string key, Etag etagBeforeUpdate)
		{
			foreach (var behavior in prefetchingBehaviors)
			{
				behavior.AfterUpdate(key, etagBeforeUpdate);
			}
		}
开发者ID:Nakro,项目名称:ravendb,代码行数:7,代码来源:Prefetcher.cs

示例9: StreamToClient

        private void StreamToClient(Stream stream, int pageSize, Etag etag)
        {
            using (var cts = new CancellationTokenSource())
			using (var timeout = cts.TimeoutAfter(FileSystemsLandlord.SystemConfiguration.DatabaseOperationTimeout))
			using (var writer = new JsonTextWriter(new StreamWriter(stream)))
			{
			    writer.WriteStartObject();
			    writer.WritePropertyName("Results");
			    writer.WriteStartArray();

                Storage.Batch(accessor =>
                {
                    var files = accessor.GetFilesAfter(etag, pageSize);
                    foreach (var file in files)
                    {
                        timeout.Delay();
                        var doc = RavenJObject.FromObject(file);
                        doc.WriteTo(writer);

                        writer.WriteRaw(Environment.NewLine);
                    }
                });

                writer.WriteEndArray();
                writer.WriteEndObject();
                writer.Flush();
			}
        }
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:28,代码来源:FilesStreamsController.cs

示例10: EnsureDocumentEtagMatch

		private Etag EnsureDocumentEtagMatch(string key, Etag etag, string method)
		{
			var existingEtag = Etag.Parse(Api.RetrieveColumn(session, Documents, tableColumnsCache.DocumentsColumns["etag"]));
			if (etag != null)
			{
				Etag next;
				while (etagTouches.TryGetValue(etag, out next))
				{
					etag = next;
				}
				if (existingEtag != etag)
				{
					if (etag == Etag.Empty)
					{
						var metadata = Api.RetrieveColumn(session, Documents, tableColumnsCache.DocumentsColumns["metadata"]).ToJObject();
						if (metadata.ContainsKey(Constants.RavenDeleteMarker) &&
							metadata.Value<bool>(Constants.RavenDeleteMarker))
						{
							return existingEtag;
						}
					}

					throw new ConcurrencyException(method + " attempted on document '" + key +
												   "' using a non current etag")
					{
						ActualETag = existingEtag,
						ExpectedETag = etag
					};
				}
			}
			return existingEtag;
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:32,代码来源:Util.cs

示例11: PeriodicExportStatus

		public PeriodicExportStatus()
		{
			LastDocsEtag = Etag.Empty;
			LastAttachmentsEtag = Etag.Empty;
		    LastDocsDeletionEtag = Etag.Empty;
		    LastAttachmentDeletionEtag = Etag.Empty;
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:7,代码来源:PeriodicBackupSetup.cs

示例12: ExportAttachments

		protected override Task<Etag> ExportAttachments(RavenConnectionStringOptions src, JsonTextWriter jsonWriter, Etag lastEtag, Etag maxEtag)
		{
			if (maxEtag != null)
				throw new ArgumentException("We don't support maxEtag in SmugglerDatabaseApi", maxEtag);

			return base.ExportAttachments(src, jsonWriter, lastEtag, null);
		}
开发者ID:CosminLazar,项目名称:ravendb,代码行数:7,代码来源:SmugglerDatabaseApi.cs

示例13: Get

        public HttpResponseMessage Get(string name)
		{
            name = FileHeader.Canonize(name);
			FileAndPagesInformation fileAndPages = null;
			try
			{
				Storage.Batch(accessor => fileAndPages = accessor.GetFile(name, 0, 0));
			}
			catch (FileNotFoundException)
			{
				log.Debug("File '{0}' was not found", name);
				throw new HttpResponseException(HttpStatusCode.NotFound);
			}

            if (fileAndPages.Metadata.Keys.Contains(SynchronizationConstants.RavenDeleteMarker))
			{
				log.Debug("File '{0}' is not accessible to get (Raven-Delete-Marker set)", name);
				throw new HttpResponseException(HttpStatusCode.NotFound);
			}

            var readingStream = StorageStream.Reading(Storage, name);

            var filename = Path.GetFileName(name);
            var result = StreamResult(filename, readingStream);

            var etag = new Etag(fileAndPages.Metadata.Value<string>(Constants.MetadataEtagField));
            fileAndPages.Metadata.Remove(Constants.MetadataEtagField);
            WriteHeaders(fileAndPages.Metadata, etag, result);

            log.Debug("File '{0}' with etag {1} is being retrieved.", name, etag);

            return result.WithNoCache();
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:33,代码来源:FilesController.cs

示例14: SetCachedDocument

		public void SetCachedDocument(string key, Etag etag, RavenJObject doc, RavenJObject metadata, int size)
		{
			if (skipSettingDocumentInCache)
				return;

			var documentClone = ((RavenJObject)doc.CloneToken());
			documentClone.EnsureCannotBeChangeAndEnableSnapshotting();
			var metadataClone = ((RavenJObject)metadata.CloneToken());
			metadataClone.EnsureCannotBeChangeAndEnableSnapshotting();
			try
			{
				cachedSerializedDocuments.Set("Doc/" + key + "/" + etag, new CachedDocument
				{
					Document = documentClone,
					Metadata = metadataClone,
					Size = size
				}, new CacheItemPolicy
				{
					SlidingExpiration = configuration.MemoryCacheExpiration,
				});
			}
			catch (OverflowException)
			{
				// this is a bug in the framework
				// http://connect.microsoft.com/VisualStudio/feedback/details/735033/memorycache-set-fails-with-overflowexception-exception-when-key-is-u7337-u7f01-u2117-exception-message-negating-the-minimum-value-of-a-twos-complement-number-is-invalid 
				// in this case, we just threat it as uncachable
			}

		}
开发者ID:925coder,项目名称:ravendb,代码行数:29,代码来源:DocumentCacher.cs

示例15: IndexingBatch

		public IndexingBatch(Etag highestEtagInBatch)
		{
			HighestEtagInBatch = highestEtagInBatch;
			Ids = new List<string>();
			Docs = new List<dynamic>();
			SkipDeleteFromIndex = new List<bool>();
		}
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:IndexingBatch.cs


注:本文中的Etag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。