Beispiel #1
0
        /// <summary>
        /// 写入AllInOne文件
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="headerMarker"></param>
        /// <param name="spliter"></param>
        /// <param name="encoding"></param>
        public void WriteAsOneFile(Stream stream, string headerMarker = "#", string spliter = "\t", Encoding encoding = null)
        {
            if (encoding == null)
            {
                encoding = Encoding.Default;
            }

            using (StreamWriter writer = new System.IO.StreamWriter(stream, encoding))
            {
                var length = GetMaxTableRowCount();
                for (int i = -1; i < length; i++)
                {
                    foreach (var table in this)
                    {
                        if (table.RowCount == 0)
                        {
                            continue;
                        }

                        if (table.RowCount > i)
                        {
                            if (i == -1)
                            {
                                writer.WriteLine(headerMarker + table.Name + spliter + table.ToSplitedTitleString(spliter));
                                continue;
                            }
                            var row = table.BufferedValues[i];

                            writer.WriteLine(table.Name + spliter + ObjectTableWriter.ToSplitedValueString(row, "", spliter, "G", table.ParamNames));
                        }
                    }
                }
                writer.Flush();
            }
        }
Beispiel #2
0
 /// <summary>
 /// 写入后就释放资源
 /// </summary>
 /// <param name="table"></param>
 /// <param name="path"></param>
 /// <param name="encoding"></param>
 public static void Write(ObjectTableStorage table, Stream path, Encoding encoding = null)
 {
     using (ObjectTableWriter writer = new ObjectTableWriter(path, encoding))
     {
         writer.Write(table);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 写一个表
        /// </summary>
        /// <param name="storage"></param>
        /// <param name="directory"></param>
        public static void WriteTable(ObjectTableStorage storage, string directory)
        {
            var OutputPath = Path.Combine(directory, storage.Name);

            if (!OutputPath.EndsWith(TableExtention, StringComparison.CurrentCultureIgnoreCase))
            {
                OutputPath += TableExtention;
            }

            var writer = new ObjectTableWriter(OutputPath);

            writer.Write(storage);
            writer.CloseStream();
        }