mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-12 07:50:59 +00:00
[C#] Add Union Constructor Utility for ObjectAPI. (#6105)
* [C#] add union constructor utility. * add union utility test. * std::tolower -> CharToLower * use std::transform instead * rebase to master. and regenerate test code
This commit is contained in:
@@ -25,8 +25,11 @@ public class AnyUnion {
|
||||
|
||||
public T As<T>() where T : class { return this.Value as T; }
|
||||
public MyGame.Example.MonsterT AsMonster() { return this.As<MyGame.Example.MonsterT>(); }
|
||||
public static AnyUnion FromMonster(MyGame.Example.MonsterT _monster) { return new AnyUnion{ Type = Any.Monster, Value = _monster }; }
|
||||
internal MyGame.Example.TestSimpleTableWithEnumT AsTestSimpleTableWithEnum() { return this.As<MyGame.Example.TestSimpleTableWithEnumT>(); }
|
||||
internal static AnyUnion FromTestSimpleTableWithEnum(MyGame.Example.TestSimpleTableWithEnumT _testsimpletablewithenum) { return new AnyUnion{ Type = Any.TestSimpleTableWithEnum, Value = _testsimpletablewithenum }; }
|
||||
public MyGame.Example2.MonsterT AsMyGame_Example2_Monster() { return this.As<MyGame.Example2.MonsterT>(); }
|
||||
public static AnyUnion FromMyGame_Example2_Monster(MyGame.Example2.MonsterT _mygame_example2_monster) { return new AnyUnion{ Type = Any.MyGame_Example2_Monster, Value = _mygame_example2_monster }; }
|
||||
|
||||
public static int Pack(FlatBuffers.FlatBufferBuilder builder, AnyUnion _o) {
|
||||
switch (_o.Type) {
|
||||
|
||||
@@ -25,8 +25,11 @@ public class AnyAmbiguousAliasesUnion {
|
||||
|
||||
public T As<T>() where T : class { return this.Value as T; }
|
||||
public MyGame.Example.MonsterT AsM1() { return this.As<MyGame.Example.MonsterT>(); }
|
||||
public static AnyAmbiguousAliasesUnion FromM1(MyGame.Example.MonsterT _m1) { return new AnyAmbiguousAliasesUnion{ Type = AnyAmbiguousAliases.M1, Value = _m1 }; }
|
||||
public MyGame.Example.MonsterT AsM2() { return this.As<MyGame.Example.MonsterT>(); }
|
||||
public static AnyAmbiguousAliasesUnion FromM2(MyGame.Example.MonsterT _m2) { return new AnyAmbiguousAliasesUnion{ Type = AnyAmbiguousAliases.M2, Value = _m2 }; }
|
||||
public MyGame.Example.MonsterT AsM3() { return this.As<MyGame.Example.MonsterT>(); }
|
||||
public static AnyAmbiguousAliasesUnion FromM3(MyGame.Example.MonsterT _m3) { return new AnyAmbiguousAliasesUnion{ Type = AnyAmbiguousAliases.M3, Value = _m3 }; }
|
||||
|
||||
public static int Pack(FlatBuffers.FlatBufferBuilder builder, AnyAmbiguousAliasesUnion _o) {
|
||||
switch (_o.Type) {
|
||||
|
||||
@@ -25,8 +25,11 @@ public class AnyUniqueAliasesUnion {
|
||||
|
||||
public T As<T>() where T : class { return this.Value as T; }
|
||||
public MyGame.Example.MonsterT AsM() { return this.As<MyGame.Example.MonsterT>(); }
|
||||
public static AnyUniqueAliasesUnion FromM(MyGame.Example.MonsterT _m) { return new AnyUniqueAliasesUnion{ Type = AnyUniqueAliases.M, Value = _m }; }
|
||||
internal MyGame.Example.TestSimpleTableWithEnumT AsTS() { return this.As<MyGame.Example.TestSimpleTableWithEnumT>(); }
|
||||
internal static AnyUniqueAliasesUnion FromTS(MyGame.Example.TestSimpleTableWithEnumT _ts) { return new AnyUniqueAliasesUnion{ Type = AnyUniqueAliases.TS, Value = _ts }; }
|
||||
public MyGame.Example2.MonsterT AsM2() { return this.As<MyGame.Example2.MonsterT>(); }
|
||||
public static AnyUniqueAliasesUnion FromM2(MyGame.Example2.MonsterT _m2) { return new AnyUniqueAliasesUnion{ Type = AnyUniqueAliases.M2, Value = _m2 }; }
|
||||
|
||||
public static int Pack(FlatBuffers.FlatBufferBuilder builder, AnyUniqueAliasesUnion _o) {
|
||||
switch (_o.Type) {
|
||||
|
||||
Reference in New Issue
Block a user