///<overloads>
        /// <summmary>
        /// You can not edit a dependent block(a block that is inside from xref) from the referenced drawing.
        /// The default is not to include dependent blocks since typically you will work on blocks that are contained
        /// inside the drawing, and it saves time by not opening the DbObject and comparing
        /// BlockTableRecord.ObjectId.OriginalDatabase.UnmanagedObject to the BlockTable.Database.UnmanagedObject property.
        /// </summmary>
        /// </overloads>
        /// <summary>
        /// Gets the block table records.
        /// </summary>
        /// <param name="symbolTbl">The symbol table.</param>
        /// <param name="trx">The TRX.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="filter"><see cref="SymbolTableRecordFilter"/>.</param>
        /// <returns>IEnumerable{BlockTableRecord}</returns>

        public static IEnumerable <BlockTableRecord> GetBlockTableRecords(this BlockTable symbolTbl, Transaction trx,
                                                                          OpenMode mode = OpenMode.ForRead, SymbolTableRecordFilter filter = SymbolTableRecordFilter.None)
        {
            if (filter.IsSet(SymbolTableRecordFilter.IncludeDependent))
            {
                return(symbolTbl.GetSymbolTableRecords <BlockTableRecord>(trx, mode, filter, true));
            }
            return(symbolTbl.GetSymbolTableRecords <BlockTableRecord>(trx, mode, filter, true).NonDependent());
        }
        ///<overloads>
        /// <summmary>
        /// You can not edit a dependent block(a block that is inside from xref) from the referenced drawing. 
        /// The default is not to include dependent blocks since typically you will work on blocks that are contained 
        /// inside the drawing, and it saves time by not opening the DbObject and comparing 
        /// BlockTableRecord.ObjectId.OriginalDatabase.UnmanagedObject to the BlockTable.Database.UnmanagedObject property.
        /// </summmary>
        /// </overloads>
        /// <summary>
        /// Gets the block table records.
        /// </summary>
        /// <param name="symbolTbl">The symbol table.</param>
        /// <param name="trx">The TRX.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="filter"><see cref="SymbolTableRecordFilter"/>.</param>
        /// <returns>IEnumerable{BlockTableRecord}</returns>

        public static IEnumerable<BlockTableRecord> GetBlockTableRecords(this BlockTable symbolTbl, Transaction trx,
            OpenMode mode = OpenMode.ForRead, SymbolTableRecordFilter filter = SymbolTableRecordFilter.None)
        {
            if (filter.IsSet(SymbolTableRecordFilter.IncludeDependent))
            {
                return symbolTbl.GetSymbolTableRecords<BlockTableRecord>(trx, mode, filter, true);
            }
            return symbolTbl.GetSymbolTableRecords<BlockTableRecord>(trx, mode, filter, true).NonDependent();
        }
        /// <summary>
        /// Gets the symbol table records.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="symbolTbl">The symbol table.</param>
        /// <param name="trx">The TRX.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="filterDependecyById">if set to <c>true</c> [filter dependecy by identifier].</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        internal static IEnumerable<T> GetSymbolTableRecords<T>(this SymbolTable symbolTbl, Transaction trx,
            OpenMode mode, SymbolTableRecordFilter filter, bool filterDependecyById) where T : SymbolTableRecord
        {
            if (trx == null)
            {
                throw new Exception(ErrorStatus.NoActiveTransactions);
            }

            bool includingErased = filter.IsSet(SymbolTableRecordFilter.IncludedErased);

            if (filter.IsSet(SymbolTableRecordFilter.IncludeDependent))
            {
                foreach (ObjectId id in includingErased ? symbolTbl.IncludingErased : symbolTbl)
                {
                    yield return (T)trx.GetObject(id, mode, includingErased, false);
                }
            }
            else
            {
                if (filterDependecyById)
                {
                    IntPtr dbIntPtr = symbolTbl.Database.UnmanagedObject;
                    foreach (ObjectId id in includingErased ? symbolTbl.IncludingErased : symbolTbl)
                    {
                        if (id.OriginalDatabase.UnmanagedObject == dbIntPtr)
                        {
                            yield return (T)trx.GetObject(id, mode, includingErased, false);
                        }
                    }
                }
                else
                {
                    foreach (ObjectId id in includingErased ? symbolTbl.IncludingErased : symbolTbl)
                    {
                        T current = (T)trx.GetObject(id, mode, includingErased, false);
                        if (!current.IsDependent)
                        {
                            yield return current;
                        }
                    }
                }
            }
        }