protected void readMapped <T>(CadObject cadObject, CadTemplate template) where T : CadObject { DxfClassMap map = DxfClassMap.Create <T>(); Debug.Assert(map.Name == this._reader.LastValueAsString); this._reader.ReadNext(); while (this._reader.LastDxfCode != DxfCode.Start && this._reader.LastDxfCode != DxfCode.Subclass) { //Check for an extended data code if (this._reader.LastDxfCode >= DxfCode.ExtendedDataAsciiString) { this.readExtendedData(cadObject); this._reader.ReadNext(); continue; } else if (this._reader.LastDxfCode == DxfCode.ControlString) { if (!template.CheckDxfCode(this._reader.LastCode, this._reader.LastValue)) { this.readDefinedGroups(template); } else { this._reader.ReadNext(); } continue; } if (!map.DxfProperties.TryGetValue(this._reader.LastCode, out DxfProperty dxfProperty)) { if (!template.CheckDxfCode(this._reader.LastCode, this._reader.LastValue)) { this._notification?.Invoke(null, new NotificationEventArgs($"Dxf code {this._reader.LastCode} not found in map for {typeof(T)} | value : {this._reader.LastValueAsString}")); } this._reader.ReadNext(); continue; } if (dxfProperty.ReferenceType == DxfReferenceType.Handle) { if (!template.AddHandle(this._reader.LastCode, this._reader.LastValueAsHandle)) { this._notification?.Invoke(null, new NotificationEventArgs($"Dxf referenced code {this._reader.LastCode} not implemented in the {template.GetType().Name} for {typeof(T)} | value : {this._reader.LastValueAsHandle}")); } } else if (dxfProperty.ReferenceType == DxfReferenceType.Name) { if (!template.AddName(this._reader.LastCode, this._reader.LastValueAsString)) { this._notification?.Invoke(null, new NotificationEventArgs($"Dxf named referenced code {this._reader.LastCode} not implemented in the {template.GetType().Name} for {typeof(T)} | value : {this._reader.LastValueAsHandle}")); } } else if (dxfProperty.ReferenceType == DxfReferenceType.Count) { //Do nothing just marks the amount } else { switch (this._reader.LastGroupCodeValue) { case GroupCodeValueType.String: case GroupCodeValueType.Point3D: case GroupCodeValueType.Double: case GroupCodeValueType.Int16: case GroupCodeValueType.Int32: case GroupCodeValueType.Int64: case GroupCodeValueType.Chunk: case GroupCodeValueType.Bool: dxfProperty.SetValue(cadObject, this._reader.LastValue); break; case GroupCodeValueType.Comment: this._notification?.Invoke(null, new NotificationEventArgs($"Comment in the file : {this._reader.LastValueAsString}")); break; case GroupCodeValueType.Handle: case GroupCodeValueType.ObjectId: case GroupCodeValueType.None: default: this._notification?.Invoke(null, new NotificationEventArgs($"Group Code not handled {this._reader.LastGroupCodeValue} for {typeof(T)}, code : {this._reader.LastCode} | value : {this._reader.LastValueAsString}")); break; } } this._reader.ReadNext(); } }
private void assignOwners(CadTemplate template) { if (template.CadObject.Owner != null || template.CadObject is CadDictionary) { return; } if (this.TryGetCadObject(template.OwnerHandle, out CadObject owner)) { switch (owner) { case CadDictionary: //Entries of the dictionary are assigned in the template break; case BlockRecord record when template.CadObject is Entity entity: record.Entities.Add(entity); break; case Polyline pline when template.CadObject is Vertex v: pline.Vertices.Add(v); break; case Insert insert when template.CadObject is AttributeEntity att: insert.Attributes.Add(att); break; default: this.NotificationHandler?.Invoke(null, new NotificationEventArgs($"Owner {owner.GetType().Name} with handle {owner.Handle} assignation not implemented for {template.CadObject.GetType().Name} with handle {template.CadObject.Handle}")); break; } } else { this.NotificationHandler?.Invoke(null, new NotificationEventArgs($"Owner {template.OwnerHandle} not found for {template.GetType().FullName} with handle {template.CadObject.Handle}")); } }