private void WriteToken(IList <JsonSchemaModel> schemas) { foreach (SchemaScope scope in this._stack) { bool flag = ((scope.TokenType == JTokenType.Array) && scope.IsUniqueArray) && (scope.ArrayItemCount > 0); if (!flag) { if (< > c.< > 9__49_0 == null) { } if (!schemas.Any <JsonSchemaModel>((< > c.< > 9__49_0 = new Func <JsonSchemaModel, bool>(< > c.< > 9. < WriteToken > b__49_0)))) { continue; } } if (scope.CurrentItemWriter == null) { if (JsonTokenUtils.IsEndToken(this._reader.TokenType)) { continue; } scope.CurrentItemWriter = new JTokenWriter(); } scope.CurrentItemWriter.WriteToken(this._reader, false); if ((scope.CurrentItemWriter.Top == 0) && (this._reader.TokenType != JsonToken.PropertyName)) { JToken token = scope.CurrentItemWriter.Token; scope.CurrentItemWriter = null; if (flag) { if (scope.UniqueArrayItems.Contains <JToken>(token, JToken.EqualityComparer)) { if (< > c.< > 9__49_1 == null) { } this.RaiseError("Non-unique array item at index {0}.".FormatWith(CultureInfo.InvariantCulture, scope.ArrayItemCount - 1), scope.Schemas.First <JsonSchemaModel>(< > c.< > 9__49_1 = new Func <JsonSchemaModel, bool>(< > c.< > 9. < WriteToken > b__49_1))); } scope.UniqueArrayItems.Add(token); } else { if (< > c.< > 9__49_2 == null) { } if (schemas.Any <JsonSchemaModel>(< > c.< > 9__49_2 = new Func <JsonSchemaModel, bool>(< > c.< > 9. < WriteToken > b__49_2))) { foreach (JsonSchemaModel model in schemas) { if ((model.Enum != null) && !model.Enum.ContainsValue <JToken>(token, JToken.EqualityComparer)) { StringWriter textWriter = new StringWriter(CultureInfo.InvariantCulture); token.WriteTo(new JsonTextWriter(textWriter), new JsonConverter[0]); this.RaiseError("Value {0} is not defined in enum.".FormatWith(CultureInfo.InvariantCulture, textWriter.ToString()), model); } } } } } } }
internal virtual void WriteToken(JsonReader reader, bool writeChildren, bool writeDateConstructorAsDate, bool writeComments) { int depth; if (reader.TokenType == JsonToken.None) { depth = -1; } else if (!JsonTokenUtils.IsStartToken(reader.TokenType)) { depth = reader.Depth + 1; } else { depth = reader.Depth; } do { if ((writeDateConstructorAsDate && (reader.TokenType == JsonToken.StartConstructor)) && string.Equals(reader.Value.ToString(), "Date", StringComparison.Ordinal)) { this.WriteConstructorDate(reader); } else if (writeComments || (reader.TokenType != JsonToken.Comment)) { this.WriteToken(reader.TokenType, reader.Value); } }while ((((depth - 1) < (reader.Depth - (JsonTokenUtils.IsEndToken(reader.TokenType) ? 1 : 0))) & writeChildren) && reader.Read()); }
private void WriteToken(IList <JsonSchemaModel> schemas) { foreach (SchemaScope schemaScope in _stack) { bool isInUniqueArray = (schemaScope.TokenType == JTokenType.Array && schemaScope.IsUniqueArray && schemaScope.ArrayItemCount > 0); if (isInUniqueArray || schemas.Any(s => s.Enum != null)) { if (schemaScope.CurrentItemWriter == null) { if (JsonTokenUtils.IsEndToken(_reader.TokenType)) { continue; } schemaScope.CurrentItemWriter = new JTokenWriter(); } schemaScope.CurrentItemWriter.WriteToken(_reader, false); // finished writing current item if (schemaScope.CurrentItemWriter.Top == 0 && _reader.TokenType != JsonToken.PropertyName) { JToken finishedItem = schemaScope.CurrentItemWriter.Token; // start next item with new writer schemaScope.CurrentItemWriter = null; if (isInUniqueArray) { if (schemaScope.UniqueArrayItems.Contains(finishedItem, JToken.EqualityComparer)) { RaiseError("Non-unique array item at index {0}.".FormatWith(CultureInfo.InvariantCulture, schemaScope.ArrayItemCount - 1), schemaScope.Schemas.First(s => s.UniqueItems)); } schemaScope.UniqueArrayItems.Add(finishedItem); } else if (schemas.Any(s => s.Enum != null)) { foreach (JsonSchemaModel schema in schemas) { if (schema.Enum != null) { if (!schema.Enum.ContainsValue(finishedItem, JToken.EqualityComparer)) { StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); finishedItem.WriteTo(new JsonTextWriter(sw)); RaiseError("Value {0} is not defined in enum.".FormatWith(CultureInfo.InvariantCulture, sw.ToString()), schema); } } } } } } } }
private void WriteToken(IList <JsonSchemaModel> schemas) { bool flag; foreach (JsonValidatingReader.SchemaScope jTokenWriter in this._stack) { flag = (jTokenWriter.TokenType != JTokenType.Array || !jTokenWriter.IsUniqueArray ? false : jTokenWriter.ArrayItemCount > 0); bool flag1 = flag; if (!flag) { if (!schemas.Any <JsonSchemaModel>((JsonSchemaModel s) => s.Enum != null)) { continue; } } if (jTokenWriter.CurrentItemWriter == null) { if (JsonTokenUtils.IsEndToken(this._reader.TokenType)) { continue; } jTokenWriter.CurrentItemWriter = new JTokenWriter(); } jTokenWriter.CurrentItemWriter.WriteToken(this._reader, false); if (jTokenWriter.CurrentItemWriter.Top != 0 || this._reader.TokenType == JsonToken.PropertyName) { continue; } JToken token = jTokenWriter.CurrentItemWriter.Token; jTokenWriter.CurrentItemWriter = null; if (!flag1) { if (!schemas.Any <JsonSchemaModel>((JsonSchemaModel s) => s.Enum != null)) { continue; } foreach (JsonSchemaModel schema in schemas) { if (schema.Enum == null || schema.Enum.ContainsValue <JToken>(token, JToken.EqualityComparer)) { continue; } StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture); token.WriteTo(new JsonTextWriter(stringWriter), new JsonConverter[0]); this.RaiseError("Value {0} is not defined in enum.".FormatWith(CultureInfo.InvariantCulture, stringWriter.ToString()), schema); } } else { if (jTokenWriter.UniqueArrayItems.Contains <JToken>(token, JToken.EqualityComparer)) { this.RaiseError("Non-unique array item at index {0}.".FormatWith(CultureInfo.InvariantCulture, jTokenWriter.ArrayItemCount - 1), jTokenWriter.Schemas.First <JsonSchemaModel>((JsonSchemaModel s) => s.UniqueItems)); } jTokenWriter.UniqueArrayItems.Add(token); } } }
private void WriteToken(IList <JsonSchemaModel> schemas) { foreach (JsonValidatingReader.SchemaScope schemaScope in this._stack) { bool flag = schemaScope.TokenType == JTokenType.Array && schemaScope.IsUniqueArray && schemaScope.ArrayItemCount > 0; if (flag || schemas.Any <JsonSchemaModel>((Func <JsonSchemaModel, bool>)(s => s.Enum != null))) { if (schemaScope.CurrentItemWriter == null) { if (!JsonTokenUtils.IsEndToken(this._reader.TokenType)) { schemaScope.CurrentItemWriter = new JTokenWriter(); } else { continue; } } schemaScope.CurrentItemWriter.WriteToken(this._reader, false); if (schemaScope.CurrentItemWriter.Top == 0 && this._reader.TokenType != JsonToken.PropertyName) { JToken token = schemaScope.CurrentItemWriter.Token; schemaScope.CurrentItemWriter = (JTokenWriter)null; if (flag) { if (schemaScope.UniqueArrayItems.Contains <JToken>(token, (IEqualityComparer <JToken>)JToken.EqualityComparer)) { this.RaiseError( "Non-unique array item at index {0}.".FormatWith((IFormatProvider)CultureInfo.InvariantCulture, (object)(schemaScope.ArrayItemCount - 1)), schemaScope.Schemas.First <JsonSchemaModel>((Func <JsonSchemaModel, bool>)(s => s.UniqueItems))); } schemaScope.UniqueArrayItems.Add(token); } else if (schemas.Any <JsonSchemaModel>((Func <JsonSchemaModel, bool>)(s => s.Enum != null))) { foreach (JsonSchemaModel schema in (IEnumerable <JsonSchemaModel>)schemas) { if (schema.Enum != null && !schema.Enum.ContainsValue <JToken>(token, (IEqualityComparer <JToken>)JToken.EqualityComparer)) { StringWriter stringWriter = new StringWriter((IFormatProvider)CultureInfo.InvariantCulture); token.WriteTo((JsonWriter) new JsonTextWriter((TextWriter)stringWriter)); this.RaiseError( "Value {0} is not defined in enum.".FormatWith((IFormatProvider)CultureInfo.InvariantCulture, (object)stringWriter.ToString()), schema); } } } } } } }
// Token: 0x06000D89 RID: 3465 RVA: 0x00054A60 File Offset: 0x00052C60 private void WriteToken(IList <JsonSchemaModel> schemas) { foreach (JsonValidatingReader.SchemaScope schemaScope in this._stack) { bool flag; if (!(flag = (schemaScope.TokenType == JTokenType.Array && schemaScope.IsUniqueArray && schemaScope.ArrayItemCount > 0))) { if (!schemas.Any((JsonSchemaModel s) => s.Enum != null)) { continue; } } if (schemaScope.CurrentItemWriter == null) { if (JsonTokenUtils.IsEndToken(this._reader.TokenType)) { continue; } schemaScope.CurrentItemWriter = new JTokenWriter(); } schemaScope.CurrentItemWriter.WriteToken(this._reader, false); if (schemaScope.CurrentItemWriter.Top == 0 && this._reader.TokenType != JsonToken.PropertyName) { JToken token = schemaScope.CurrentItemWriter.Token; schemaScope.CurrentItemWriter = null; if (flag) { if (schemaScope.UniqueArrayItems.Contains(token, JToken.EqualityComparer)) { this.RaiseError("Non-unique array item at index {0}.".FormatWith(CultureInfo.InvariantCulture, schemaScope.ArrayItemCount - 1), schemaScope.Schemas.First((JsonSchemaModel s) => s.UniqueItems)); } schemaScope.UniqueArrayItems.Add(token); } else if (schemas.Any((JsonSchemaModel s) => s.Enum != null)) { foreach (JsonSchemaModel jsonSchemaModel in schemas) { if (jsonSchemaModel.Enum != null && !jsonSchemaModel.Enum.ContainsValue(token, JToken.EqualityComparer)) { StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture); token.WriteTo(new JsonTextWriter(stringWriter), new JsonConverter[0]); this.RaiseError("Value {0} is not defined in enum.".FormatWith(CultureInfo.InvariantCulture, stringWriter.ToString()), jsonSchemaModel); } } } } } }
internal virtual void WriteToken( JsonReader reader, bool writeChildren, bool writeDateConstructorAsDate, bool writeComments) { int writeTokenDepth = this.CalculateWriteTokenDepth(reader); do { if (writeDateConstructorAsDate && reader.TokenType == JsonToken.StartConstructor && string.Equals(reader.Value.ToString(), "Date", StringComparison.Ordinal)) { this.WriteConstructorDate(reader); } else if (writeComments || reader.TokenType != JsonToken.Comment) { this.WriteToken(reader.TokenType, reader.Value); } } while (writeTokenDepth - 1 < reader.Depth - (JsonTokenUtils.IsEndToken(reader.TokenType) ? 1 : 0) & writeChildren && reader.Read()); }