diff --git a/Sunfish/Sunfish/FServiceConf.Designer.cs b/Sunfish/Sunfish/FServiceConf.Designer.cs
new file mode 100644
index 0000000..2ec6df4
--- /dev/null
+++ b/Sunfish/Sunfish/FServiceConf.Designer.cs
@@ -0,0 +1,113 @@
+namespace DolphinWebXplorer2
+{
+ partial class FServiceConf
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.lbType = new System.Windows.Forms.Label();
+ this.cbType = new System.Windows.Forms.ComboBox();
+ this.lbName = new System.Windows.Forms.Label();
+ this.tbName = new System.Windows.Forms.TextBox();
+ this.cbActive = new System.Windows.Forms.CheckBox();
+ this.SuspendLayout();
+ //
+ // lbType
+ //
+ this.lbType.AutoSize = true;
+ this.lbType.Location = new System.Drawing.Point(12, 9);
+ this.lbType.Name = "lbType";
+ this.lbType.Size = new System.Drawing.Size(47, 20);
+ this.lbType.TabIndex = 0;
+ this.lbType.Text = "Type:";
+ //
+ // cbType
+ //
+ this.cbType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbType.FormattingEnabled = true;
+ this.cbType.Location = new System.Drawing.Point(25, 32);
+ this.cbType.Name = "cbType";
+ this.cbType.Size = new System.Drawing.Size(353, 28);
+ this.cbType.TabIndex = 1;
+ //
+ // lbName
+ //
+ this.lbName.AutoSize = true;
+ this.lbName.Location = new System.Drawing.Point(12, 77);
+ this.lbName.Name = "lbName";
+ this.lbName.Size = new System.Drawing.Size(55, 20);
+ this.lbName.TabIndex = 2;
+ this.lbName.Text = "Name:";
+ //
+ // tbName
+ //
+ this.tbName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tbName.Location = new System.Drawing.Point(25, 100);
+ this.tbName.Name = "tbName";
+ this.tbName.Size = new System.Drawing.Size(269, 26);
+ this.tbName.TabIndex = 3;
+ //
+ // cbActive
+ //
+ this.cbActive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.cbActive.AutoSize = true;
+ this.cbActive.Location = new System.Drawing.Point(300, 102);
+ this.cbActive.Name = "cbActive";
+ this.cbActive.Size = new System.Drawing.Size(78, 24);
+ this.cbActive.TabIndex = 4;
+ this.cbActive.Text = "Active";
+ this.cbActive.UseVisualStyleBackColor = true;
+ //
+ // FServiceConf
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(401, 408);
+ this.Controls.Add(this.cbActive);
+ this.Controls.Add(this.tbName);
+ this.Controls.Add(this.lbName);
+ this.Controls.Add(this.cbType);
+ this.Controls.Add(this.lbType);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "FServiceConf";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Service";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label lbType;
+ private System.Windows.Forms.ComboBox cbType;
+ private System.Windows.Forms.Label lbName;
+ private System.Windows.Forms.TextBox tbName;
+ private System.Windows.Forms.CheckBox cbActive;
+ }
+}
\ No newline at end of file
diff --git a/Sunfish/Sunfish/FServiceConf.cs b/Sunfish/Sunfish/FServiceConf.cs
new file mode 100644
index 0000000..49bb880
--- /dev/null
+++ b/Sunfish/Sunfish/FServiceConf.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace DolphinWebXplorer2
+{
+ public partial class FServiceConf : Form
+ {
+ public FServiceConf()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Sunfish/Sunfish/FServiceConf.resx b/Sunfish/Sunfish/FServiceConf.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Sunfish/Sunfish/FServiceConf.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Sunfish/Sunfish/Form1.Designer.cs b/Sunfish/Sunfish/Form1.Designer.cs
index 120b6c5..88f8d28 100644
--- a/Sunfish/Sunfish/Form1.Designer.cs
+++ b/Sunfish/Sunfish/Form1.Designer.cs
@@ -48,6 +48,7 @@
this.cmsGOptions = new System.Windows.Forms.ContextMenuStrip(this.components);
this.shareScreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tstbPassword = new System.Windows.Forms.ToolStripTextBox();
+ this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nudPort)).BeginInit();
this.cmsItem.SuspendLayout();
this.cmsGOptions.SuspendLayout();
@@ -254,11 +255,22 @@
this.tstbPassword.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tstbPassword_KeyPress);
this.tstbPassword.TextChanged += new System.EventHandler(this.tstbPassword_TextChanged);
//
+ // button2
+ //
+ this.button2.Location = new System.Drawing.Point(9, 9);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(103, 32);
+ this.button2.TabIndex = 10;
+ this.button2.Text = "Test 2";
+ this.button2.UseVisualStyleBackColor = true;
+ this.button2.Click += new System.EventHandler(this.button2_Click_1);
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(360, 558);
+ this.Controls.Add(this.button2);
this.Controls.Add(this.btGeneralOptions);
this.Controls.Add(this.btShowIp);
this.Controls.Add(this.lbPaths);
@@ -303,6 +315,7 @@
private System.Windows.Forms.ToolStripMenuItem añadirToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem borrarToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
+ private System.Windows.Forms.Button button2;
}
}
diff --git a/Sunfish/Sunfish/Form1.cs b/Sunfish/Sunfish/Form1.cs
index e42b13a..979d2fb 100644
--- a/Sunfish/Sunfish/Form1.cs
+++ b/Sunfish/Sunfish/Form1.cs
@@ -14,7 +14,6 @@
{
public partial class Form1 : Form
{
- public const string conffile = "sunfish";
public Font smallfont;
public Brush itembrushgray;
private Screen myscreen;
@@ -24,10 +23,6 @@
itembrushgray = new SolidBrush(Color.Gray);
smallfont = new Font(Font.FontFamily, 7, FontStyle.Regular);
Icon = Resources.sunfishWebServer;
- if (File.Exists(conffile))
- {
- WebXplorer.Load(conffile);
- }
PopulateData();
Text += " " + Program.VERSION;
myscreen = Screen.FromControl(this);
@@ -36,10 +31,8 @@
private void PopulateData()
{
Enabled = false;
- nudPort.Value = WebXplorer.Port;
- cbActive.Checked = WebXplorer.Active;
- shareScreenToolStripMenuItem.Checked = WebXplorer.SharedScreen;
- tstbPassword.Text = WebXplorer.SharedScreenPassword;
+ nudPort.Value = Sunfish.Port;
+ cbActive.Checked = Sunfish.Active;
lbPaths.Items.Clear();
foreach (WShared sh in WebXplorer.Shares)
lbPaths.Items.Add(sh);
@@ -66,8 +59,7 @@
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
- WebXplorer.Save(conffile);
- WebXplorer.Stop();
+ Sunfish.Active = false;
}
private void cbActive_CheckedChanged(object sender, EventArgs e)
@@ -262,8 +254,9 @@
}
}
- private void button2_Click(object sender, EventArgs e)
+ private void button2_Click_1(object sender, EventArgs e)
{
+ Sunfish.Save();
}
}
}
diff --git a/Sunfish/Sunfish/Form1.resx b/Sunfish/Sunfish/Form1.resx
index 012af4b..9f39972 100644
--- a/Sunfish/Sunfish/Form1.resx
+++ b/Sunfish/Sunfish/Form1.resx
@@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAq
- AQAAAk1TRnQBSQFMAgEBAgEAAWABAAFgAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA
+ AQAAAk1TRnQBSQFMAgEBAgEAAWgBAAFoAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA
AwABEAMAAQEBAAEEBgABAhgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/
AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP//wD/AAMAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB
BQABgBcAA/8BAAT/BAAE/wQABP8EAAH8AT8C/wQAAfwBPwL/BAAB/AE/Av8EAAHgAQcB4AEHBAAB4AEH
@@ -136,6 +136,9 @@
BAAL
+
+ 17, 17
+
185, 17
diff --git a/Sunfish/Sunfish/Library/Json.Net/IJsonConverter.cs b/Sunfish/Sunfish/Library/Json.Net/IJsonConverter.cs
new file mode 100644
index 0000000..81836af
--- /dev/null
+++ b/Sunfish/Sunfish/Library/Json.Net/IJsonConverter.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace Json.Net
+{
+ ///
+ /// Converter interface
+ ///
+ public interface IJsonConverter
+ {
+ Type GetConvertingType();
+ string Serializer(object obj);
+ object Deserializer(string txt);
+ }
+}
diff --git a/Sunfish/Sunfish/Library/Json.Net/IPropertyNameTransform.cs b/Sunfish/Sunfish/Library/Json.Net/IPropertyNameTransform.cs
new file mode 100644
index 0000000..8fb26c3
--- /dev/null
+++ b/Sunfish/Sunfish/Library/Json.Net/IPropertyNameTransform.cs
@@ -0,0 +1,7 @@
+namespace Json.Net
+{
+ public interface IPropertyNameTransform
+ {
+ string Transform(string propertyName);
+ }
+}
diff --git a/Sunfish/Sunfish/Library/Json.Net/JsonConverter.cs b/Sunfish/Sunfish/Library/Json.Net/JsonConverter.cs
new file mode 100644
index 0000000..9ba36da
--- /dev/null
+++ b/Sunfish/Sunfish/Library/Json.Net/JsonConverter.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Json.Net
+{
+ ///
+ /// Custom type converter for serializer and deserializer
+ ///
+ ///
+ public class JsonConverter : IJsonConverter
+ {
+ public JsonConverter(
+ Func serializer,
+ Func deserializer)
+ {
+ Serializer = serializer;
+ Deserializer = deserializer;
+ }
+
+ public Func Serializer;
+ public Func Deserializer;
+
+ Type IJsonConverter.GetConvertingType()
+ {
+ return typeof(T);
+ }
+
+ string IJsonConverter.Serializer(object obj)
+ {
+ return Serializer((T)obj);
+ }
+
+ object IJsonConverter.Deserializer(string txt)
+ {
+ return Deserializer(txt);
+ }
+ }
+}
diff --git a/Sunfish/Sunfish/Library/Json.Net/JsonNet.cs b/Sunfish/Sunfish/Library/Json.Net/JsonNet.cs
new file mode 100644
index 0000000..a075e26
--- /dev/null
+++ b/Sunfish/Sunfish/Library/Json.Net/JsonNet.cs
@@ -0,0 +1,262 @@
+using System.IO;
+using System.Text;
+
+namespace Json.Net
+{
+ ///
+ /// Json.Net Helper Class
+ ///
+ public static class JsonNet
+ {
+ ///
+ /// Deserializes an object from a JSON text.
+ ///
+ /// Deserialized object's type
+ /// JSON text
+ /// Serialization options.
+ ///
+ public static T Deserialize(string json, SerializationOptions options = null)
+ {
+ return (T)JsonParser.Instance.Initialize(json, options)
+ .FromJson(typeof(T));
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text stream.
+ ///
+ /// Deserialized object's type
+ /// Source JSON text stream
+ /// Serialization options.
+ ///
+ public static T Deserialize(Stream stream, SerializationOptions options = null)
+ {
+ return (T)JsonParser.Instance.Initialize(new StreamReader(stream), options)
+ .FromJson(typeof(T));
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text reader.
+ ///
+ /// Deserialized object's type
+ /// Source JSON text reader
+ /// Serialization options.
+ ///
+ public static T Deserialize(TextReader reader, SerializationOptions options = null)
+ {
+ return (T)JsonParser.Instance.Initialize(reader, options)
+ .FromJson(typeof(T));
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation.
+ ///
+ /// Object to be serialized
+ /// Serialization options.
+ ///
+ public static string Serialize(object obj, SerializationOptions options = null)
+ {
+ var serializer = JsonSerializer.Instance.Initialize();
+
+ serializer.Serialize(obj, options);
+
+ return serializer.Builder.ToString();
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation and writes to specified stream.
+ ///
+ /// Object to be serialized
+ /// Destination stream
+ /// Serialization options.
+ ///
+ public static void Serialize(object obj, Stream stream, SerializationOptions options = null)
+ {
+ using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
+ {
+ Serialize(obj, sw, options);
+ }
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation and writes to a textwriter.
+ ///
+ /// Object to be serialized
+ /// Destination text writer
+ /// Serialization options.
+ ///
+ public static void Serialize(object obj, TextWriter writer, SerializationOptions options = null)
+ {
+ JsonSerializer.Instance.Initialize(writer)
+ .Serialize(obj, options);
+
+ writer.Flush();
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text.
+ ///
+ /// Deserialized object's type
+ /// JSON text
+ /// Custom converters.
+ ///
+ public static T Deserialize(string json, params IJsonConverter[] converters)
+ {
+ return Deserialize(json, new SerializationOptions { Converters = converters });
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text stream.
+ ///
+ /// Deserialized object's type
+ /// Source JSON text stream
+ /// Custom converters.
+ ///
+ public static T Deserialize(Stream stream, params IJsonConverter[] converters)
+ {
+ return Deserialize(new StreamReader(stream), new SerializationOptions { Converters = converters });
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text reader.
+ ///
+ /// Deserialized object's type
+ /// Source JSON text reader
+ /// Custom converters.
+ ///
+ public static T Deserialize(TextReader reader, params IJsonConverter[] converters)
+ {
+ return Deserialize(reader, new SerializationOptions { Converters = converters });
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation.
+ ///
+ /// Object to be serialized
+ /// Custom type converters.
+ ///
+ public static string Serialize(object obj, params IJsonConverter[] converters)
+ {
+ return Serialize(obj, new SerializationOptions { Converters = converters });
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation and writes to specified stream.
+ ///
+ /// Object to be serialized
+ /// Destination stream
+ /// Custom type converters.
+ ///
+ public static void Serialize(object obj, Stream stream, params IJsonConverter[] converters)
+ {
+ Serialize(obj, stream, new SerializationOptions { Converters = converters });
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation and writes to a textwriter.
+ ///
+ /// Object to be serialized
+ /// Destination text writer
+ /// Custom type converters.
+ ///
+ public static void Serialize(object obj, TextWriter writer, params IJsonConverter[] converters)
+ {
+ Serialize(obj, new SerializationOptions { Converters = converters });
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text.
+ ///
+ /// Deserialized object's type
+ /// JSON text
+ /// Property name tranform
+ /// Custom converters.
+ ///
+ public static T Deserialize(string json, IPropertyNameTransform propertyNameTransform, params IJsonConverter[] converters)
+ {
+ return Deserialize(json, new SerializationOptions { PropertyNameTransform = propertyNameTransform, Converters = converters });
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text stream.
+ ///
+ /// Deserialized object's type
+ /// Source JSON text stream
+ /// Property name tranform
+ /// Custom converters.
+ ///
+ public static T Deserialize(Stream stream, IPropertyNameTransform propertyNameTransform, params IJsonConverter[] converters)
+ {
+ return Deserialize(new StreamReader(stream), new SerializationOptions { PropertyNameTransform = propertyNameTransform, Converters = converters });
+ }
+
+
+ ///
+ /// Deserializes an object from a JSON text reader.
+ ///
+ /// Deserialized object's type
+ /// Source JSON text reader
+ /// Property name tranform
+ /// Custom converters.
+ ///
+ public static T Deserialize(TextReader reader, IPropertyNameTransform propertyNameTransform, params IJsonConverter[] converters)
+ {
+ return Deserialize(reader, new SerializationOptions { PropertyNameTransform = propertyNameTransform, Converters = converters });
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation.
+ ///
+ /// Object to be serialized
+ /// Property name tranform
+ /// Custom type converters.
+ ///
+ public static string Serialize(object obj, IPropertyNameTransform propertyNameTransform, params IJsonConverter[] converters)
+ {
+ return Serialize(obj, new SerializationOptions { PropertyNameTransform = propertyNameTransform, Converters = converters });
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation and writes to specified stream.
+ ///
+ /// Object to be serialized
+ /// Destination stream
+ /// Property name tranform
+ /// Custom type converters.
+ ///
+ public static void Serialize(object obj, Stream stream, IPropertyNameTransform propertyNameTransform, params IJsonConverter[] converters)
+ {
+ Serialize(obj, stream, new SerializationOptions { PropertyNameTransform = propertyNameTransform, Converters = converters });
+ }
+
+
+ ///
+ /// Serializes an object to its JSON text representation and writes to a textwriter.
+ ///
+ /// Object to be serialized
+ /// Destination text writer
+ /// Property name tranform
+ /// Custom type converters.
+ ///
+ public static void Serialize(object obj, TextWriter writer, IPropertyNameTransform propertyNameTransform, params IJsonConverter[] converters)
+ {
+ Serialize(obj, new SerializationOptions { PropertyNameTransform = propertyNameTransform, Converters = converters });
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/Sunfish/Sunfish/Library/Json.Net/JsonParser.cs b/Sunfish/Sunfish/Library/Json.Net/JsonParser.cs
new file mode 100644
index 0000000..c27358f
--- /dev/null
+++ b/Sunfish/Sunfish/Library/Json.Net/JsonParser.cs
@@ -0,0 +1,363 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Collections;
+using System.Globalization;
+using System.Linq;
+
+
+namespace Json.Net
+{
+ ///
+ /// JSON Parser Class
+ ///
+ public class JsonParser : ParserBase
+ {
+ IJsonConverter[] Converters;
+ IPropertyNameTransform PropertyNameTransform;
+
+ static Dictionary EscapeMap =
+ new Dictionary()
+ {
+ { 'b', (char)8 },
+ { 't', (char)9 },
+ { 'n', (char)10 },
+ { 'f', (char)12 },
+ { 'r', (char)13 }
+ };
+
+
+ public JsonParser()
+ {
+ }
+
+
+ [ThreadStatic]
+ static JsonParser _Instance;
+
+ public static JsonParser Instance
+ {
+ get
+ {
+ return _Instance ??
+ (_Instance = new JsonParser());
+ }
+ }
+
+
+ public JsonParser Initialize(string json, SerializationOptions options)
+ {
+ base.Initialize(json);
+ Converters = options?.Converters;
+ PropertyNameTransform = options?.PropertyNameTransform;
+ return this;
+ }
+
+
+ public JsonParser Initialize(TextReader jsonReader, SerializationOptions options)
+ {
+ base.Initialize(jsonReader);
+ Converters = options?.Converters;
+ PropertyNameTransform = options.PropertyNameTransform;
+ return this;
+ }
+
+
+ StringBuilder text = new StringBuilder();
+
+ public object FromJson(Type type)
+ {
+ object result;
+
+ SkipWhite();
+
+ if (NextChar == '{')
+ {
+ ReadNext();
+ SkipWhite();
+
+ if (type.IsValueType)
+ throw new FormatException("Unexpected type!");
+
+ result = Activator.CreateInstance(type);
+
+ var nameType = result is IDictionary ?
+ type.GenericTypeArguments[0] :
+ typeof(string);
+
+ var valueType = result is IDictionary ?
+ type.GenericTypeArguments[1] :
+ null;
+
+ var mIndex = 0;
+
+ while (NextChar!='}')
+ {
+ var name = (string)FromJson(nameType);
+
+ SkipWhite();
+ Match(":");
+
+ var map = SerializerMap.GetSerializerMap(type);
+
+ MemberAccessor field = null;
+
+ if (valueType == null)
+ {
+ for (var i = mIndex; i < map.Members.Length; i++)
+ {
+ string memberName = map.Members[i].Name;
+ if (PropertyNameTransform != null)
+ memberName = PropertyNameTransform.Transform(memberName);
+ if (memberName == name)
+ {
+ field = map.Members[i];
+ break;
+ }
+ }
+ }
+
+ var fieldType = field == null ? valueType : field.ValueType;
+
+ var value = FromJson(fieldType);
+
+ if (field != null)
+ {
+ field.SetValue(result, value);
+ }
+ else
+ {
+ ((IDictionary)result).Add(name, value);
+ }
+
+ SkipWhite();
+
+ if (NextChar == ',')
+ {
+ ReadNext();
+ SkipWhite();
+ continue;
+ }
+
+ break;
+ }
+
+ Match("}");
+
+ return result;
+ }
+
+ if (NextChar == '[')
+ {
+ ReadNext();
+ SkipWhite();
+
+ var elementType =
+ type.IsArray ?
+ type.GetElementType() :
+ type.IsGenericType ?
+ type.GenericTypeArguments[0] :
+ typeof(object);
+
+ var list =
+ type.IsArray ?
+ new ArrayList() :
+ (IList)Activator.CreateInstance(type);
+
+ while (NextChar != ']')
+ {
+ var item = FromJson(elementType);
+
+ list.Add(item);
+
+ SkipWhite();
+
+ if (NextChar == ',')
+ {
+ ReadNext();
+ SkipWhite();
+ continue;
+ }
+
+ break;
+ }
+
+ Match("]");
+
+ if (list is ArrayList)
+ return ((ArrayList)list).ToArray(elementType);
+ else
+ return list;
+ }
+
+ if (NextChar == '"')
+ {
+ ReadNext();
+
+ while (!EndOfStream && NextChar != '"')
+ {
+ if (NextChar == '\\')
+ {
+ ReadNext();
+
+ switch (NextChar)
+ {
+ case 'b':
+ case 't':
+ case 'n':
+ case 'f':
+ case 'r':
+ text.Append(EscapeMap[NextChar]);
+ break;
+
+ case 'u':
+ ReadNext();
+
+ var unicode = "";
+
+ while (unicode.Length < 4 && IsHexDigit)
+ {
+ unicode += NextChar;
+ ReadNext();
+ }
+
+ text.Append(char.ConvertFromUtf32(int.Parse("0x" + unicode)));
+ continue;
+
+ default:
+ text.Append(NextChar);
+ break;
+ }
+ }
+ else
+ text.Append(NextChar);
+
+ ReadNext();
+ }
+
+ SkipWhite();
+ Match("\"");
+
+ result = text.ToString();
+
+ text.Clear();
+
+ var converter = Converters?.FirstOrDefault(c => c.GetConvertingType() == type);
+
+ if (converter != null)
+ return converter.Deserializer((string)result);
+
+ if (type == typeof(DateTime)
+ || type == typeof(DateTime?))
+ return DateTime.Parse((string)result, CultureInfo.InvariantCulture);
+
+ if (type == typeof(DateTimeOffset)
+ || type == typeof(DateTimeOffset?))
+ return DateTimeOffset.Parse((string)result, CultureInfo.InvariantCulture);
+
+ if (type == typeof(TimeSpan)
+ || type == typeof(TimeSpan?))
+ return TimeSpan.Parse((string)result, CultureInfo.InvariantCulture);
+
+ return result;
+ }
+ else if (NextChar == 't')
+ {
+ Match("true");
+ return true;
+ }
+ else if (NextChar == 'f')
+ {
+ Match("false");
+ return false;
+ }
+ else if (NextChar == 'n')
+ {
+ Match("null");
+
+ if (!(type.IsClass
+ || Nullable.GetUnderlyingType(type) != null))
+ throw new InvalidDataException("Type " + type.Name + "'s value cannot be null!");
+
+ return null;
+ }
+ else if (NextChar == '-' || IsDigit)
+ {
+ if (NextChar == '-')
+ {
+ text.Append('-');
+ ReadNext();
+ }
+
+ if (NextChar == '0')
+ {
+ text.Append('0');
+ ReadNext();
+ }
+ else if (IsDigit)
+ {
+ do
+ {
+ text.Append(NextChar);
+ ReadNext();
+ }
+ while (IsDigit);
+ }
+ else
+ throw new FormatException("Digit expected!");
+
+ if (NextChar == '.')
+ {
+ text.Append('.');
+ ReadNext();
+
+ while (IsDigit)
+ {
+ text.Append(NextChar);
+ ReadNext();
+ }
+ }
+
+ if (NextChar == 'e' || NextChar == 'E')
+ {
+ text.Append('e');
+ ReadNext();
+
+ if (NextChar == '+' || NextChar == '-')
+ {
+ text.Append(NextChar);
+ ReadNext();
+ }
+
+ while (IsDigit)
+ {
+ text.Append(NextChar);
+ ReadNext();
+ }
+ }
+
+ var t = text.ToString();
+ text.Clear();
+
+ var inv = CultureInfo.InvariantCulture;
+
+ if (type.IsEnum
+ || type == typeof(int)
+ || type == typeof(int?))
+ return int.Parse(t, inv);
+
+ if (type == typeof(long)
+ || type == typeof(long?))
+ return long.Parse(t, inv);
+
+ return double.Parse(t, inv);
+ }
+
+ throw new FormatException("Unexpected character! " + NextChar);
+ }
+
+
+
+ }
+}
diff --git a/Sunfish/Sunfish/Library/Json.Net/JsonSerializer.cs b/Sunfish/Sunfish/Library/Json.Net/JsonSerializer.cs
new file mode 100644
index 0000000..dd1fa4f
--- /dev/null
+++ b/Sunfish/Sunfish/Library/Json.Net/JsonSerializer.cs
@@ -0,0 +1,230 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+
+namespace Json.Net
+{
+ public class JsonSerializer
+ {
+ TextWriter Writer;
+ public StringBuilder Builder = new StringBuilder(1024);
+
+ protected Action Write;
+
+ public JsonSerializer()
+ { }
+
+
+
+ public JsonSerializer Initialize()
+ {
+ Writer = null;
+ Builder.Clear();
+ Write = s => Builder.Append(s);
+ return this;
+ }
+
+
+ public JsonSerializer Initialize(TextWriter writer)
+ {
+ Writer = writer;
+ Write = s => Writer.Write(s);
+ return this;
+ }
+
+
+ [ThreadStatic]
+ static JsonSerializer _Instance;
+
+ public static JsonSerializer Instance
+ {
+ get
+ {
+ return _Instance ??
+ (_Instance = new JsonSerializer());
+ }
+ }
+
+
+ static Dictionary> SerializerCache =
+ new Dictionary>();
+
+
+ public void Serialize(object obj, SerializationOptions options)
+ {
+ if (obj == null)
+ {
+ Write("null");
+ return;
+ }
+
+ var objectType = obj.GetType();
+
+ var converter = options?.Converters?.FirstOrDefault(c => c.GetConvertingType() == objectType);
+
+ if (converter != null)
+ {
+ Serialize(converter.Serializer(obj), options);
+ return;
+ }
+
+ Func