コード例 #1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            // Manage the open and closing of the object.
            // Write APObject specific content (e.g., acls)
            // Call appropriate helpers to write common stuff.
            APObject obj = value as APObject;

            if (obj == null)
            {
                writer.WriteNull();
                return;
            }
            writer.StartObject();
            EntityParser.WriteJson(writer, obj, serializer);
            AclParser.WriteAcl(writer, obj, serializer);
            writer.WriteEndObject();
        }
コード例 #2
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            // Manage the open and closing of the object.
            // Write APConnection specific content (e.g., endpoints)
            // Call appropriate helpers to write common stuff.
            APConnection conn = value as APConnection;

            if (conn == null)
            {
                writer.WriteNull();
                return;
            }
            writer.StartObject();
            EntityParser.WriteJson(writer, conn, serializer);
            WriteEndpoints(writer, conn, serializer);
            writer.WriteEndObject();
        }
コード例 #3
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            // Read the type of the object and create  a new instance.
            // Invoke a helper to populate the common fields for the entity
            // Parse the rest
            var json = JObject.ReadFrom(reader) as JObject;

            if (json == null || json.Type == JTokenType.Null)
            {
                return(null);
            }
            var conn = BuildNewInstance(json, objectType);

            EntityParser.ReadJson(conn, json, serializer);
            // The only field only available in connection ie, endpoints
            ParseEndpoints(conn, json, serializer);
            return(conn);
        }
コード例 #4
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            // Read the type of the object and create  a new instance.
            // Invoke a helper to populate the common fields for the entity
            // Parse the rest
            var json = JObject.ReadFrom(reader) as JObject;

            if (json == null || json.Type == JTokenType.Null)
            {
                return(null);
            }
            var instance = BuildNewInstance(json, objectType);

            EntityParser.ReadJson(instance, json, serializer);
            // The only field only available in ap object is acl.
            AclParser.ReadAcl(instance, json, serializer);
            // Read any type specific fields
            if (instance is APUser)
            {
                UserParser.ReadJson(instance as APUser, json);
            }
            return(instance);
        }