コード例 #1
0
 private static void ExportControl(Control control, JsonWriter writer)
 {
     StringWriter innerWriter = new StringWriter();
     HtmlTextWriter htmlWriter = GetHtmlWriter(innerWriter);
     control.RenderControl(htmlWriter);
     writer.WriteString(innerWriter.ToString());
 }
コード例 #2
0
 protected virtual void ExportTime(DateTime time, JsonWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     writer.WriteString(FormatDateTime(time));
 }
コード例 #3
0
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     if (this._properties.Count == 0)
     {
         writer.WriteString(value.ToString());
     }
     else
     {
         ObjectReferenceTracker tracker = null;
         try
         {
             writer.WriteStartObject();
             int num = 0;
             foreach (PropertyDescriptor descriptor in this._properties)
             {
                 IObjectMemberExporter exporter = ((this._exporters != null) && (num < this._exporters.Length)) ? this._exporters[num++] : null;
                 if (exporter != null)
                 {
                     exporter.Export(context, writer, value);
                 }
                 else
                 {
                     object o = descriptor.GetValue(value);
                     if (!JsonNull.LogicallyEquals(o))
                     {
                         writer.WriteMember(descriptor.Name);
                         if (value.GetType().IsClass && (tracker == null))
                         {
                             tracker = TrackObject(context, value);
                         }
                         context.Export(o, writer);
                     }
                 }
             }
             writer.WriteEndObject();
         }
         finally
         {
             if (tracker != null)
             {
                 tracker.Pop(value);
             }
         }
     }
 }
コード例 #4
0
ファイル: ExportContext.cs プロジェクト: huaminglee/myyyyshop
 public virtual void Export(object value, JsonWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (JsonNull.LogicallyEquals(value))
     {
         writer.WriteNull();
     }
     else
     {
         IExporter exporter = this.FindExporter(value.GetType());
         if (exporter != null)
         {
             exporter.Export(this, value, writer);
         }
         else
         {
             writer.WriteString(value.ToString());
         }
     }
 }
コード例 #5
0
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     writer.WriteString(value.ToString());
 }
コード例 #6
0
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     byte[] inArray = (byte[]) value;
     writer.WriteString(Convert.ToBase64String(inArray));
 }