"Fossies" - the Fresh Open Source Software Archive

Member "protobuf-3.12.3/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs" (2 Jun 2020, 10980 Bytes) of package /linux/misc/protobuf-all-3.12.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C# source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Any.cs" see the Fossies "Dox" file reference documentation.

    1 // <auto-generated>
    2 //     Generated by the protocol buffer compiler.  DO NOT EDIT!
    3 //     source: google/protobuf/any.proto
    4 // </auto-generated>
    5 #pragma warning disable 1591, 0612, 3021
    6 #region Designer generated code
    7 
    8 using pb = global::Google.Protobuf;
    9 using pbc = global::Google.Protobuf.Collections;
   10 using pbr = global::Google.Protobuf.Reflection;
   11 using scg = global::System.Collections.Generic;
   12 namespace Google.Protobuf.WellKnownTypes {
   13 
   14   /// <summary>Holder for reflection information generated from google/protobuf/any.proto</summary>
   15   public static partial class AnyReflection {
   16 
   17     #region Descriptor
   18     /// <summary>File descriptor for google/protobuf/any.proto</summary>
   19     public static pbr::FileDescriptor Descriptor {
   20       get { return descriptor; }
   21     }
   22     private static pbr::FileDescriptor descriptor;
   23 
   24     static AnyReflection() {
   25       byte[] descriptorData = global::System.Convert.FromBase64String(
   26           string.Concat(
   27             "Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi",
   28             "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQm8KE2Nv",
   29             "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaJWdpdGh1Yi5jb20vZ29s",
   30             "YW5nL3Byb3RvYnVmL3B0eXBlcy9hbnmiAgNHUEKqAh5Hb29nbGUuUHJvdG9i",
   31             "dWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw=="));
   32       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
   33           new pbr::FileDescriptor[] { },
   34           new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
   35             new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.WellKnownTypes.Any), global::Google.Protobuf.WellKnownTypes.Any.Parser, new[]{ "TypeUrl", "Value" }, null, null, null, null)
   36           }));
   37     }
   38     #endregion
   39 
   40   }
   41   #region Messages
   42   /// <summary>
   43   /// `Any` contains an arbitrary serialized protocol buffer message along with a
   44   /// URL that describes the type of the serialized message.
   45   ///
   46   /// Protobuf library provides support to pack/unpack Any values in the form
   47   /// of utility functions or additional generated methods of the Any type.
   48   ///
   49   /// Example 1: Pack and unpack a message in C++.
   50   ///
   51   ///     Foo foo = ...;
   52   ///     Any any;
   53   ///     any.PackFrom(foo);
   54   ///     ...
   55   ///     if (any.UnpackTo(&amp;foo)) {
   56   ///       ...
   57   ///     }
   58   ///
   59   /// Example 2: Pack and unpack a message in Java.
   60   ///
   61   ///     Foo foo = ...;
   62   ///     Any any = Any.pack(foo);
   63   ///     ...
   64   ///     if (any.is(Foo.class)) {
   65   ///       foo = any.unpack(Foo.class);
   66   ///     }
   67   ///
   68   ///  Example 3: Pack and unpack a message in Python.
   69   ///
   70   ///     foo = Foo(...)
   71   ///     any = Any()
   72   ///     any.Pack(foo)
   73   ///     ...
   74   ///     if any.Is(Foo.DESCRIPTOR):
   75   ///       any.Unpack(foo)
   76   ///       ...
   77   ///
   78   ///  Example 4: Pack and unpack a message in Go
   79   ///
   80   ///      foo := &amp;pb.Foo{...}
   81   ///      any, err := ptypes.MarshalAny(foo)
   82   ///      ...
   83   ///      foo := &amp;pb.Foo{}
   84   ///      if err := ptypes.UnmarshalAny(any, foo); err != nil {
   85   ///        ...
   86   ///      }
   87   ///
   88   /// The pack methods provided by protobuf library will by default use
   89   /// 'type.googleapis.com/full.type.name' as the type URL and the unpack
   90   /// methods only use the fully qualified type name after the last '/'
   91   /// in the type URL, for example "foo.bar.com/x/y.z" will yield type
   92   /// name "y.z".
   93   ///
   94   /// JSON
   95   /// ====
   96   /// The JSON representation of an `Any` value uses the regular
   97   /// representation of the deserialized, embedded message, with an
   98   /// additional field `@type` which contains the type URL. Example:
   99   ///
  100   ///     package google.profile;
  101   ///     message Person {
  102   ///       string first_name = 1;
  103   ///       string last_name = 2;
  104   ///     }
  105   ///
  106   ///     {
  107   ///       "@type": "type.googleapis.com/google.profile.Person",
  108   ///       "firstName": &lt;string>,
  109   ///       "lastName": &lt;string>
  110   ///     }
  111   ///
  112   /// If the embedded message type is well-known and has a custom JSON
  113   /// representation, that representation will be embedded adding a field
  114   /// `value` which holds the custom JSON in addition to the `@type`
  115   /// field. Example (for message [google.protobuf.Duration][]):
  116   ///
  117   ///     {
  118   ///       "@type": "type.googleapis.com/google.protobuf.Duration",
  119   ///       "value": "1.212s"
  120   ///     }
  121   /// </summary>
  122   public sealed partial class Any : pb::IMessage<Any> {
  123     private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any());
  124     private pb::UnknownFieldSet _unknownFields;
  125     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  126     public static pb::MessageParser<Any> Parser { get { return _parser; } }
  127 
  128     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  129     public static pbr::MessageDescriptor Descriptor {
  130       get { return global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor.MessageTypes[0]; }
  131     }
  132 
  133     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  134     pbr::MessageDescriptor pb::IMessage.Descriptor {
  135       get { return Descriptor; }
  136     }
  137 
  138     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  139     public Any() {
  140       OnConstruction();
  141     }
  142 
  143     partial void OnConstruction();
  144 
  145     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  146     public Any(Any other) : this() {
  147       typeUrl_ = other.typeUrl_;
  148       value_ = other.value_;
  149       _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
  150     }
  151 
  152     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  153     public Any Clone() {
  154       return new Any(this);
  155     }
  156 
  157     /// <summary>Field number for the "type_url" field.</summary>
  158     public const int TypeUrlFieldNumber = 1;
  159     private string typeUrl_ = "";
  160     /// <summary>
  161     /// A URL/resource name that uniquely identifies the type of the serialized
  162     /// protocol buffer message. This string must contain at least
  163     /// one "/" character. The last segment of the URL's path must represent
  164     /// the fully qualified name of the type (as in
  165     /// `path/google.protobuf.Duration`). The name should be in a canonical form
  166     /// (e.g., leading "." is not accepted).
  167     ///
  168     /// In practice, teams usually precompile into the binary all types that they
  169     /// expect it to use in the context of Any. However, for URLs which use the
  170     /// scheme `http`, `https`, or no scheme, one can optionally set up a type
  171     /// server that maps type URLs to message definitions as follows:
  172     ///
  173     /// * If no scheme is provided, `https` is assumed.
  174     /// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
  175     ///   value in binary format, or produce an error.
  176     /// * Applications are allowed to cache lookup results based on the
  177     ///   URL, or have them precompiled into a binary to avoid any
  178     ///   lookup. Therefore, binary compatibility needs to be preserved
  179     ///   on changes to types. (Use versioned type names to manage
  180     ///   breaking changes.)
  181     ///
  182     /// Note: this functionality is not currently available in the official
  183     /// protobuf release, and it is not used for type URLs beginning with
  184     /// type.googleapis.com.
  185     ///
  186     /// Schemes other than `http`, `https` (or the empty scheme) might be
  187     /// used with implementation specific semantics.
  188     /// </summary>
  189     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  190     public string TypeUrl {
  191       get { return typeUrl_; }
  192       set {
  193         typeUrl_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
  194       }
  195     }
  196 
  197     /// <summary>Field number for the "value" field.</summary>
  198     public const int ValueFieldNumber = 2;
  199     private pb::ByteString value_ = pb::ByteString.Empty;
  200     /// <summary>
  201     /// Must be a valid serialized protocol buffer of the above specified type.
  202     /// </summary>
  203     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  204     public pb::ByteString Value {
  205       get { return value_; }
  206       set {
  207         value_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
  208       }
  209     }
  210 
  211     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  212     public override bool Equals(object other) {
  213       return Equals(other as Any);
  214     }
  215 
  216     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  217     public bool Equals(Any other) {
  218       if (ReferenceEquals(other, null)) {
  219         return false;
  220       }
  221       if (ReferenceEquals(other, this)) {
  222         return true;
  223       }
  224       if (TypeUrl != other.TypeUrl) return false;
  225       if (Value != other.Value) return false;
  226       return Equals(_unknownFields, other._unknownFields);
  227     }
  228 
  229     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  230     public override int GetHashCode() {
  231       int hash = 1;
  232       if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode();
  233       if (Value.Length != 0) hash ^= Value.GetHashCode();
  234       if (_unknownFields != null) {
  235         hash ^= _unknownFields.GetHashCode();
  236       }
  237       return hash;
  238     }
  239 
  240     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  241     public override string ToString() {
  242       return pb::JsonFormatter.ToDiagnosticString(this);
  243     }
  244 
  245     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  246     public void WriteTo(pb::CodedOutputStream output) {
  247       if (TypeUrl.Length != 0) {
  248         output.WriteRawTag(10);
  249         output.WriteString(TypeUrl);
  250       }
  251       if (Value.Length != 0) {
  252         output.WriteRawTag(18);
  253         output.WriteBytes(Value);
  254       }
  255       if (_unknownFields != null) {
  256         _unknownFields.WriteTo(output);
  257       }
  258     }
  259 
  260     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  261     public int CalculateSize() {
  262       int size = 0;
  263       if (TypeUrl.Length != 0) {
  264         size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeUrl);
  265       }
  266       if (Value.Length != 0) {
  267         size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value);
  268       }
  269       if (_unknownFields != null) {
  270         size += _unknownFields.CalculateSize();
  271       }
  272       return size;
  273     }
  274 
  275     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  276     public void MergeFrom(Any other) {
  277       if (other == null) {
  278         return;
  279       }
  280       if (other.TypeUrl.Length != 0) {
  281         TypeUrl = other.TypeUrl;
  282       }
  283       if (other.Value.Length != 0) {
  284         Value = other.Value;
  285       }
  286       _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
  287     }
  288 
  289     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  290     public void MergeFrom(pb::CodedInputStream input) {
  291       uint tag;
  292       while ((tag = input.ReadTag()) != 0) {
  293         switch(tag) {
  294           default:
  295             _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
  296             break;
  297           case 10: {
  298             TypeUrl = input.ReadString();
  299             break;
  300           }
  301           case 18: {
  302             Value = input.ReadBytes();
  303             break;
  304           }
  305         }
  306       }
  307     }
  308 
  309   }
  310 
  311   #endregion
  312 
  313 }
  314 
  315 #endregion Designer generated code