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


C# Etag.ToString方法代码示例

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


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

示例1: PerformPost

		public static HttpStatusCode PerformPost(string url, string payload, Etag requestEtag, out Etag responseEtag)
        {
            var request = WebRequest.Create(url);
            
            if (requestEtag != null)
                request.Headers.Add("If-None-Match", requestEtag.ToString());

            request.Method = "POST";

            byte[] buffer = Encoding.UTF8.GetBytes(payload);

            request.GetRequestStream().Write(buffer, 0, buffer.Length);

            using (var response = GetHttpResponseHandle304(request))
            {
                try
                {
                    responseEtag = response.GetEtagHeader();
                }
                catch (Exception)
                {
                    responseEtag = null;
                }

                return response.StatusCode;
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:27,代码来源:ConditionalGetHelper.cs

示例2: PerformGet

		public static HttpStatusCode PerformGet(string url, Etag requestEtag, out Etag responseEtag)
        {
            var getRequest = WebRequest.Create(url);

            if(requestEtag != null)
                getRequest.Headers.Add("If-None-Match", requestEtag.ToString());

            using (var response = GetHttpResponseHandle304(getRequest))
            {
                try
                {
                    responseEtag = response.GetEtagHeader();
                }
                catch (Exception)
                {
                    responseEtag = null;
                }

                return response.StatusCode;
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:21,代码来源:ConditionalGetHelper.cs

示例3: Touch

        public void Touch(string name, string key, UuidType uuidType, out Etag preTouchEtag, out Etag afterTouchEtag)
        {
            var item = Read(name, key);
            if (item == null)
            {
                afterTouchEtag = null;
                preTouchEtag = null;
                return;
            }

            preTouchEtag = item.Etag;

            Remove(name, key);

            afterTouchEtag = generator.CreateSequentialUuid(uuidType);
            var internalKey = afterTouchEtag.ToString();
            var internalKeyAsSlice = (Slice) internalKey;

            tableStorage.Lists.Add(
                writeBatch.Value,
                internalKeyAsSlice,
                new RavenJObject
                {
                    {"name", name},
                    {"key", key},
                    {"etag", afterTouchEtag.ToByteArray()},
                    {"data", item.Data},
                    {"createdAt", item.CreatedAt}
                });

            var listsByName = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByName);
            var listsByNameAndKey = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByNameAndKey);

            var nameKey = CreateKey(name);
            var nameKeySlice = (Slice) nameKey;
            var nameAndKeySlice = (Slice) AppendToKey(nameKey, key);

            listsByName.MultiAdd(writeBatch.Value, nameKeySlice, internalKeyAsSlice);
            listsByNameAndKey.Add(writeBatch.Value, nameAndKeySlice, internalKey);
        }
开发者ID:JudahGabriel,项目名称:ravendb,代码行数:40,代码来源:ListsStorageActions.cs

示例4: 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:bbqchickenrobot,项目名称:ravendb,代码行数:26,代码来源:ListsStorageActions.cs

示例5: WithEtagAndLastModified

 public static Negotiator WithEtagAndLastModified(this Negotiator negotiator, Etag etag, DateTime responseLastModified)
 {
     var currentEtag = etag.ToString();
     return negotiator
         .WithHeader("ETag", currentEtag)
         .WithHeader("Last-Modified", responseLastModified.ToString("R"));
 }
开发者ID:dmitriylyner,项目名称:ServiceControl,代码行数:7,代码来源:NegotiatorExtensions.cs


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