forked from confluentinc/confluent-kafka-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser2.cs
81 lines (77 loc) · 2.44 KB
/
User2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using Avro;
using Avro.Specific;
namespace Confluent.Kafka.Examples.AvroSpecific
{
// This class is modified from the auto-generated class
public partial class User2 : ISpecificRecord
{
// The namespace and name of the schema does not need to match the namespace and name of the actual .NET data class.
// Think about a use case where a producer and a consumer use completely different languages.
public static Schema _SCHEMA = Schema.Parse("{\"type\":\"record\",\"name\":\"SomeUser\",\"namespace\":\"SomeNamespace" +
"\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favorite_number\",\"type\":[\"i" +
"nt\",\"null\"]},{\"name\":\"favorite_color\",\"type\":[\"string\",\"null\"]}]}");
private string _name;
private int? _favorite_number;
private string _favorite_color;
public virtual Schema Schema
{
get
{
return _SCHEMA;
}
}
public string name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public int? favorite_number
{
get
{
return _favorite_number;
}
set
{
_favorite_number = value;
}
}
public string favorite_color
{
get
{
return _favorite_color;
}
set
{
_favorite_color = value;
}
}
public virtual object Get(int fieldPos)
{
switch (fieldPos)
{
case 0: return name;
case 1: return favorite_number;
case 2: return favorite_color;
default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()");
};
}
public virtual void Put(int fieldPos, object fieldValue)
{
switch (fieldPos)
{
case 0: name = (System.String)fieldValue; break;
case 1: favorite_number = (System.Nullable<int>)fieldValue; break;
case 2: favorite_color = (System.String)fieldValue; break;
default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()");
};
}
}
}