using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;
using System.Web.Script.Serialization;
using Red;
using System.Collections.ObjectModel;
namespace Black
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
using (var istream = File.OpenRead(@"C:\Users\Selvin\Desktop\eve\cb2_t1.black"))
{
using (var br = new BinaryReader(istream))
{
BlackObject root = new BlackObject(istream);
using (var streamwriter = new StreamWriter(@"C:\Users\Selvin\Desktop\eve\result.json", false))
{
var serializer = new JavaScriptSerializer();
serializer.MaxJsonLength *= 2;
serializer.RegisterConverters(new JavaScriptConverter[] { new BlackObject.BlackObjectJSONConverter() });
streamwriter.WriteLine(serializer.Serialize(root));
}
}
};
}
}
}
namespace Red
{
public partial class BlackObject
{
public class BlackObjectJSONConverter : JavaScriptConverter
{
public override object Deserialize(IDictionary dictionary, Type type, JavaScriptSerializer serializer)
{
throw new NotImplementedException();
}
public override IDictionary Serialize(object obj, JavaScriptSerializer serializer)
{
return (obj as BlackObject).dictionary;
}
public override IEnumerable SupportedTypes
{
get{return new ReadOnlyCollection(new Type[] { typeof(BlackObject) });}
}
}
}
}