• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IHttpEntity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WriteTo

 public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
 {
   Image image = (Image)entity;
   response.ContentType = image.MediaType;
   image.Data.Seek(0, SeekOrigin.Begin);
   image.Data.WriteTo(response.Stream);
 }
开发者ID:miqui,项目名称:Ramone,代码行数:7,代码来源:ImageCodec.cs


示例2: RenderToResponse

		private static void RenderToResponse(IHttpEntity response, ISparkView templateBase)
		{
			Encoding targetEncoding = Encoding.UTF8;
			response.ContentType.CharSet = targetEncoding.HeaderName;
			TextWriter writer = null;
			bool ownsWriter = false;
			try
			{
				if (response is ISupportsTextWriter)
				{
					writer = ((ISupportsTextWriter) response).TextWriter;
				}
				else
				{
					writer = new DeterministicStreamWriter(response.Stream, targetEncoding, StreamActionOnDispose.None);
					ownsWriter = true;
				}
				templateBase.RenderView(writer);
			}
			finally
			{
				if (ownsWriter)
					writer.Dispose();
			}
		}
开发者ID:tanerst,项目名称:schedumail,代码行数:25,代码来源:SparkCodec.cs


示例3: WriteTo

        public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
        {
            if (entity == null)
                return;

            bool isError = (response.Errors.Count > 0);
            string status = isError ? "error" : "ok";

            var writerSettings = new XmlWriterSettings { OmitXmlDeclaration = true, Encoding = Encoding.UTF8, NamespaceHandling = NamespaceHandling.OmitDuplicates };

            using (var xmlTextWriter = XmlWriter.Create(response.Stream, writerSettings)) {

                xmlTextWriter.WriteStartDocument();
                xmlTextWriter.WriteStartElement("response");
                xmlTextWriter.WriteAttributeString("xsi", "noNamespaceSchemaLocation", "", "http://api.7digital.com/1.2/static/7digitalAPI.xsd");
                xmlTextWriter.WriteAttributeString("status", status);
                xmlTextWriter.WriteAttributeString("version", "1.2");
                xmlTextWriter.WriteAttributeString("xmlns", "xsd", "", "http://www.w3.org/2001/XMLSchema");
                xmlTextWriter.WriteAttributeString("xmlns", "xsi", "", "http://www.w3.org/2001/XMLSchema-instance");

                if (!isError)
                    OutputEntity(entity, xmlTextWriter);
                else
                    OutputError(response, xmlTextWriter);

                xmlTextWriter.WriteEndElement();
            }
        }
开发者ID:gregsochanik,项目名称:RESTfulService,代码行数:28,代码来源:SevenDigitalDataContractCodec.cs


示例4: ReadFrom

 public object ReadFrom(IHttpEntity request, IType destinationType, string destinationName)
 {
   using (var reader = new StreamReader(request.Stream))
   {
     return JsonPatchDocument.Read(reader);
   }
 }
开发者ID:miqui,项目名称:Ramone,代码行数:7,代码来源:JsonPatchDocumentCodec.cs


示例5: WriteTo

 public void WriteTo(object entity, IHttpEntity response, string[] paramneters)
 {
     if (entity == null)
         return;
     DataContractJsonSerializer serializer = new DataContractJsonSerializer(entity.GetType());
     serializer.WriteObject(response.Stream, entity);
 }
开发者ID:rokite,项目名称:openrasta-stable,代码行数:7,代码来源:JsonDataContractCodec.cs


示例6: ReadFrom

        public object ReadFrom(IHttpEntity request, IType destinationType, string parameterName)
        {
            if (destinationType.IsAssignableFrom<IEnumerable<IMultipartHttpEntity>>())
            {
                var multipartReader = new MultipartReader(request.ContentType.Boundary, request.Stream);
                return multipartReader.GetParts();
            }

            if (destinationType.IsAssignableFrom<IDictionary<string, IList<IMultipartHttpEntity>>>())
            {
                return FormData(request);
            }

            var binder = BinderLocator.GetBinder(destinationType);
            
            if (binder == null)
            {
                throw new InvalidOperationException("Cannot find a binder to create the object");
            }

            binder.Prefixes.Add(parameterName);
            bool wasAnyKeyUsed = ReadKeyValues(request).Aggregate(false, (wasUsed, kv) => kv.SetProperty(binder) || wasUsed);
            var result = binder.BuildObject();

            return wasAnyKeyUsed && result.Successful ? result.Instance : Missing.Value;
        }
开发者ID:endjin,项目名称:openrasta-stable,代码行数:26,代码来源:MultipartFormDataObjectCodec.cs


示例7: ReadFrom

        public override object ReadFrom(IHttpEntity request, IType destinationType, string parameterName)
        {
            if (destinationType.StaticType == null)
                throw new InvalidOperationException();

            return new XmlSerializer(destinationType.StaticType).Deserialize(request.Stream);
        }
开发者ID:dhootha,项目名称:openrasta-core,代码行数:7,代码来源:XmlSerializerCodec.cs


示例8: WriteTo

		public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
		{
			var codecParameterList = new List<string>(codecParameters);
			if (!string.IsNullOrEmpty(request.UriName))
				codecParameterList.Add(request.UriName);
			string templateAddress = GetViewVPath(Configuration, codecParameterList.ToArray());
			RenderTemplate(response, templateAddress, entity);
		}
开发者ID:tanerst,项目名称:schedumail,代码行数:8,代码来源:SparkCodec.cs


