Esempio n. 1
0
 // Output
 //
 // Outputs the names of the rowset columns in a column separated row and optionally adds their types in a second row.
 //
 public override void Output(IRow row, IUnstructuredWriter output)
 {
     if (_first_row_written) { return; }
     using (StreamWriter streamWriter = new StreamWriter(output.BaseStream, this._encoding))
     {
         streamWriter.NewLine = this._row_delim;
         ISchema schema = row.Schema;
         for (int i = 0; i < schema.Count(); i++)
         {
             var col = schema[i];
             if (i > 0)
             {
                 streamWriter.Write(this._col_delim);
             }
             var val = _quoting ? AddQuotes(col.Name) : col.Name;
             streamWriter.Write(val);
         }
         streamWriter.WriteLine();
         if (_with_types)
         {
             for (int i = 0; i < schema.Count(); i++)
             {
                 var col = schema[i];
                 if (i > 0)
                 {
                     streamWriter.Write(this._col_delim);
                 }
                 var val = _quoting ? AddQuotes(col.Type.FullName) : col.Type.FullName;
                 streamWriter.Write(val);
             }
             streamWriter.WriteLine();
         }
     }
     _first_row_written = true;
 }
Esempio n. 2
0
 public override void Output(IRow input, IUnstructuredWriter output)
 {
     var obj = input.Get<object>(0);
     byte[] imageArray = (byte[])obj;
     using (MemoryStream ms = new MemoryStream(imageArray))
     {
         var image = Image.FromStream(ms);
         image.Save(output.BaseStream, ImageFormat.Jpeg);
     }
 }
Esempio n. 3
0
        /// <summary/>
        public override void                    Output(IRow row, IUnstructuredWriter output)
        {
            // First Row
            if(this.writer == null)
            {
                // Json.Net (writer)
                this.writer = new JsonTextWriter(new StreamWriter(output.BaseStream));
                
                // Header (array)
                this.writer.WriteStartArray();
            }

            // Row(s)
            WriteRow(row, this.writer);
        }
Esempio n. 4
0
        /// <summary>Output is called at least once per instance</summary>
        /// <param name="input">A SQLIP row</param>
        /// <param name="output">Wrapper for a Stream</param>
        public override void Output(IRow input, IUnstructuredWriter output)
        {
            IColumn badColumn = input.Schema.FirstOrDefault(col => col.Type != typeof(string));
            if (badColumn != null)
            {
                throw new ArgumentException(string.Format("Column '{0}' must be of type 'string', not '{1}'", badColumn.Name, badColumn.Type.Name));
            }

            using (var writer = XmlWriter.Create(output.BaseStream, this.fragmentSettings))
            {
                writer.WriteStartElement(this.rowPath);
                foreach (IColumn col in input.Schema)
                {
                    var value = input.Get<string>(col.Name);
                    if (value != null)
                    {
                        // Skip null values in order to distinguish them from empty strings
                        writer.WriteElementString(this.columnPaths[col.Name] ?? col.Name, value);
                    }
                }
            }
        }
Esempio n. 5
0
File: Class1.cs Progetto: Azure/usql
 // void Output(IRow row, IUnstructuredWriter output)
 //
 // Actual implementation of DriverOutputter that overwrites the Output method of IOutputter.
 public override void Output(IRow row, IUnstructuredWriter output)
 {
     using (StreamWriter streamWriter = new StreamWriter(output.BaseStream, this._encoding))
     {
         streamWriter.NewLine = this._row_delim;
         ISchema schema = row.Schema;
         for (int i = 0; i < schema.Count; i++)
         {
             object val = row.Get<object>(i);
             if (i > 0)
             {
                 streamWriter.Write(this._col_delim);
             }
             this.WriteValue(val, streamWriter);
         }
         streamWriter.WriteLine();
     }
 }