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


C# IHttpContext.GetEtagFromQueryString方法代码示例

本文整理汇总了C#中IHttpContext.GetEtagFromQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpContext.GetEtagFromQueryString方法的具体用法?C# IHttpContext.GetEtagFromQueryString怎么用?C# IHttpContext.GetEtagFromQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHttpContext的用法示例。


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

示例1: Respond

		public override void Respond(IHttpContext context)
		{
			var array = Database.GetAttachments(context.GetStart(), 
			                                   context.GetPageSize(Database.Configuration.MaxPageSize),
			                                   context.GetEtagFromQueryString());
			context.WriteJson(array);
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:7,代码来源:Statics.cs

示例2: Respond

		public override void Respond(IHttpContext context)
		{
			switch (context.Request.HttpMethod)
			{
				case "GET":
					long documentsCount = 0;
					Etag lastDocEtag = Etag.Empty;
					Database.TransactionalStorage.Batch(accessor =>
					{
						lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
						documentsCount = accessor.Documents.GetDocumentsCount();
					});

					lastDocEtag = lastDocEtag.HashWith(BitConverter.GetBytes(documentsCount));
					if (context.MatchEtag(lastDocEtag))
					{
						context.SetStatusToNotModified();
					}
					else
					{
						context.WriteHeaders(new RavenJObject(), lastDocEtag);

						using (var cts = new CancellationTokenSource())
						{
							cts.TimeoutAfter(Settings.DatbaseOperationTimeout);

							var startsWith = context.Request.QueryString["startsWith"];
							if (string.IsNullOrEmpty(startsWith))
								context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString(), cts.Token));
							else
								context.WriteJson(Database.GetDocumentsWithIdStartingWith(
									startsWith,
									context.Request.QueryString["matches"],
									context.Request.QueryString["exclude"],
									context.GetStart(),
									context.GetPageSize(Database.Configuration.MaxPageSize), 
									cts.Token));
						}
					}
					break;
				case "POST":
					var json = context.ReadJson();
					var id = Database.Put(null, Etag.Empty, json,
					                      context.Request.Headers.FilterHeaders(),
					                      GetRequestTransaction(context));
					context.SetStatusToCreated("/docs/" + Uri.EscapeUriString(id.Key));
					context.WriteJson(id);
					break;
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:50,代码来源:Docs.cs

示例3: Respond

		public override void Respond(IHttpContext context)
		{
			switch (context.Request.HttpMethod)
			{
				case "GET":
					long documentsCount = 0;
					Guid lastDocEtag = Guid.Empty;
					Database.TransactionalStorage.Batch(accessor =>
					{
						lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
						documentsCount = accessor.Documents.GetDocumentsCount();
					});

					var array = lastDocEtag.ToByteArray().Concat(BitConverter.GetBytes(documentsCount)).ToArray();
					using (var md5 = MD5.Create())
					{
						var hashed = md5.ComputeHash(array);
						lastDocEtag = new Guid(hashed);
					}

					if (context.MatchEtag(lastDocEtag))
					{
						context.SetStatusToNotModified();
					}
					else
					{
						context.WriteHeaders(new RavenJObject(), lastDocEtag);

						var startsWith = context.Request.QueryString["startsWith"];
						if (string.IsNullOrEmpty(startsWith))
							context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString()));
						else
							context.WriteJson(Database.GetDocumentsWithIdStartingWith(
								startsWith,
								context.Request.QueryString["matches"],
								context.GetStart(),
								context.GetPageSize(Database.Configuration.MaxPageSize)));
					}
					break;
				case "POST":
					var json = context.ReadJson();
					var id = Database.Put(null, Guid.Empty, json,
					                      context.Request.Headers.FilterHeaders(),
					                      GetRequestTransaction(context));
					context.SetStatusToCreated("/docs/" + Uri.EscapeUriString(id.Key));
					context.WriteJson(id);
					break;
			}
		}
开发者ID:nberardi,项目名称:ravendb,代码行数:49,代码来源:Docs.cs

