Inheritance: JSONNode, IEnumerable
Ejemplo n.º 1
0
 public virtual string Serialize()
 {
     var jsonObject = new JSONClass();
     return jsonObject.ToString();
 }
 public virtual string Serialize() {
     var jsonObject = new JSONClass();
     jsonObject.Add("Progress", new JSONData(this.Progress));
     return jsonObject.ToString();
 }
 public virtual string Serialize() {
     var jsonObject = new JSONClass();
     jsonObject.Add("Width", new JSONData(this.Width));
     jsonObject.Add("Height", new JSONData(this.Height));
     return jsonObject.ToString();
 }
Ejemplo n.º 4
0
 public JsonStream(ITypeResolver typeResolver)
 {
     _typeResolver = typeResolver;
     RootNode      = new JSONClass();
 }
Ejemplo n.º 5
0
 public JsonStream()
 {
     RootNode = new JSONClass();
 }
Ejemplo n.º 6
0
        public void SerializeObject(string name, object value)
        {
            if (value is int)
            {
                SerializeInt(name, (int)value);
                return;
            }
            if (value is string)
            {
                SerializeString(name, (string)value);
                return;
            }
            if (value is bool)
            {
                SerializeBool(name, (bool)value);
                return;
            }
            if (value is Vector2)
            {
                SerializeVector2(name, (Vector2)value);
                return;
            }
            if (value is Vector3)
            {
                SerializeVector3(name, (Vector3)value);
                return;
            }
            if (value is Quaternion)
            {
                SerializeQuaternion(name, (Quaternion)value);
                return;
            }
            if (value is double)
            {
                SerializeDouble(name, (double)value);
                return;
            }
            var cls = new JSONClass();

            if (name == null)
            {
                CurrentNode.Add(cls);
            }
            else
            {
                CurrentNode.Add(name, cls);
            }
            Push(name, cls);

            var serializable = value as IUFSerializable;

            if (serializable != null)
            {
                SerializeString("Identifier", serializable.Identifier);
                if (!UseReferences || !ReferenceObjects.ContainsKey(serializable.Identifier))
                {
                    SerializeString("CLRType", TypeResolver.SetType(value.GetType()));

                    if (UseReferences)
                    {
                        ReferenceObjects.Add(serializable.Identifier, serializable);
                    }

                    serializable.Write(this);
                }
            }
            Pop();
        }