"Fossies" - the Fresh Open Source Software Archive 
Member "protobuf-3.21.1/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs" (27 May 2022, 13699 Bytes) of package /linux/misc/protobuf-all-3.21.1.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 and the last
Fossies "Diffs" side-by-side code changes report:
3.20.1_vs_3.21.0.
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, 8981
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 "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnYKE2Nv",
29 "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaLGdvb2dsZS5nb2xhbmcu",
30 "b3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2FueXBiogIDR1BCqgIeR29vZ2xl",
31 "LlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM="));
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(&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 := &pb.Foo{...}
81 /// any, err := anypb.New(foo)
82 /// if err != nil {
83 /// ...
84 /// }
85 /// ...
86 /// foo := &pb.Foo{}
87 /// if err := any.UnmarshalTo(foo); err != nil {
88 /// ...
89 /// }
90 ///
91 /// The pack methods provided by protobuf library will by default use
92 /// 'type.googleapis.com/full.type.name' as the type URL and the unpack
93 /// methods only use the fully qualified type name after the last '/'
94 /// in the type URL, for example "foo.bar.com/x/y.z" will yield type
95 /// name "y.z".
96 ///
97 /// JSON
98 ///
99 /// The JSON representation of an `Any` value uses the regular
100 /// representation of the deserialized, embedded message, with an
101 /// additional field `@type` which contains the type URL. Example:
102 ///
103 /// package google.profile;
104 /// message Person {
105 /// string first_name = 1;
106 /// string last_name = 2;
107 /// }
108 ///
109 /// {
110 /// "@type": "type.googleapis.com/google.profile.Person",
111 /// "firstName": <string>,
112 /// "lastName": <string>
113 /// }
114 ///
115 /// If the embedded message type is well-known and has a custom JSON
116 /// representation, that representation will be embedded adding a field
117 /// `value` which holds the custom JSON in addition to the `@type`
118 /// field. Example (for message [google.protobuf.Duration][]):
119 ///
120 /// {
121 /// "@type": "type.googleapis.com/google.protobuf.Duration",
122 /// "value": "1.212s"
123 /// }
124 /// </summary>
125 public sealed partial class Any : pb::IMessage<Any>
126 #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
127 , pb::IBufferMessage
128 #endif
129 {
130 private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any());
131 private pb::UnknownFieldSet _unknownFields;
132 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
133 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
134 public static pb::MessageParser<Any> Parser { get { return _parser; } }
135
136 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
137 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
138 public static pbr::MessageDescriptor Descriptor {
139 get { return global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor.MessageTypes[0]; }
140 }
141
142 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
143 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
144 pbr::MessageDescriptor pb::IMessage.Descriptor {
145 get { return Descriptor; }
146 }
147
148 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
149 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
150 public Any() {
151 OnConstruction();
152 }
153
154 partial void OnConstruction();
155
156 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
157 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
158 public Any(Any other) : this() {
159 typeUrl_ = other.typeUrl_;
160 value_ = other.value_;
161 _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
162 }
163
164 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
165 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
166 public Any Clone() {
167 return new Any(this);
168 }
169
170 /// <summary>Field number for the "type_url" field.</summary>
171 public const int TypeUrlFieldNumber = 1;
172 private string typeUrl_ = "";
173 /// <summary>
174 /// A URL/resource name that uniquely identifies the type of the serialized
175 /// protocol buffer message. This string must contain at least
176 /// one "/" character. The last segment of the URL's path must represent
177 /// the fully qualified name of the type (as in
178 /// `path/google.protobuf.Duration`). The name should be in a canonical form
179 /// (e.g., leading "." is not accepted).
180 ///
181 /// In practice, teams usually precompile into the binary all types that they
182 /// expect it to use in the context of Any. However, for URLs which use the
183 /// scheme `http`, `https`, or no scheme, one can optionally set up a type
184 /// server that maps type URLs to message definitions as follows:
185 ///
186 /// * If no scheme is provided, `https` is assumed.
187 /// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
188 /// value in binary format, or produce an error.
189 /// * Applications are allowed to cache lookup results based on the
190 /// URL, or have them precompiled into a binary to avoid any
191 /// lookup. Therefore, binary compatibility needs to be preserved
192 /// on changes to types. (Use versioned type names to manage
193 /// breaking changes.)
194 ///
195 /// Note: this functionality is not currently available in the official
196 /// protobuf release, and it is not used for type URLs beginning with
197 /// type.googleapis.com.
198 ///
199 /// Schemes other than `http`, `https` (or the empty scheme) might be
200 /// used with implementation specific semantics.
201 /// </summary>
202 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
203 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
204 public string TypeUrl {
205 get { return typeUrl_; }
206 set {
207 typeUrl_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
208 }
209 }
210
211 /// <summary>Field number for the "value" field.</summary>
212 public const int ValueFieldNumber = 2;
213 private pb::ByteString value_ = pb::ByteString.Empty;
214 /// <summary>
215 /// Must be a valid serialized protocol buffer of the above specified type.
216 /// </summary>
217 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
218 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
219 public pb::ByteString Value {
220 get { return value_; }
221 set {
222 value_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
223 }
224 }
225
226 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
227 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
228 public override bool Equals(object other) {
229 return Equals(other as Any);
230 }
231
232 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
233 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
234 public bool Equals(Any other) {
235 if (ReferenceEquals(other, null)) {
236 return false;
237 }
238 if (ReferenceEquals(other, this)) {
239 return true;
240 }
241 if (TypeUrl != other.TypeUrl) return false;
242 if (Value != other.Value) return false;
243 return Equals(_unknownFields, other._unknownFields);
244 }
245
246 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
247 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
248 public override int GetHashCode() {
249 int hash = 1;
250 if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode();
251 if (Value.Length != 0) hash ^= Value.GetHashCode();
252 if (_unknownFields != null) {
253 hash ^= _unknownFields.GetHashCode();
254 }
255 return hash;
256 }
257
258 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
259 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
260 public override string ToString() {
261 return pb::JsonFormatter.ToDiagnosticString(this);
262 }
263
264 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
265 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
266 public void WriteTo(pb::CodedOutputStream output) {
267 #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
268 output.WriteRawMessage(this);
269 #else
270 if (TypeUrl.Length != 0) {
271 output.WriteRawTag(10);
272 output.WriteString(TypeUrl);
273 }
274 if (Value.Length != 0) {
275 output.WriteRawTag(18);
276 output.WriteBytes(Value);
277 }
278 if (_unknownFields != null) {
279 _unknownFields.WriteTo(output);
280 }
281 #endif
282 }
283
284 #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
285 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
286 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
287 void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
288 if (TypeUrl.Length != 0) {
289 output.WriteRawTag(10);
290 output.WriteString(TypeUrl);
291 }
292 if (Value.Length != 0) {
293 output.WriteRawTag(18);
294 output.WriteBytes(Value);
295 }
296 if (_unknownFields != null) {
297 _unknownFields.WriteTo(ref output);
298 }
299 }
300 #endif
301
302 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
303 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
304 public int CalculateSize() {
305 int size = 0;
306 if (TypeUrl.Length != 0) {
307 size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeUrl);
308 }
309 if (Value.Length != 0) {
310 size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value);
311 }
312 if (_unknownFields != null) {
313 size += _unknownFields.CalculateSize();
314 }
315 return size;
316 }
317
318 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
319 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
320 public void MergeFrom(Any other) {
321 if (other == null) {
322 return;
323 }
324 if (other.TypeUrl.Length != 0) {
325 TypeUrl = other.TypeUrl;
326 }
327 if (other.Value.Length != 0) {
328 Value = other.Value;
329 }
330 _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
331 }
332
333 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
334 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
335 public void MergeFrom(pb::CodedInputStream input) {
336 #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
337 input.ReadRawMessage(this);
338 #else
339 uint tag;
340 while ((tag = input.ReadTag()) != 0) {
341 switch(tag) {
342 default:
343 _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
344 break;
345 case 10: {
346 TypeUrl = input.ReadString();
347 break;
348 }
349 case 18: {
350 Value = input.ReadBytes();
351 break;
352 }
353 }
354 }
355 #endif
356 }
357
358 #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
359 [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
360 [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
361 void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
362 uint tag;
363 while ((tag = input.ReadTag()) != 0) {
364 switch(tag) {
365 default:
366 _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
367 break;
368 case 10: {
369 TypeUrl = input.ReadString();
370 break;
371 }
372 case 18: {
373 Value = input.ReadBytes();
374 break;
375 }
376 }
377 }
378 }
379 #endif
380
381 }
382
383 #endregion
384
385 }
386
387 #endregion Designer generated code