コード例 #1
0
ファイル: Datapoint.cs プロジェクト: YHZX2013/exchange_diff
        public void AppendTo(StringBuilder buffer)
        {
            buffer.AppendFormat("{0},", this.Time);
            buffer.AppendFormat("{0},", Datapoint.GetCsvEscapedString(this.Id));
            buffer.AppendFormat("{0},", Datapoint.GetCsvEscapedString(this.Consumers));
            if (this.Keys == null && this.Values == null)
            {
                return;
            }
            string[] array  = this.Keys ?? Datapoint.EmptyStringArray;
            string[] array2 = this.Values ?? Datapoint.EmptyStringArray;
            KeyValuePair <string, string>[] array3 = new KeyValuePair <string, string> [Math.Max(array.Length, array2.Length)];
            for (int i = 0; i < Math.Min(array.Length, array2.Length); i++)
            {
                array3[i] = Datapoint.NewKeyValuePair(array[i], array2[i]);
            }
            if (array.Length > array2.Length)
            {
                for (int j = array3.Length; j < array.Length; j++)
                {
                    array3[j] = Datapoint.NewKeyValuePair(array[j], null);
                }
            }
            else
            {
                for (int k = array3.Length; k < array2.Length; k++)
                {
                    array3[k] = Datapoint.NewKeyValuePair(null, array2[k]);
                }
            }
            bool   flag;
            string text = LogRowFormatter.FormatCollection(array3, true, out flag);

            buffer.Append(flag ? Datapoint.GetCsvEscapedString(text) : text);
        }