示例4: Respond

		public override void Respond(IHttpContext context)
		{
			using (context.Response.Streaming())
			{
				context.Response.ContentType = "application/json; charset=utf-8";

				using (var writer = new JsonTextWriter(new StreamWriter(context.Response.OutputStream)))
				{
					writer.WriteStartObject();
					writer.WritePropertyName("Results");
					writer.WriteStartArray();

					Database.TransactionalStorage.Batch(accessor =>
					{
						var startsWith = context.Request.QueryString["startsWith"];
						int pageSize = context.GetPageSize(int.MaxValue);
						if (string.IsNullOrEmpty(context.Request.QueryString["pageSize"]))
							pageSize = int.MaxValue;

						// we may be sending a LOT of documents to the user, and most 
						// of them aren't going to be relevant for other ops, so we are going to skip
						// the cache for that, to avoid filling it up very quickly
						using (DocumentCacher.SkipSettingDocumentsInDocumentCache())
						{
							if (string.IsNullOrEmpty(startsWith))
							{
								Database.GetDocuments(context.GetStart(), pageSize, context.GetEtagFromQueryString(),
								                      doc => doc.WriteTo(writer));
							}
							else
							{
								Database.GetDocumentsWithIdStartingWith(
									startsWith,
									context.Request.QueryString["matches"],
                                    context.Request.QueryString["exclude"],
									context.GetStart(),
									pageSize,
									doc => doc.WriteTo(writer));
							}
						}
					});

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

示例5: Respond

		public override void Respond(IHttpContext context)
		{
			switch (context.Request.HttpMethod)
			{
				case "GET":
					context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString()));
					break;
				case "POST":
					var json = context.ReadJson();
					var id = Database.Put(null, Guid.NewGuid(), json,
										  context.Request.Headers.FilterHeaders(isServerDocument: true),
                                          GetRequestTransaction(context));
					context.SetStatusToCreated("/docs/" + id);
					context.WriteJson(id);
					break;
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:17,代码来源:Docs.cs

示例6: Respond

        public override void Respond(IHttpContext context)
        {
            var match = urlMatcher.Match(context.GetRequestUrl());

            var queue = match.Groups[1].Value;
            var etag = context.GetEtagFromQueryString() ?? Guid.Empty;
            var pageSize = context.GetPageSize(Configuration.MaxPageSize);
            TimeSpan timeout = context.GetTimeout(TimeSpan.FromMinutes(3));

            context.WriteJson(Queues.Read(new ReadRequest
            {
              HideTimeout  = timeout,
              LastMessageId = etag,
              PageSize = pageSize,
              Queue = queue
            }));
        }
开发者ID:nieve,项目名称:ravenmq,代码行数:17,代码来源:Messages.cs

示例7: Respond

		public override void Respond(IHttpContext context)
		{
			switch (context.Request.HttpMethod)
			{
				case "GET":
					Guid lastDocEtag = Guid.Empty;
					Database.TransactionalStorage.Batch(accessor =>
					{
						lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
					});

					if (context.MatchEtag(lastDocEtag))
					{
						context.SetStatusToNotModified();
					}
					else
					{
						context.WriteHeaders(new RavenJObject(), lastDocEtag);

						var startsWith = context.Request.QueryString["startsWith"];
						if (string.IsNullOrEmpty(startsWith))
							context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString()));
						else
							context.WriteJson(Database.GetDocumentsWithIdStartingWith(
								startsWith,
								context.Request.QueryString["matches"],
								context.GetStart(),
								context.GetPageSize(Database.Configuration.MaxPageSize)));
					}
					break;
				case "POST":
					var json = context.ReadJson();
					var id = Database.Put(null, Guid.Empty, json,
										  context.Request.Headers.FilterHeaders(),
										  GetRequestTransaction(context));
					context.SetStatusToCreated("/docs/" + Uri.EscapeUriString(id.Key));
					context.WriteJson(id);
					break;
			}
		}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:40,代码来源:Docs.cs

示例8: Respond

		public override void Respond(IHttpContext context)
		{
			context.Response.BufferOutput = false;
		
			using (var writer = new JsonTextWriter(new StreamWriter(context.Response.OutputStream)))
			{
				writer.WriteStartObject();
				writer.WritePropertyName("Results");
				writer.WriteStartArray();

				Database.TransactionalStorage.Batch(accessor =>
				{
					var startsWith = context.Request.QueryString["startsWith"];
					int pageSize = context.GetPageSize(int.MaxValue);
					if (string.IsNullOrEmpty(context.Request.QueryString["pageSize"]))
						pageSize = int.MaxValue;

					if (string.IsNullOrEmpty(startsWith))
					{
						Database.GetDocuments(context.GetStart(), pageSize, context.GetEtagFromQueryString(), 
							doc => doc.WriteTo(writer));
					}
					else
					{
						Database.GetDocumentsWithIdStartingWith(
							startsWith,
							context.Request.QueryString["matches"],
							context.GetStart(),
							pageSize,
							doc => doc.WriteTo(writer));
					}
				});

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

示例9: GetIndexMappedResult

		private void GetIndexMappedResult(IHttpContext context, string index)
		{
			if(Database.IndexDefinitionStorage.GetIndexDefinition(index)==null)
			{
				context.SetStatusToNotFound();
				return;
			}

			var etag = context.GetEtagFromQueryString() ?? Guid.Empty;
			List<MappedResultInfo> mappedResult = null;
			Database.TransactionalStorage.Batch(accessor =>
			{
				mappedResult = accessor.MappedResults.GetMappedResultsReduceKeysAfter(index, etag, 
					loadData: true, 
					take: context.GetPageSize(Settings.MaxPageSize))
					.ToList();
			});
			context.WriteJson(mappedResult);
		}
开发者ID:alwin,项目名称:ravendb,代码行数:19,代码来源:Index.cs


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