internal static DxfTable ReadFromBuffer(DxfCodePairBufferReader buffer) { var table = new DxfUcsTable(); table.Items.Clear(); while (buffer.ItemsRemain) { var pair = buffer.Peek(); buffer.Advance(); if (DxfTablesSection.IsTableEnd(pair)) { break; } if (pair.Code == 0 && pair.StringValue == DxfTable.UcsText) { var item = DxfUcs.FromBuffer(buffer); table.Items.Add(item); } } return(table); }
internal static DxfTable ReadFromBuffer(DxfCodePairBufferReader buffer) { var table = new DxfUcsTable(); while (buffer.ItemsRemain) { var pair = buffer.Peek(); buffer.Advance(); if (DxfTablesSection.IsTableEnd(pair)) { break; } if (pair.Code == 0 && pair.StringValue == DxfTable.UcsText) { var item = DxfUcs.FromBuffer(buffer); table.Items.Add(item); } } return table; }
internal static DxfTable FromBuffer(DxfCodePairBufferReader buffer) { var pair = buffer.Peek(); buffer.Advance(); if (pair.Code != 2) { throw new DxfReadException("Expected table type.", pair); } var tableType = pair.StringValue; // read common table values var commonValues = new List <DxfCodePair>(); var groups = new List <DxfCodePairGroup>(); pair = buffer.Peek(); while (pair != null && pair.Code != 0) { buffer.Advance(); if (pair.Code == DxfCodePairGroup.GroupCodeNumber) { var groupName = DxfCodePairGroup.GetGroupName(pair.StringValue); groups.Add(DxfCodePairGroup.FromBuffer(buffer, groupName)); } else { commonValues.Add(pair); } pair = buffer.Peek(); } DxfTable result; switch (tableType) { case DxfTable.AppIdText: result = DxfAppIdTable.ReadFromBuffer(buffer); break; case DxfTable.BlockRecordText: result = DxfBlockRecordTable.ReadFromBuffer(buffer); break; case DxfTable.DimStyleText: result = DxfDimStyleTable.ReadFromBuffer(buffer); break; case DxfTable.LayerText: result = DxfLayerTable.ReadFromBuffer(buffer); break; case DxfTable.LTypeText: result = DxfLTypeTable.ReadFromBuffer(buffer); break; case DxfTable.StyleText: result = DxfStyleTable.ReadFromBuffer(buffer); break; case DxfTable.UcsText: result = DxfUcsTable.ReadFromBuffer(buffer); break; case DxfTable.ViewText: result = DxfViewTable.ReadFromBuffer(buffer); break; case DxfTable.ViewPortText: result = DxfViewPortTable.ReadFromBuffer(buffer); break; default: SwallowTable(buffer); result = null; break; } if (result != null) { // set common values foreach (var common in commonValues) { switch (common.Code) { case 5: result.Handle = DxfCommonConverters.UIntHandle(common.StringValue); break; case 70: // entry count, read dynamically break; case 330: result.OwnerHandle = DxfCommonConverters.UIntHandle(common.StringValue); break; } } foreach (var group in groups) { result.ExtensionDataGroups.Add(group); } result.AfterRead(); } return(result); }