Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: ModelReference & Attachment base class for polymorphism

$
0
0
using Bentley.Interop.MicroStationDGN;
using Bentley.MicroStation.InteropServices;
using BNS = Bentley.Interop.MicroStationDGN;

namespace Scanners
{
    public class Scannable : IScanMe
    {
        protected ModelReference ModelReference;
        protected Attachment Attachment;
        public Scannable(ModelReference scannableObject)
        {
            this.ModelReference = scannableObject;
        }
        public Scannable(Attachment scannableObject)
        {
            this.Attachment = scannableObject;
        }

        public ElementEnumerator Scan()
        {
            ElementEnumerator eE = null;
            if (this.ModelReference != null)
            {
                eE = this.ModelReference.Scan();
            }
            if (this.Attachment != null)
            {
                eE = this.Attachment.Scan();
            }
            return eE;
        }
    }
}


namespace Scanners
{
    public interface IScanMe
    {
        ElementEnumerator Scan();
    }
}

This works, but it is exactly what I'm trying to avoid.  If anyone has a better solution, I would appreciate it.  I tried to get reflection/dynamic working to no avail.  I think reflection requires loading in the assemblies, which is undesirable.


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>