public static FixedSizeList <T> Create(Pointer pointer, IList <T> items) { var accessor = TypeAccessor <T> .Instance; if (accessor.IsStruct) { throw new InvalidOperationException("Lists of structs cannot be created retrospectively, since the list *is* the data"); } if (items == null) { return(default(FixedSizeList <T>)); } if (items.Count == 0) { return(FixedSizeList <T> .Create(pointer, 0)); } FixedSizeList <T> list = accessor.CreateList(pointer, items.Count); for (int i = 0; i < items.Count; i++) { list[i] = items[i]; } return(list); }
public CodeWriter(TextWriter destination, FixedSizeList <Schema.Node> nodes, string @namespace, string serializer) { this.destination = destination; this.@namespace = @namespace; this.serializer = serializer; foreach (var node in nodes) { if (node.id != 0) { map[node.id] = node; } } }
public CodeWriter(TextWriter destination, FixedSizeList <Schema.Node> nodes, string @namespace, string serializer) { this.destination = destination; this.@namespace = @namespace; this.serializer = serializer; ulong fileNodeId = 0; ulong nsNodeId = 0; foreach (var node in nodes) { if (node.id != 0) { map[node.id] = node; } if (fileNodeId == 0 && node.Union == Node.Unions.file) { fileNodeId = node.id; } if (nsNodeId == 0 && node.Union == Node.Unions.annotation && node.annotation.targetsFile && node.annotation.type.Union == Schema.Type.Unions.text) { string name = node.displayName.ToString(); string anno = name.Substring((int)node.displayNamePrefixLength); if (name.Contains("csharp") && anno == "namespace") { nsNodeId = node.id; } } } if (nsNodeId != 0 && fileNodeId != 0) { Node fileNode = map[fileNodeId]; foreach (var anno in fileNode.annotations) { if (anno.id == nsNodeId) { string ns = anno.value.text.ToString(); if (ns.Length > 0) { //this.@namespace = ns; } } } } }
public static FixedSizeList <T> Create(Pointer pointer, IList <T> items) { if (items == null) { return(default(FixedSizeList <T>)); } if (items.Count == 0) { return(FixedSizeList <T> .Create(pointer, 0)); } var accessor = StructAccessor <T> .Instance; FixedSizeList <T> list = accessor.IsPointer ? accessor.CreateList(pointer, items.Count, ElementSize.EightBytesPointer) : accessor.CreateList(pointer, items.Count); for (int i = 0; i < items.Count; i++) { list[i] = items[i]; } return(list); }
public CSharpStructWriter(TextWriter destination, FixedSizeList <Schema.Node> nodes, string @namespace) : base(destination, nodes, @namespace, "not used") { }
public override void SetElement(Pointer pointer, int index, FixedSizeList <TInner> value) { pointer.SetListPointer(index, value); }
public FixedSizeList <T> AllocateList <T>(IList <T> items) { return(FixedSizeList <T> .Create(this.Root, items)); }