CollectEvent(object sender, CollectorEventArgs e) { // cast the sender object to the SnoopCollector we are expecting Collector snoopCollector = sender as Collector; if (snoopCollector == null) { Debug.Assert(false); // why did someone else send us the message? return; } // branch to all types we are concerned with AcDb.SymbolTableRecord tblRec = e.ObjToSnoop as AcDb.SymbolTableRecord; if (tblRec != null) { Stream(snoopCollector.Data(), tblRec); return; } AcDb.SymbolTable symTbl = e.ObjToSnoop as AcDb.SymbolTable; // need to use namespace or it thinks we are referring to this class "SymbolTable" instead! if (symTbl != null) { Stream(snoopCollector.Data(), symTbl); return; } }
Stream(ArrayList data, AcDb.SymbolTableRecord tblRec) { data.Add(new Snoop.Data.ClassSeparator(typeof(AcDb.SymbolTableRecord))); data.Add(new Snoop.Data.String("Name", tblRec.Name)); data.Add(new Snoop.Data.Bool("Is dependent", tblRec.IsDependent)); data.Add(new Snoop.Data.Bool("Is resolved", tblRec.IsResolved)); // branch to all known major sub-classes AbstractViewTableRecord viewRec = tblRec as AbstractViewTableRecord; if (viewRec != null) { Stream(data, viewRec); return; } BlockTableRecord blkRec = tblRec as BlockTableRecord; if (blkRec != null) { Stream(data, blkRec); return; } DimStyleTableRecord dimRec = tblRec as DimStyleTableRecord; if (dimRec != null) { Stream(data, dimRec); return; } LayerTableRecord layRec = tblRec as LayerTableRecord; if (layRec != null) { Stream(data, layRec); return; } LinetypeTableRecord ltypeRec = tblRec as LinetypeTableRecord; if (ltypeRec != null) { Stream(data, ltypeRec); return; } TextStyleTableRecord textRec = tblRec as TextStyleTableRecord; if (textRec != null) { Stream(data, textRec); return; } UcsTableRecord ucsRec = tblRec as UcsTableRecord; if (ucsRec != null) { Stream(data, ucsRec); return; } }