public ObservableCollection <Tag> GetTags()
        {
            var tags = new ObservableCollection <Tag>();

            BCOM.ElementScanCriteria sc = (BCOM.ElementScanCriteria)_application.CreateObjectInMicroStation("MicroStationDGN.ElementScanCriteria");
            sc.ExcludeAllTypes();
            sc.IncludeType(BCOM.MsdElementType.msdElementTypeTag);

            BCOM.ElementEnumerator ee = _application.ActiveModelReference.Scan(sc);
            Array elements            = ee.BuildArrayFromContents();

            foreach (BCOM.Element element in elements)
            {
                BCOM.TagElement te = element as BCOM.TagElement;

                var tag = new Tag()
                {
                    TagSetName        = te.TagSetName,
                    TagDefinitionName = te.TagDefinitionName,
                    Value             = te.Value,
                    ID     = ToInt64(te.ID),
                    HostID = ToInt64(te.BaseElement != null ? te.BaseElement.ID : new BCOM.DLong())
                };
                tags.Add(tag);
            }

            ComUtilities.ReleaseComObject(sc);
            sc = null;

            return(tags);
        }
        public ObservableCollection <Text> GetTexts()
        {
            var texts = new ObservableCollection <Text>();

            BCOM.ElementScanCriteria sc = (BCOM.ElementScanCriteria)_application.CreateObjectInMicroStation("MicroStationDGN.ElementScanCriteria");
            sc.ExcludeAllTypes();
            sc.IncludeType(BCOM.MsdElementType.msdElementTypeText);
            sc.IncludeType(BCOM.MsdElementType.msdElementTypeTextNode);

            BCOM.ElementEnumerator ee = _application.ActiveModelReference.Scan(sc);
            Array elements            = ee.BuildArrayFromContents();

            foreach (BCOM.Element element in elements)
            {
                if (element is BCOM.TextElement)
                {
                    BCOM.TextElement te = element as BCOM.TextElement;

                    var text = new Text()
                    {
                        Value = te.Text,
                        ID    = ToInt64(te.ID),
                    };
                    texts.Add(text);
                }
                else if (element is BCOM.TextNodeElement)
                {
                    BCOM.TextNodeElement   tn = element as BCOM.TextNodeElement;
                    BCOM.ElementEnumerator en = tn.GetSubElements();
                    while (en.MoveNext())
                    {
                        BCOM.TextElement te = en.Current.AsTextElement;
                        var text            = new Text()
                        {
                            Value = te.Text,
                            ID    = ToInt64(te.ID),
                        };
                        texts.Add(text);
                    }
                }
            }

            ComUtilities.ReleaseComObject(sc);
            sc = null;

            return(texts);
        }