/// <summary> /// Serialize the value into an JSON AST. /// </summary> /// <param name="type">The type to serialize from.</param> /// <param name="value">The value to serialize.</param> /// <returns>The JSON object that represents the serialized value.</returns> protected override JsonValue SerializeValue(Type type, object value) { var serializer = new JsonApiSerializer(ContractResolver, _fieldNamingStratgey); if (TypeHelper.IsEnumerable(type)) { return(serializer.SerializeMany((IEnumerable)value)); } return(serializer.SerializeEntity(value)); }
/// <summary> /// Serialize the value into an JSON AST. /// </summary> /// <param name="type">The type to serialize from.</param> /// <param name="value">The value to serialize.</param> /// <returns>The JSON object that represents the serialized value.</returns> JsonValue SerializeContract(Type type, object value) { var serializer = new JsonApiSerializer(ContractResolver, FieldNamingStrategy); if (TypeHelper.IsEnumerable(type)) { return(serializer.SerializeMany((IEnumerable)value)); } return(serializer.SerializeEntity(value)); }
/// <summary> /// Serialize the entities to a content string. /// </summary> /// <param name="entities">The entities to serialize.</param> /// <param name="serializerOptions">The serializer options.</param> /// <returns>The string that represents the serialized version of the entity.</returns> static string SerializeMany(IEnumerable <TEntity> entities, JsonApiSerializerOptions serializerOptions) { var serializer = new JsonApiSerializer(serializerOptions); return(serializer.SerializeMany(entities).Stringify()); }
/// <summary> /// Serialize the entities to a content string. /// </summary> /// <param name="entities">The entities to serialize.</param> /// <param name="contractResolver">The resource contract resolver.</param> /// <returns>The string that represents the serialized version of the entity.</returns> static string SerializeMany(IEnumerable <TEntity> entities, IContractResolver contractResolver) { var serializer = new JsonApiSerializer(contractResolver, new DasherizedFieldNamingStrategy()); return(serializer.SerializeMany(entities).Stringify()); }
/// <summary> /// Serialize the value into an JSON AST. /// </summary> /// <param name="type">The type to serialize from.</param> /// <param name="value">The value to serialize.</param> /// <returns>The JSON object that represents the serialized value.</returns> protected override JsonValue SerializeValue(Type type, object value) { var serializer = new JsonApiSerializer(ContractResolver, _fieldNamingStratgey); if (TypeHelper.IsEnumerable(type)) { return serializer.SerializeMany((IEnumerable)value); } return serializer.SerializeEntity(value); }