示例9: WriteJsonp

 private static void WriteJsonp(object entity, IHttpEntity response, string jsonpId)
 {
     var front = Encoding.UTF8.GetBytes(jsonpId + "(");
     response.Stream.Write(front, 0, front.Length);
     WriteJson(entity, response);
     var back = Encoding.UTF8.GetBytes(")");
     response.Stream.Write(back, 0, back.Length);
 }
开发者ID:thatpaulschofield,项目名称:LifeMap,代码行数:8,代码来源:JsonpDataContractCodec.cs


示例10: CheckEntity

 void CheckEntity(IHttpEntity entity, MediaType httpContentType, string expectedContent)
 {
     entity.ContentType
         .Matches(httpContentType)
         .ShouldBeTrue();
     string actualContent = new StreamReader(entity.Stream).ReadToEnd();
     actualContent.ShouldBe(expectedContent);
 }
开发者ID:dhootha,项目名称:openrasta-core,代码行数:8,代码来源:MultipartReader_Specification.cs


示例11: WriteTo

 public void WriteTo(object entity, IHttpEntity response, string[] parameters)
 {
     var entityString = entity.ToString();
     
     var encodedText = Encoding.GetEncoding(EncodingIso88591).GetBytes(entityString);
     response.ContentType = new MediaType("text/plain;charset=ISO-8859-1");
     response.ContentLength = encodedText.Length;
     response.Stream.Write(encodedText, 0, encodedText.Length);
 }
开发者ID:endjin,项目名称:openrasta-stable,代码行数:9,代码来源:TextPlainCodec.cs


示例12: ReadFrom

 public object ReadFrom(IHttpEntity request, OpenRasta.TypeSystem.IType destinationType, string destinationName)
 {
   string text = null;
   using (StreamReader r = new StreamReader(request.Stream, Encoding.UTF8))
   {
     text = r.ReadToEnd();
   }
   return new Cat { Name = text };
 }
开发者ID:miqui,项目名称:Ramone,代码行数:9,代码来源:CatAsHtmlCodec.cs


示例13: WriteTo

    public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
    {
      Cat c = (Cat)entity;

      using (var writer = new StreamWriter(response.Stream))
      {
        writer.Write(string.Format("<html><body><p>{0}</p></body></html>", c.Name));
      }
    }
开发者ID:miqui,项目名称:Ramone,代码行数:9,代码来源:CatAsHtmlCodec.cs


示例14: WriteTo

    public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
    {
      Cat c = (Cat)entity;

      using (var writer = new StreamWriter(response.Stream))
      {
        writer.Write(c.Name);
      }
    }
开发者ID:miqui,项目名称:Ramone,代码行数:9,代码来源:CatAsTextCodec.cs


示例15: ReadFrom

 public object ReadFrom(IHttpEntity request, IType destinationType, string paramName)
 {
     if (destinationType.StaticType == null)
     {
         throw new InvalidOperationException();
     }
     
     return new DataContractJsonSerializer(destinationType.StaticType).ReadObject(request.Stream);
 }
开发者ID:endjin,项目名称:openrasta-stable,代码行数:9,代码来源:JsonDataContractCodec.cs


示例16: TryAssignKeyValues

 public static bool TryAssignKeyValues(this ICodec codec, IHttpEntity entity, IObjectBinder binder, Action<KeyedValues> assigned, Action<KeyedValues> failed)
 {
     return codec.ReadKeyValues(entity)
                 .AsObservable(x => from kv in x
                                   where kv.SetProperty(binder)
                                   select kv, 
                               assigned, 
                               failed)
                 .Count() > 0;
 }
开发者ID:dhootha,项目名称:openrasta-core,代码行数:10,代码来源:CodecExtensions.cs


示例17: WriteTo

 public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
 {
     if (entity == null)
         return;
     var json = JsonConvert.SerializeObject(entity);
     using(var writer = new StreamWriter(response.Stream))
     {
         writer.Write(json);
     }
 }
开发者ID:dineshkummarc,项目名称:Session--15--.NET-Web-Frameworks,代码行数:10,代码来源:Configuration.cs


示例18: Write

 public void Write(IHttpEntity formDataField)
 {
     WriteLine();
     WriteBoundary();
     foreach (var header in formDataField.Headers)
         WriteHeader(header);
     WriteContentLength(formDataField);
     WriteLine();
     WriteBody(formDataField);
 }
开发者ID:dhootha,项目名称:openrasta-core,代码行数:10,代码来源:MultipartWriter.cs


示例19: OutputError

 private static void OutputError(IHttpEntity response, XmlWriter xmlTextWriter)
 {
     xmlTextWriter.WriteStartElement("error", "");
     foreach (var error in response.Errors) {
         xmlTextWriter.WriteStartElement("errorMessage");
         xmlTextWriter.WriteAttributeString("code", "1001");
         xmlTextWriter.WriteString(error.Message);
         xmlTextWriter.WriteEndElement();
     }
     xmlTextWriter.WriteEndElement();
 }
开发者ID:gregsochanik,项目名称:RESTfulService,代码行数:11,代码来源:SevenDigitalDataContractCodec.cs


示例20: WriteTo

    public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
    {
      string text = entity as string;
      if (text == null)
        throw new ArgumentException("Entity was not a string", "entity");

      using (var writer = new StreamWriter(response.Stream))
      {
        writer.Write(text);
      }
    }
开发者ID:miqui,项目名称:Ramone,代码行数:11,代码来源:TextCodec.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IHttpHandler类代码示例发布时间:2022-05-24
下一篇:
C# IHttpContextAccessor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap