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

C# WriterContext类代码示例

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

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



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

示例1: WriteTo

        protected override void WriteTo(object item, XmlWriter writer, WriterContext context)
        {
            if (item == null)
            throw new ArgumentNullException("item");

              XmlSerializer serializer = GetSerializer(item.GetType());
              serializer.Serialize(writer, item);
        }
开发者ID:JornWildt,项目名称:Ramone,代码行数:8,代码来源:XmlSerializerCodec.cs


示例2: WriteTo

 public void WriteTo(WriterContext context)
 {
   Cat c = (Cat)context.Data;
   using (StreamWriter w = new StreamWriter(context.HttpStream, Encoding.UTF8))
   {
     w.Write(c.Name);
   }
 }
开发者ID:miqui,项目名称:Ramone,代码行数:8,代码来源:CatAsTextCodec.cs


示例3: WriteTo

 public void WriteTo(WriterContext context)
 {
     if (context.Data == null)
     return;
       if (!(context.Data is byte[]))
     throw new ArgumentException(string.Format("Expected byte[] in ByteArrayCodec. Got {0}.", context.Data.GetType()));
       using (Stream input = new MemoryStream((byte[])context.Data))
     input.CopyTo(context.HttpStream);
 }
开发者ID:JornWildt,项目名称:Ramone,代码行数:9,代码来源:ByteArrayCodec.cs


示例4: WriteTo

 public void WriteTo(WriterContext context)
 {
   if (context.Data == null)
     return;
   if (!(context.Data is Stream))
     throw new ArgumentException(string.Format("Expected Stream in StreamCodec. Got {0}.", context.Data.GetType()));
   Stream input = context.Data as Stream;
   input.CopyTo(context.HttpStream);
 }
开发者ID:miqui,项目名称:Ramone,代码行数:9,代码来源:StreamCodec.cs


示例5: WriteTo

 public void WriteTo(WriterContext context)
 {
   Cat c = (Cat)context.Data;
   using (StreamWriter w = new StreamWriter(context.HttpStream, Encoding.UTF8))
   {
     // Absolute meaningless post data
     w.Write(string.Format("<html><body><p>{0}</p></body></html>", c.Name));
   }
 }
开发者ID:miqui,项目名称:Ramone,代码行数:9,代码来源:CatAsHtmlCodec.cs


示例6: WriteTo

    public void WriteTo(WriterContext context)
    {
      if (context.Data == null)
        return;

      Type t = context.Data.GetType();
      MultipartFormDataSerializer Serializer = new MultipartFormDataSerializer(t);

      string charset = context.CodecParameters["Charset"];

      Encoding enc = (charset != null ? Encoding.GetEncoding(charset) : context.Session.DefaultEncoding);

      Serializer.Serialize(context.HttpStream, context.Data, enc, CodecArgument as string, context.Session.SerializerSettings);
    }
开发者ID:miqui,项目名称:Ramone,代码行数:14,代码来源:MultipartFormDataSerializerCodec.cs


示例7: GetWriterContext

		public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language)
		{
			AssemblySpecificContext assemblyContext = new AssemblySpecificContext();
			ModuleSpecificContext moduleContext = new ModuleSpecificContext();
			TypeSpecificContext typeContext = new TypeSpecificContext(Utilities.GetDeclaringTypeOrSelf(member));

			DecompiledType decompiledType = GetDecompiledType(member, language);

			Dictionary<string, MethodSpecificContext> methodContexts = new Dictionary<string, MethodSpecificContext>();
			Dictionary<string, Statement> decompiledStatements = new Dictionary<string, Statement>();

			foreach (KeyValuePair<string, DecompiledMember> decompiledPair in decompiledType.DecompiledMembers)
			{
				methodContexts.Add(decompiledPair.Key, decompiledPair.Value.Context);
				decompiledStatements.Add(decompiledPair.Key, decompiledPair.Value.Statement);
			}

			WriterContext writerContext = new WriterContext(assemblyContext, moduleContext, typeContext, methodContexts, decompiledStatements);

			return writerContext;
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:21,代码来源:FrameworkFoldersWriterContextService.cs


示例8: Write

			protected override void Write (BinaryWriter w, object o, WriterContext ctx)
			{
				w.Write (PrimaryId);
				w.Write ((char) o);
			}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:ObjectStateFormatter.cs


示例9: WriteObjectStart

            public void WriteObjectStart()
            {
                DoValidation (Condition.NotAProperty);
                PutNewline ();

                Put ("{");

                context = new WriterContext ();
                context.InObject = true;
                ctx_stack.Push (context);

                Indent ();
            }
开发者ID:nunun,项目名称:Xnet,代码行数:13,代码来源:JsonWriter.cs


示例10: WriteTo

 protected override void WriteTo(object item, XmlWriter writer, WriterContext context)
 {
   SyndicationItem si = (SyndicationItem)item;
   si.SaveAsAtom10(writer);
 }
开发者ID:miqui,项目名称:Ramone,代码行数:5,代码来源:AtomItemCodec.cs


示例11: WriteObject

			public static void WriteObject (BinaryWriter w, object o, WriterContext ctx)
			{
#if TRACE && !TARGET_J2EE
				if (o != null) {
					Trace.WriteLine (String.Format ("Writing {0} (type: {1})", o, o.GetType ()));
					Trace.Indent ();
				} else {
					Trace.WriteLine ("Writing null");
				}
				long pos = w.BaseStream.Position;
#endif
				
				if (o == null) {
					w.Write ((byte) 0);
					return;
				}
				
				Type t = o.GetType ();
#if TRACE
				Trace.WriteLine (String.Format ("Looking up formatter for type {0}", t));
#endif

				ObjectFormatter fmt = writeMap [t] as ObjectFormatter;
#if TRACE
				Trace.WriteLine (String.Format ("Formatter from writeMap: '{0}'", fmt));
#endif
				if (fmt == null) {
					// Handle abstract types here
					
					if (o is Type)
						fmt = typeFormatter;
					else if (t.IsEnum)
						fmt = enumFormatter;
					else if (t.IsArray && ((Array) o).Rank == 1)
						fmt = singleRankArrayFormatter;
					else {
						TypeConverter converter;
						converter = TypeDescriptor.GetConverter (o);
#if TRACE
						Trace.WriteLine (String.Format ("Type converter: '{0}' (to string: {1}; from {2}: {3})",
										converter,
										converter != null ? converter.CanConvertTo (typeof (string)) : false,
										t,
										converter != null ? converter.CanConvertFrom (t) : false));
#endif
						// Do not use the converter if it's an instance of
						// TypeConverter itself - it reports it is able to
						// convert to string, but it's only a conversion
						// consisting of a call to ToString() with no
						// reverse conversion supported. This leads to
						// problems when deserializing the object.
						if (converter == null || converter.GetType () == typeof (TypeConverter) ||
						    !converter.CanConvertTo (typeof (string)) || !converter.CanConvertFrom (typeof (string)))
							fmt = binaryObjectFormatter;
						else {
							typeConverterFormatter.Converter = converter;
							fmt = typeConverterFormatter;
						}
					}
				}

#if TRACE
				Trace.WriteLine (String.Format ("Writing with formatter '{0}'", fmt.GetType ()));
#endif
				fmt.Write (w, o, ctx);
#if TRACE && !TARGET_J2EE
				Trace.Unindent ();
				Trace.WriteLine (String.Format ("Wrote {0} (type: {1}) {2} bytes", o, o.GetType (), w.BaseStream.Position - pos));
#endif
			}
开发者ID:nlhepler,项目名称:mono,代码行数:70,代码来源:ObjectStateFormatter.cs


示例12: WriteObjectEnd

            public void WriteObjectEnd()
            {
                DoValidation (Condition.InObject);
                PutNewline (false);

                ctx_stack.Pop ();
                if (ctx_stack.Count == 1)
                has_reached_end = true;
                else {
                context = ctx_stack.Peek ();
                context.ExpectingValue = false;
                }

                Unindent ();
                Put ("}");
            }
开发者ID:nunun,项目名称:Xnet,代码行数:16,代码来源:JsonWriter.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# WriterState类代码示例发布时间:2022-05-24
下一篇:
C# Writer类代码示例发布时间: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