diff --git a/Razor/DynamicJson/DynamicJson.cs b/Razor/DynamicJson/DynamicJson.cs
deleted file mode 100644
index fb5f3ed..0000000
--- a/Razor/DynamicJson/DynamicJson.cs
+++ /dev/null
@@ -1,401 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Dynamic;
-using System.Linq;
-using System.Reflection;
-using System.Xml.Linq;
-
-namespace DynamicJson
-{
- ///
- /// Dynamic JSON
- ///
- public class DynamicJson : DynamicObject
- {
- #region Fields
-
- readonly XElement xml;
- readonly DynamicJsonType jsonType;
-
- #endregion
-
- #region Ctors
-
- ///
- /// Dynamic JSON
- ///
- public DynamicJson()
- {
- xml = new XElement("root", DynamicJsonHelper.CreateTypeAttr(DynamicJsonType.@object));
- jsonType = DynamicJsonType.@object;
- }
-
- internal DynamicJson(XElement element, DynamicJsonType type)
- {
- Debug.Assert(type == DynamicJsonType.array || type == DynamicJsonType.@object);
-
- xml = element;
- jsonType = type;
- }
-
- #endregion
-
- #region Property Methods
-
- ///
- /// Gets a value indicating whether this instance is object.
- ///
- ///
- /// true if this instance is object; otherwise, false.
- ///
- public bool IsObject { get { return jsonType == DynamicJsonType.@object; } }
-
- ///
- /// Gets a value indicating whether this instance is array.
- ///
- ///
- /// true if this instance is array; otherwise, false.
- ///
- public bool IsArray { get { return jsonType == DynamicJsonType.array; } }
-
- ///
- /// 是否定义了指定名称的属性
- ///
- public bool IsDefined(string name)
- {
- return IsObject && (xml.Element(name) != null);
- }
-
- ///
- /// 是否定义了指定索引的属性
- ///
- public bool IsDefined(int index)
- {
- return IsArray && (xml.Elements().ElementAtOrDefault(index) != null);
- }
-
- ///
- /// 删除属性
- ///
- public bool Delete(string name)
- {
- var elem = xml.Element(name);
- if (elem != null)
- {
- elem.Remove();
- return true;
- }
- else return false;
- }
-
- ///
- /// 删除属性
- ///
- public bool Delete(int index)
- {
- var elem = xml.Elements().ElementAtOrDefault(index);
- if (elem != null)
- {
- elem.Remove();
- return true;
- }
- else return false;
- }
-
- #endregion
-
- #region Serialize
-
- ///
- /// 序列化至字符串
- ///
- /// 字符串
- public string Serialize()
- {
- return this.ToString();
- }
-
- ///
- /// Returns a that represents this instance.
- ///
- ///
- /// A that represents this instance.
- ///
- public override string ToString()
- {
- // Serialize to JsonString
- // is can't serialize. replace to
- foreach (var elem in xml.Descendants().Where(x => x.Attribute("type").Value == "null"))
- {
- elem.RemoveNodes();
- }
- return DynamicJsonHelper.CreateJsonString(new XStreamingElement("root", DynamicJsonHelper.CreateTypeAttr(jsonType), xml.Elements()));
- }
-
- #endregion
-
- #region Deserialize
-
- ///
- /// 将JSON反序列化成对象
- ///
- public T Deserialize()
- {
- return (T)Deserialize(typeof(T));
- }
-
- private object Deserialize(Type type)
- {
- return (IsArray) ? DeserializeArray(type) : DeserializeObject(type);
- }
-
- private dynamic DeserializeValue(XElement element, Type elementType)
- {
- var value = DynamicJsonHelper.ConvertElementToValue(element);
- if (value is DynamicJson)
- {
- value = ((DynamicJson)value).Deserialize(elementType);
- }
- return Convert.ChangeType(value, elementType);
- }
-
- private object DeserializeObject(Type targetType)
- {
- var result = Activator.CreateInstance(targetType);
- var dict = targetType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
- .Where(p => p.CanWrite)
- .ToDictionary(pi => pi.Name, pi => pi);
- foreach (var item in xml.Elements())
- {
- PropertyInfo propertyInfo;
- if (!dict.TryGetValue(item.Name.LocalName, out propertyInfo)) continue;
- var value = DeserializeValue(item, propertyInfo.PropertyType);
- propertyInfo.SetValue(result, value, null);
- }
- return result;
- }
-
- private object DeserializeArray(Type targetType)
- {
- if (targetType.IsArray) // Foo[]
- {
- var elemType = targetType.GetElementType();
- dynamic array = Array.CreateInstance(elemType, xml.Elements().Count());
- var index = 0;
- foreach (var item in xml.Elements())
- {
- array[index++] = DeserializeValue(item, elemType);
- }
- return array;
- }
- else // List
- {
- var elemType = targetType.GetGenericArguments()[0];
- dynamic list = Activator.CreateInstance(targetType);
- foreach (var item in xml.Elements())
- {
- list.Add(DeserializeValue(item, elemType));
- }
- return list;
- }
- }
-
- #endregion
-
- #region DynamicObject Overrides
-
- ///
- /// Provides the implementation for operations that invoke an object. Classes derived from the class can override this method to specify dynamic behavior for operations such as invoking an object or a delegate.
- ///
- /// Provides information about the invoke operation.
- /// The arguments that are passed to the object during the invoke operation. For example, for the sampleObject(100) operation, where sampleObject is derived from the class, args[0] is equal to 100.
- /// The result of the object invocation.
- ///
- /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.
- ///
- public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
- {
- // Delete
- result = (IsArray)
- ? Delete((int)args[0])
- : Delete((string)args[0]);
- return true;
- }
-
- ///
- /// Provides the implementation for operations that invoke a member. Classes derived from the class can override this method to specify dynamic behavior for operations such as calling a method.
- ///
- /// Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.
- /// The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the class, args[0] is equal to 100.
- /// The result of the member invocation.
- ///
- /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
- ///
- public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
- {
- // IsDefined, if has args then TryGetMember
- if (args.Length > 0)
- {
- result = null;
- return false;
- }
-
- result = IsDefined(binder.Name);
- return true;
- }
-
- ///
- /// Provides implementation for type conversion operations. Classes derived from the class can override this method to specify dynamic behavior for operations that convert an object from one type to another.
- ///
- /// Provides information about the conversion operation. The binder.Type property provides the type to which the object must be converted. For example, for the statement (String)sampleObject in C# (CType(sampleObject, Type) in Visual Basic), where sampleObject is an instance of the class derived from the class, binder.Type returns the type. The binder.Explicit property provides information about the kind of conversion that occurs. It returns true for explicit conversion and false for implicit conversion.
- /// The result of the type conversion operation.
- ///
- /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
- ///
- public override bool TryConvert(ConvertBinder binder, out object result)
- {
- // Deserialize or foreach(IEnumerable)
- if (binder.Type == typeof(IEnumerable) || binder.Type == typeof(object[]))
- {
- var ie = (IsArray)
- ? xml.Elements().Select(x => DynamicJsonHelper.ConvertElementToValue(x))
- : xml.Elements().Select(x => (dynamic)new KeyValuePair(x.Name.LocalName, DynamicJsonHelper.ConvertElementToValue(x)));
- result = (binder.Type == typeof(object[])) ? ie.ToArray() : ie;
- }
- else
- {
- result = Deserialize(binder.Type);
- }
- return true;
- }
-
- ///
- /// Provides the implementation for operations that get a value by index. Classes derived from the class can override this method to specify dynamic behavior for indexing operations.
- ///
- /// Provides information about the operation.
- /// The indexes that are used in the operation. For example, for the sampleObject[3] operation in C# (sampleObject(3) in Visual Basic), where sampleObject is derived from the DynamicObject class, indexes[0] is equal to 3.
- /// The result of the index operation.
- ///
- /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
- ///
- public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
- {
- return (IsArray)
- ? TryGet(xml.Elements().ElementAtOrDefault((int)indexes[0]), out result)
- : TryGet(xml.Element((string)indexes[0]), out result);
- }
-
- ///
- /// Provides the implementation for operations that get member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as getting a value for a property.
- ///
- /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.
- /// The result of the get operation. For example, if the method is called for a property, you can assign the property value to .
- ///
- /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
- ///
- public override bool TryGetMember(GetMemberBinder binder, out object result)
- {
- return (IsArray)
- ? TryGet(xml.Elements().ElementAtOrDefault(int.Parse(binder.Name)), out result)
- : TryGet(xml.Element(binder.Name), out result);
- }
-
- ///
- /// Provides the implementation for operations that set a value by index. Classes derived from the class can override this method to specify dynamic behavior for operations that access objects by a specified index.
- ///
- /// Provides information about the operation.
- /// The indexes that are used in the operation. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, indexes[0] is equal to 3.
- /// The value to set to the object that has the specified index. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, is equal to 10.
- ///
- /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.
- ///
- public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
- {
- return (IsArray)
- ? TrySet((int)indexes[0], value)
- : TrySet((string)indexes[0], value);
- }
-
- ///
- /// Provides the implementation for operations that set member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as setting a value for a property.
- ///
- /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.
- /// The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, the is "Test".
- ///
- /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
- ///
- public override bool TrySetMember(SetMemberBinder binder, object value)
- {
- return (IsArray)
- ? TrySet(int.Parse(binder.Name), value)
- : TrySet(binder.Name, value);
- }
-
- ///
- /// Returns the enumeration of all dynamic member names.
- ///
- ///
- /// A sequence that contains dynamic member names.
- ///
- public override IEnumerable GetDynamicMemberNames()
- {
- return (IsArray)
- ? xml.Elements().Select((x, i) => i.ToString())
- : xml.Elements().Select(x => x.Name.LocalName);
- }
-
- #endregion
-
- #region Private Methods
-
- private bool TryGet(XElement element, out object result)
- {
- if (element == null)
- {
- result = null;
- return false;
- }
-
- result = DynamicJsonHelper.ConvertElementToValue(element);
- return true;
- }
-
- private bool TrySet(string name, object value)
- {
- var type = DynamicJsonHelper.GetDynamicJsonType(value);
- var element = xml.Element(name);
- if (element == null)
- {
- xml.Add(new XElement(name, DynamicJsonHelper.CreateTypeAttr(type), DynamicJsonHelper.CreateJsonNode(value)));
- }
- else
- {
- element.Attribute("type").Value = type.ToString();
- element.ReplaceNodes(DynamicJsonHelper.CreateJsonNode(value));
- }
-
- return true;
- }
-
- private bool TrySet(int index, object value)
- {
- var type = DynamicJsonHelper.GetDynamicJsonType(value);
- var e = xml.Elements().ElementAtOrDefault(index);
- if (e == null)
- {
- xml.Add(new XElement("item", DynamicJsonHelper.CreateTypeAttr(type), DynamicJsonHelper.CreateJsonNode(value)));
- }
- else
- {
- e.Attribute("type").Value = type.ToString();
- e.ReplaceNodes(DynamicJsonHelper.CreateJsonNode(value));
- }
-
- return true;
- }
-
- #endregion
- }
-}
diff --git a/Razor/DynamicJson/DynamicJson.csproj b/Razor/DynamicJson/DynamicJson.csproj
deleted file mode 100644
index f994a18..0000000
--- a/Razor/DynamicJson/DynamicJson.csproj
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {9F68A91C-E200-4998-A601-10D9FFFE94DB}
- Library
- Properties
- DynamicJson
- DynamicJson
- v4.0
- 512
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Razor/DynamicJson/DynamicJson.csproj.user b/Razor/DynamicJson/DynamicJson.csproj.user
deleted file mode 100644
index 55f44b9..0000000
--- a/Razor/DynamicJson/DynamicJson.csproj.user
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- ShowAllFiles
-
-
\ No newline at end of file
diff --git a/Razor/DynamicJson/DynamicJsonConvert.cs b/Razor/DynamicJson/DynamicJsonConvert.cs
deleted file mode 100644
index 820bb3e..0000000
--- a/Razor/DynamicJson/DynamicJsonConvert.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Runtime.Serialization.Json;
-using System.Text;
-using System.Xml;
-using System.Xml.Linq;
-
-namespace DynamicJson
-{
- ///
- /// DynamicJson转换器
- ///
- public static class DynamicJsonConvert
- {
- ///
- /// 序列化指定的对象至JSON字符串
- ///
- /// 指定的对象
- /// JSON字符串
- public static string SerializeObject(object target)
- {
- return DynamicJsonHelper.CreateJsonString(
- new XStreamingElement("root",
- DynamicJsonHelper.CreateTypeAttr(DynamicJsonHelper.GetDynamicJsonType(target)),
- DynamicJsonHelper.CreateJsonNode(target)));
- }
-
- ///
- /// Convert JSON string to DynamicJson
- ///
- /// JSON字符串
- /// DynamicJson
- public static dynamic Parse(string json)
- {
- using (var reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.Unicode.GetBytes(json), XmlDictionaryReaderQuotas.Max))
- {
- return DynamicJsonHelper.ConvertElementToValue(XElement.Load(reader));
- }
- }
- }
-}
diff --git a/Razor/DynamicJson/DynamicJsonHelper.cs b/Razor/DynamicJson/DynamicJsonHelper.cs
deleted file mode 100644
index 81902dd..0000000
--- a/Razor/DynamicJson/DynamicJsonHelper.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.Serialization.Json;
-using System.Text;
-using System.Xml.Linq;
-
-namespace DynamicJson
-{
- internal static class DynamicJsonHelper
- {
- #region Serialize
-
- internal static string CreateJsonString(XStreamingElement element)
- {
- using (var ms = new MemoryStream())
- using (var writer = JsonReaderWriterFactory.CreateJsonWriter(ms, Encoding.Unicode))
- {
- element.WriteTo(writer);
- writer.Flush();
- return Encoding.Unicode.GetString(ms.ToArray());
- }
- }
-
- internal static XAttribute CreateTypeAttr(DynamicJsonType type)
- {
- return new XAttribute("type", type.ToString());
- }
-
- internal static object CreateJsonNode(object obj)
- {
- var type = GetDynamicJsonType(obj);
- switch (type)
- {
- case DynamicJsonType.@string:
- case DynamicJsonType.number:
- return obj;
- case DynamicJsonType.boolean:
- return obj.ToString().ToLower();
- case DynamicJsonType.@object:
- return CreateXObject(obj);
- case DynamicJsonType.array:
- return CreateXArray(obj as IEnumerable);
- case DynamicJsonType.@null:
- default:
- return null;
- }
- }
-
- internal static DynamicJsonType GetDynamicJsonType(object obj)
- {
- if (obj == null) return DynamicJsonType.@null;
-
- switch (Type.GetTypeCode(obj.GetType()))
- {
- case TypeCode.Boolean:
- return DynamicJsonType.boolean;
- case TypeCode.String:
- case TypeCode.Char:
- case TypeCode.DateTime:
- return DynamicJsonType.@string;
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- case TypeCode.Single:
- case TypeCode.Double:
- case TypeCode.Decimal:
- case TypeCode.SByte:
- case TypeCode.Byte:
- return DynamicJsonType.number;
- case TypeCode.Object:
- return (obj is IEnumerable) ? DynamicJsonType.array : DynamicJsonType.@object;
- case TypeCode.DBNull:
- case TypeCode.Empty:
- default:
- return DynamicJsonType.@null;
- }
- }
-
- private static IEnumerable CreateXArray(T obj) where T : IEnumerable
- {
- return obj.Cast