mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-21 19:48:28 +00:00
[C#] support Object API (#5710)
* [C#] support Object API * fix sign-compare * fix indent * add new line before for loop. * using auto whenever possible * reduce the amout of blank lines. * wip: support vectors of union * done: support unions of vectors * set C# version to 4.0 * remove null propagation operator * remove auto property initializer * remove expression-bodied method * remove pattern matching * add Example2 to NetTest.sh * separate JavaUsage.md and CsharpUsage.md from JavaCsharpUsage.md * add C# Object based API notes. * support vs2010. * remove range based for loop. * remove System.Linq * fix indent * CreateSharedString to CreateString * check shared attribute * snake case
This commit is contained in:
@@ -6,6 +6,7 @@ namespace NamespaceA
|
||||
{
|
||||
|
||||
using global::System;
|
||||
using global::System.Collections.Generic;
|
||||
using global::FlatBuffers;
|
||||
|
||||
public struct TableInFirstNS : IFlatbufferObject
|
||||
@@ -31,7 +32,39 @@ public struct TableInFirstNS : IFlatbufferObject
|
||||
int o = builder.EndTable();
|
||||
return new Offset<NamespaceA.TableInFirstNS>(o);
|
||||
}
|
||||
public TableInFirstNST UnPack() {
|
||||
var _o = new TableInFirstNST();
|
||||
this.UnPackTo(_o);
|
||||
return _o;
|
||||
}
|
||||
public void UnPackTo(TableInFirstNST _o) {
|
||||
_o.FooTable = this.FooTable.HasValue ? this.FooTable.Value.UnPack() : null;
|
||||
_o.FooEnum = this.FooEnum;
|
||||
_o.FooStruct = this.FooStruct.HasValue ? this.FooStruct.Value.UnPack() : null;
|
||||
}
|
||||
public static Offset<NamespaceA.TableInFirstNS> Pack(FlatBufferBuilder builder, TableInFirstNST _o) {
|
||||
if (_o == null) return default(Offset<NamespaceA.TableInFirstNS>);
|
||||
var _foo_table = _o.FooTable == null ? default(Offset<NamespaceA.NamespaceB.TableInNestedNS>) : NamespaceA.NamespaceB.TableInNestedNS.Pack(builder, _o.FooTable);
|
||||
StartTableInFirstNS(builder);
|
||||
AddFooTable(builder, _foo_table);
|
||||
AddFooEnum(builder, _o.FooEnum);
|
||||
AddFooStruct(builder, NamespaceA.NamespaceB.StructInNestedNS.Pack(builder, _o.FooStruct));
|
||||
return EndTableInFirstNS(builder);
|
||||
}
|
||||
};
|
||||
|
||||
public class TableInFirstNST
|
||||
{
|
||||
public NamespaceA.NamespaceB.TableInNestedNST FooTable { get; set; }
|
||||
public NamespaceA.NamespaceB.EnumInNestedNS FooEnum { get; set; }
|
||||
public NamespaceA.NamespaceB.StructInNestedNST FooStruct { get; set; }
|
||||
|
||||
public TableInFirstNST() {
|
||||
this.FooTable = null;
|
||||
this.FooEnum = NamespaceA.NamespaceB.EnumInNestedNS.A;
|
||||
this.FooStruct = new NamespaceA.NamespaceB.StructInNestedNST();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user