/// <summary> /// Creates a <see cref="JsonStringContract"/> for the given type. /// </summary> /// <param name="objectType">Type of the object.</param> /// <returns>A <see cref="JsonStringContract"/> for the given type.</returns> protected virtual JsonStringContract CreateStringContract(Type objectType) { JsonStringContract contract = new JsonStringContract(objectType); InitializeContract(contract); return(contract); }
private void SerializeString(JsonWriter writer, object value, JsonStringContract contract) { contract.InvokeOnSerializing(value, this.Serializer.Context); string s; TryConvertToString(value, contract.UnderlyingType, out s); writer.WriteValue(s); contract.InvokeOnSerialized(value, this.Serializer.Context); }
private void SerializeString(JsonWriter writer, object value, JsonStringContract contract) { contract.InvokeOnSerializing(value, Serializer.Context); string s; TryConvertToString(value, contract.UnderlyingType, out s); writer.WriteValue(s); contract.InvokeOnSerialized(value, Serializer.Context); }