/// <summary>
 /// Constructs a new attribute instance for the given name.
 /// </summary>
 /// <param name="name">The name of the element in the .proto file.</param>
 public OriginalNameAttribute(string name)
 {
     Name           = ProtoPreconditions.CheckNotNull(name, nameof(name));
     PreferredAlias = true;
 }
 /// <summary>
 /// Converts a message to text for diagnostic purposes with no extra context.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This differs from calling <see cref="Format(IMessage)"/> on the default text
 /// formatter in its handling of <see cref="Any"/>. As no type registry is available
 /// in <see cref="object.ToString"/> calls, the normal way of resolving the type of
 /// an <c>Any</c> message cannot be applied. Instead, a text property named <c>@value</c>
 /// is included with the base64 data from the <see cref="Any.Value"/> property of the message.
 /// </para>
 /// <para>The value returned by this method is only designed to be used for diagnostic
 /// purposes. It may not be parsable by <see cref="TextParser"/>, and may not be parsable
 /// by other Protocol Buffer implementations.</para>
 /// </remarks>
 /// <param name="message">The message to format for diagnostic purposes.</param>
 /// <returns>The diagnostic-only text representation of the message</returns>
 public static string ToDiagnosticString(IMessage message)
 {
     ProtoPreconditions.CheckNotNull(message, nameof(message));
     return(diagnosticFormatter.Format(message));
 }
Exemple #3
0
 /// <summary>
 /// Adds the specified item to the collection.
 /// </summary>
 /// <param name="item">The item to add.</param>
 public void Add(T item)
 {
     ProtoPreconditions.CheckNotNullUnconstrained(item, "item");
     EnsureSize(count + 1);
     array[count++] = item;
 }
Exemple #4
0
 /// <summary>
 /// Creates a type registry from the file descriptor parents of the specified set of message descriptors.
 /// </summary>
 /// <remarks>
 /// The specified message descriptors are only used to identify their file descriptors; the returned registry
 /// contains all the types within the file descriptors which contain the specified message descriptors (and
 /// the dependencies of those files), not just the specified messages.
 /// </remarks>
 /// <param name="messageDescriptors">The set of message descriptors to use to identify file descriptors to include in the registry.
 /// Must not contain null values.</param>
 /// <returns>A type registry for the given files.</returns>
 public static TypeRegistry FromMessages(IEnumerable <MessageDescriptor> messageDescriptors)
 {
     ProtoPreconditions.CheckNotNull(messageDescriptors, "messageDescriptors");
     return(FromFiles(messageDescriptors.Select(md => md.File)));
 }
Exemple #5
0
 /// <summary>
 /// Returns the index of the given item within the collection, or -1 if the item is not
 /// present.
 /// </summary>
 /// <param name="item">The item to find in the collection.</param>
 /// <returns>The zero-based index of the item, or -1 if it is not found.</returns>
 public new int IndexOf(T item)
 {
     ProtoPreconditions.CheckNotNullUnconstrained(item, "item");
     return(base.IndexOf(item));
 }
Exemple #6
0
 /// <summary>
 /// Inserts the given item at the specified index.
 /// </summary>
 /// <param name="index">The index at which to insert the item.</param>
 /// <param name="item">The item to insert.</param>
 public new void Insert(int index, T item)
 {
     ProtoPreconditions.CheckNotNullUnconstrained(item, "item");
     base.Insert(index, item);
 }
Exemple #7
0
 /// <summary>
 /// Adds the specified item to the collection.
 /// </summary>
 /// <param name="item">The item to add.</param>
 public new void Add(T item)
 {
     ProtoPreconditions.CheckNotNullUnconstrained(item, "item");
     base.Add(item);
 }
Exemple #8
0
 /// <summary>
 /// Determines whether the specified key is present in the map.
 /// </summary>
 /// <param name="key">The key to check.</param>
 /// <returns><c>true</c> if the map contains the given key; <c>false</c> otherwise.</returns>
 public bool ContainsKey(TKey key)
 {
     ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
     return(map.ContainsKey(key));
 }
Exemple #9
0
 /// <summary>
 /// Determines whether this instance is empty.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <returns>
 ///   <c>true</c> if the specified message is empty; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsEmpty(this IMessage message)
 {
     ProtoPreconditions.CheckNotNull(message, nameof(message));
     return(message.CalculateSize() == 0);
 }
Exemple #10
0
 /// <summary>
 /// Returns a bool indictating whether this Any message is of the target message type
 /// </summary>
 /// <param name="descriptor">The descriptor of the message type</param>
 /// <returns><c>true</c> if the type name matches the descriptor's full name or <c>false</c> otherwise</returns>
 public bool Is(MessageDescriptor descriptor)
 {
     ProtoPreconditions.CheckNotNull(descriptor, "descriptor");
     return(GetTypeName(TypeUrl) == descriptor.FullName);
 }
 /// <summary>
 /// Constructs a new attribute instance for the given name.
 /// </summary>
 /// <param name="name">The name of the element in the .proto file.</param>
 public OriginalNameAttribute(string name)
 {
     Name = ProtoPreconditions.CheckNotNull(name, nameof(name));
 }