/// <summary> /// Constructor. /// </summary> /// <param name="jsonOutputContext">The output context to write to.</param> /// <param name="functionImport">The function import whose parameters will be written.</param> internal ODataJsonParameterWriter(ODataJsonOutputContext jsonOutputContext, IEdmFunctionImport functionImport) : base(jsonOutputContext, functionImport) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(jsonOutputContext != null, "jsonOutputContext != null"); this.jsonOutputContext = jsonOutputContext; this.jsonPropertyAndValueSerializer = new ODataJsonPropertyAndValueSerializer(this.jsonOutputContext); }
internal static string ConvertToUriComplexLiteral(ODataComplexValue complexValue, IEdmModel model, ODataVersion version) { ExceptionUtils.CheckArgumentNotNull<ODataComplexValue>(complexValue, "complexValue"); ExceptionUtils.CheckArgumentNotNull<IEdmModel>(model, "model"); StringBuilder sb = new StringBuilder(); using (TextWriter writer = new StringWriter(sb, CultureInfo.InvariantCulture)) { JsonWriter jsonWriter = new JsonWriter(writer, false); bool writingResponse = false; ODataMessageWriterSettings messageWriterSettings = new ODataMessageWriterSettings { Version = new ODataVersion?(version) }; using (ODataJsonOutputContext context = ODataJsonOutputContext.Create(ODataFormat.VerboseJson, jsonWriter, messageWriterSettings, writingResponse, model, null)) { ODataJsonPropertyAndValueSerializer serializer = new ODataJsonPropertyAndValueSerializer(context); serializer.WriteComplexValue(complexValue, null, true, serializer.CreateDuplicatePropertyNamesChecker(), null); } } return sb.ToString(); }
/// <summary> /// Writes an <see cref="ODataProperty"/> as message payload. /// </summary> /// <param name="property">The property to write.</param> private void WritePropertyImplementation(ODataProperty property) { ODataJsonPropertyAndValueSerializer jsonPropertyAndValueSerializer = new ODataJsonPropertyAndValueSerializer(this); jsonPropertyAndValueSerializer.WriteTopLevelProperty(property); }
internal ODataJsonParameterWriter(ODataJsonOutputContext jsonOutputContext, IEdmFunctionImport functionImport) : base(jsonOutputContext, functionImport) { this.jsonOutputContext = jsonOutputContext; this.jsonPropertyAndValueSerializer = new ODataJsonPropertyAndValueSerializer(this.jsonOutputContext); }