mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 19:18:56 +00:00
Default file name now has _generated in it,
so we need to rename all the generated test files tests/namespace_test/NamespaceA/TableInC.* are no longer used, so these can be deleted
This commit is contained in:
98
tests/union_vector/Character_generated.cs
Normal file
98
tests/union_vector/Character_generated.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
// <auto-generated>
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// </auto-generated>
|
||||
|
||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
public enum Character : byte
|
||||
{
|
||||
NONE = 0,
|
||||
MuLan = 1,
|
||||
Rapunzel = 2,
|
||||
Belle = 3,
|
||||
BookFan = 4,
|
||||
Other = 5,
|
||||
Unused = 6,
|
||||
};
|
||||
|
||||
public class CharacterUnion {
|
||||
public Character Type { get; set; }
|
||||
public object Value { get; set; }
|
||||
|
||||
public CharacterUnion() {
|
||||
this.Type = Character.NONE;
|
||||
this.Value = null;
|
||||
}
|
||||
|
||||
public T As<T>() where T : class { return this.Value as T; }
|
||||
public AttackerT AsMuLan() { return this.As<AttackerT>(); }
|
||||
public static CharacterUnion FromMuLan(AttackerT _mulan) { return new CharacterUnion{ Type = Character.MuLan, Value = _mulan }; }
|
||||
public RapunzelT AsRapunzel() { return this.As<RapunzelT>(); }
|
||||
public static CharacterUnion FromRapunzel(RapunzelT _rapunzel) { return new CharacterUnion{ Type = Character.Rapunzel, Value = _rapunzel }; }
|
||||
public BookReaderT AsBelle() { return this.As<BookReaderT>(); }
|
||||
public static CharacterUnion FromBelle(BookReaderT _belle) { return new CharacterUnion{ Type = Character.Belle, Value = _belle }; }
|
||||
public BookReaderT AsBookFan() { return this.As<BookReaderT>(); }
|
||||
public static CharacterUnion FromBookFan(BookReaderT _bookfan) { return new CharacterUnion{ Type = Character.BookFan, Value = _bookfan }; }
|
||||
public string AsOther() { return this.As<string>(); }
|
||||
public static CharacterUnion FromOther(string _other) { return new CharacterUnion{ Type = Character.Other, Value = _other }; }
|
||||
public string AsUnused() { return this.As<string>(); }
|
||||
public static CharacterUnion FromUnused(string _unused) { return new CharacterUnion{ Type = Character.Unused, Value = _unused }; }
|
||||
|
||||
public static int Pack(FlatBuffers.FlatBufferBuilder builder, CharacterUnion _o) {
|
||||
switch (_o.Type) {
|
||||
default: return 0;
|
||||
case Character.MuLan: return Attacker.Pack(builder, _o.AsMuLan()).Value;
|
||||
case Character.Rapunzel: return Rapunzel.Pack(builder, _o.AsRapunzel()).Value;
|
||||
case Character.Belle: return BookReader.Pack(builder, _o.AsBelle()).Value;
|
||||
case Character.BookFan: return BookReader.Pack(builder, _o.AsBookFan()).Value;
|
||||
case Character.Other: return builder.CreateString(_o.AsOther()).Value;
|
||||
case Character.Unused: return builder.CreateString(_o.AsUnused()).Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CharacterUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||
public override bool CanConvert(System.Type objectType) {
|
||||
return objectType == typeof(CharacterUnion) || objectType == typeof(System.Collections.Generic.List<CharacterUnion>);
|
||||
}
|
||||
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) {
|
||||
var _olist = value as System.Collections.Generic.List<CharacterUnion>;
|
||||
if (_olist != null) {
|
||||
writer.WriteStartArray();
|
||||
foreach (var _o in _olist) { this.WriteJson(writer, _o, serializer); }
|
||||
writer.WriteEndArray();
|
||||
} else {
|
||||
this.WriteJson(writer, value as CharacterUnion, serializer);
|
||||
}
|
||||
}
|
||||
public void WriteJson(Newtonsoft.Json.JsonWriter writer, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer) {
|
||||
if (_o == null) return;
|
||||
serializer.Serialize(writer, _o.Value);
|
||||
}
|
||||
public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) {
|
||||
var _olist = existingValue as System.Collections.Generic.List<CharacterUnion>;
|
||||
if (_olist != null) {
|
||||
for (var _j = 0; _j < _olist.Count; ++_j) {
|
||||
reader.Read();
|
||||
_olist[_j] = this.ReadJson(reader, _olist[_j], serializer);
|
||||
}
|
||||
reader.Read();
|
||||
return _olist;
|
||||
} else {
|
||||
return this.ReadJson(reader, existingValue as CharacterUnion, serializer);
|
||||
}
|
||||
}
|
||||
public CharacterUnion ReadJson(Newtonsoft.Json.JsonReader reader, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer) {
|
||||
if (_o == null) return null;
|
||||
switch (_o.Type) {
|
||||
default: break;
|
||||
case Character.MuLan: _o.Value = serializer.Deserialize<AttackerT>(reader); break;
|
||||
case Character.Rapunzel: _o.Value = serializer.Deserialize<RapunzelT>(reader); break;
|
||||
case Character.Belle: _o.Value = serializer.Deserialize<BookReaderT>(reader); break;
|
||||
case Character.BookFan: _o.Value = serializer.Deserialize<BookReaderT>(reader); break;
|
||||
case Character.Other: _o.Value = serializer.Deserialize<string>(reader); break;
|
||||
case Character.Unused: _o.Value = serializer.Deserialize<string>(reader); break;
|
||||
}
|
||||
return _o;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user