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


C# IHttpEntity类代码示例

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


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


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