Lines Matching defs:message

140         /// Formats the specified message as JSON.
142 /// <param name="message">The message to format.</param>
143 /// <returns>The formatted message.</returns>
144 public string Format(IMessage message)
147 Format(message, writer);
152 /// Formats the specified message as JSON.
154 /// <param name="message">The message to format.</param>
155 /// <param name="writer">The TextWriter to write the formatted message to.</param>
156 /// <returns>The formatted message.</returns>
157 public void Format(IMessage message, TextWriter writer)
159 ProtoPreconditions.CheckNotNull(message, nameof(message));
162 if (message.Descriptor.IsWellKnownType)
164 WriteWellKnownTypeValue(writer, message.Descriptor, message);
168 WriteMessage(writer, message);
173 /// Converts a message to JSON for diagnostic purposes with no extra context.
180 /// an <c>Any</c> message cannot be applied. Instead, a JSON property named <c>@value</c>
181 /// is included with the base64 data from the <see cref="Any.Value"/> property of the message.
187 /// <param name="message">The message to format for diagnostic purposes.</param>
188 /// <returns>The diagnostic-only JSON representation of the message</returns>
189 public static string ToDiagnosticString(IMessage message)
191 ProtoPreconditions.CheckNotNull(message, nameof(message));
192 return diagnosticFormatter.Format(message);
195 private void WriteMessage(TextWriter writer, IMessage message)
197 if (message == null)
204 ICustomDiagnosticMessage customDiagnosticMessage = message as ICustomDiagnosticMessage;
212 bool writtenFields = WriteMessageFields(writer, message, false);
216 private bool WriteMessageFields(TextWriter writer, IMessage message, bool assumeFirstFieldWritten)
218 var fields = message.Descriptor.Fields;
224 var value = accessor.GetValue(message);
225 if (!ShouldFormatFieldValue(message, field, value))
246 /// its value in the message, and the settings of this formatter.
248 private bool ShouldFormatFieldValue(IMessage message, FieldDescriptor field, object value) =>
251 ? field.Accessor.HasValue(message)
458 // or the message itself if we're formatting it at the top level (e.g. just calling ToString on the object itself).
459 // If it's the message form, we can extract the value first, which *will* be the (possibly boxed) native value,
466 var message = (IMessage) value;
467 value = message.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.GetValue(message);
552 IMessage message = descriptor.Parser.ParseFrom(data);
563 WriteWellKnownTypeValue(writer, descriptor, message);
567 WriteMessageFields(writer, message, true);
589 private void WriteStruct(TextWriter writer, IMessage message)
592 IDictionary fields = (IDictionary) message.Descriptor.Fields[Struct.FieldsFieldNumber].Accessor.GetValue(message);
615 private void WriteStructFieldValue(TextWriter writer, IMessage message)
617 var specifiedField = message.Descriptor.Oneofs[0].Accessor.GetCaseFieldDescriptor(message);
620 throw new InvalidOperationException("Value message must contain a value for the oneof.");
623 object value = specifiedField.Accessor.GetValue(message);
635 var nestedMessage = (IMessage) specifiedField.Accessor.GetValue(message);