internal static DxfFile LoadFromReader(IDxfCodePairReader reader) { var file = new DxfFile(); file.Clear(); var buffer = new DxfCodePairBufferReader(reader); var version = DxfAcadVersion.R14; while (buffer.ItemsRemain) { var pair = buffer.Peek(); if (DxfCodePair.IsSectionStart(pair)) { buffer.Advance(); // swallow (0, SECTION) pair var section = DxfSection.FromBuffer(buffer, file, version); if (section != null) { switch (section.Type) { case DxfSectionType.Blocks: file.BlocksSection = (DxfBlocksSection)section; break; case DxfSectionType.Entities: file.EntitiesSection = (DxfEntitiesSection)section; break; case DxfSectionType.Classes: file.ClassSection = (DxfClassesSection)section; break; case DxfSectionType.Header: file.HeaderSection = (DxfHeaderSection)section; version = file.Header.Version; break; case DxfSectionType.Objects: file.ObjectsSection = (DxfObjectsSection)section; break; case DxfSectionType.Tables: file.TablesSection = (DxfTablesSection)section; break; case DxfSectionType.Thumbnail: file.ThumbnailImageSection = (DxfThumbnailImageSection)section; break; } } } else if (DxfCodePair.IsEof(pair)) { // swallow and quit buffer.Advance(); break; } else if (DxfCodePair.IsComment(pair)) { // swallow comments buffer.Advance(); } else { // swallow unexpected code pair buffer.Advance(); } } Debug.Assert(!buffer.ItemsRemain); DxfPointer.BindPointers(file); return(file); }
/*public void Load(string filename) * { * ISubject<string> lines = new ReplaySubject<string>(); * LineReader.Filename = filename; * LineReader.Output.Subscribe(lines); * * }*/ private void ReadDxf() { var section = DxfSection; #region Read Header if (section == DxfSection.Header) { LoadSection <DxfHeaderTypeAttribute>(Lines, DxfHeaderCode.HeaderSection, () => _headerLoaded = DxfSection.Header); } #endregion #region Read CLASSES if (section == DxfSection.Classes) { LoadSection <DxfClassTypeAttribute>(Lines, DxfClasseCode.ClasseSection, () => _classesLoaded = DxfSection.Classes); } #endregion #region Read TABLES if (section == DxfSection.Tables) { LoadSection <DxfTableTypeAttribute>(Lines, DxfTableCode.TableSection, () => _tablesLoaded = DxfSection.Tables); } #endregion #region Read BLOCKS if (section == DxfSection.Blocks) { LoadSection <DxfBlockTypeAttribute>(Lines, DxfBlockCode.BlockSection, () => _blocksLoaded = DxfSection.Blocks); } #endregion #region Read OBJECTS if (section == DxfSection.Objects) { LoadSection <DxfObjectTypeAttribute>(Lines, DxfObjectCode.ObjectsSection, () => _objectsLoaded = DxfSection.Objects); } #endregion #region Read ENTITIES if (section == DxfSection.Entities) { LoadSection <DxfEntityTypeAttribute>(Lines, DxfEntityCode.EntitiesSection, () => _entitiesLoaded = DxfSection.Entities); } #endregion if (section == DxfSection.Thumbnails) #region Read THUMNAILIMAGE { LoadSection <DxfThumbnailTypeAttribute>(Lines, DxfThumbnailCode.ThumbnailImageSection, () => _thumbnailLoaded = DxfSection.Thumbnails); } #endregion }