Merge pull request #130 from dwango/fix_formatter_clear

Fixed IFormatter.Clear that JsonFormatter.Clear dose not called.
This commit is contained in:
ousttrue 2019-01-20 15:55:30 +09:00 committed by GitHub
commit bf52efeb5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View File

@ -43,5 +43,16 @@ namespace UniJSON
Assert.True(json.GetStoreBytes().ToEnumerable().SequenceEqual(bytes));
}
}
[Test]
public void ReUseFormatter()
{
IFormatter f = new JsonFormatter();
f.Value(1);
f.Clear();
// fail
f.Value(2);
}
}
}

View File

@ -9,11 +9,6 @@ namespace UniJSON
{
public static partial class FormatterExtensions
{
public static void Clear(this IFormatter f)
{
f.GetStore().Clear();
}
public static ArraySegment<Byte> GetStoreBytes(this IFormatter f)
{
return f.GetStore().Bytes;

View File

@ -6,6 +6,7 @@ namespace UniJSON
public interface IFormatter
{
IStore GetStore();
void Clear();
void BeginList(int n);
void EndList();

View File

@ -1,5 +1,4 @@
using System;
using System.Text;
namespace UniJSON
@ -16,6 +15,11 @@ namespace UniJSON
{
}
public void Clear()
{
m_store.Clear();
}
#if false
public bool MsgPack_Ext(IList list)
{