private void WriteEscapedString(string value, bool quote) { EnsureWriteBuffer(); JavaScriptUtils.WriteEscapedJavaScriptString(_writer, value, _quoteChar, quote, _charEscapeFlags, StringEscapeHandling, ref _writeBuffer); }
public void Dispose() { _javaScriptUtils?.Clear(); _javaScriptUtils = null; Current = null; }
private void UpdateCharEscapeFlags() { _charEscapeFlags = JavaScriptUtils.GetCharEscapeFlags(StringEscapeHandling, _quoteChar); }
private void LoadFileBrowser() { JavaScriptUtils.UploadNative(gameObject.name, nameof(LoadFileBrowserCallback)); }
/// <summary> /// Converts the <see cref="String"/> to it's JavaScript string representation. /// </summary> /// <param name="value">The value to convert.</param> /// <param name="delimter">The string delimiter character.</param> /// <returns>A Json string representation of the <see cref="String"/>.</returns> public static string ToString(string value, char delimter) { return(JavaScriptUtils.ToEscapedJavaScriptString(value, delimter, true)); }
private void WriteEscapedString(string value, bool quote) { this.EnsureWriteBuffer(); JavaScriptUtils.WriteEscapedJavaScriptString(this._writer, value, this._quoteChar, quote, this._charEscapeFlags, this.StringEscapeHandling, this._arrayPool, ref this._writeBuffer); }
private void UpdateCharEscapeFlags() { this._charEscapeFlags = JavaScriptUtils.GetCharEscapeFlags(this.StringEscapeHandling, this._quoteChar); }
/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The <see cref="JsonReader"/> to read from.</param> /// <param name="objectType">Type of the object.</param> /// <param name="existingValue">The existing property value of the JSON that is being converted.</param> /// <param name="serializer">The calling serializer.</param> /// <returns>The object value.</returns> public override object?ReadJson( JsonReader reader, Type objectType, object?existingValue, JsonSerializer serializer ) { if (reader.TokenType == JsonToken.Null) { if (!ReflectionUtils.IsNullable(objectType)) { throw JsonSerializationException.Create( reader, "Cannot convert null value to {0}.".FormatWith( CultureInfo.InvariantCulture, objectType ) ); } return(null); } if ( reader.TokenType != JsonToken.StartConstructor || !string.Equals(reader.Value?.ToString(), "Date", StringComparison.Ordinal) ) { throw JsonSerializationException.Create( reader, "Unexpected token or value when parsing date. Token: {0}, Value: {1}".FormatWith( CultureInfo.InvariantCulture, reader.TokenType, reader.Value ) ); } if ( !JavaScriptUtils.TryGetDateFromConstructorJson( reader, out DateTime d, out string?errorMessage ) ) { throw JsonSerializationException.Create(reader, errorMessage); } #if HAVE_DATE_TIME_OFFSET Type t = (ReflectionUtils.IsNullableType(objectType)) ? Nullable.GetUnderlyingType(objectType) : objectType; if (t == typeof(DateTimeOffset)) { return(new DateTimeOffset(d)); } #endif return(d); }