Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a little bit of dilema here.

I have a hierachical collection of classExtensions that I very much would like to keep them as they are now:

1) Timestamper (master concrete class Extension) 1.1) BaseCadastralExtension (derives from Timestamper) 2) Derived classes (from BaseCadastralExtension)

But I want to implement custom IObjectInspectors for each of the derived classes. I can't keep them deriving from BaseCadastralExtensions, because the IObjectInspector needs to derive from UserControl (am I right?). So, I cannot do this with multiple inheritance :P

Is it possible to implement an IObjectInspector without trashing the class structure? Or do I need to rewrite? I wonder that composition in this matter (baseCadastralExtension to have a "funcionalities" member to take care of all the events, etc) and implement for each a custom IObjectInspector would do better?

I'm not sure if I'm being clear, but I would like suggestions from you expert ESRI devs.

Thanks,

George

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I really figured this one out.

What I did was to compose the class extension with a IObjectInspector. In the init method, I would create it accordingly, like this:

My methods for object inspector just call the ones in _CustomObjectInspector

public class CustomExtension:BaseExtension,IObjectInspector
{
    // COM registration, etc for brevity

    protected IObjectInspector _CustomObjectInspector;

    public override Init(IClassHelper helper,IPropertySet properties)
    {
        // init our properties
        _CustomObjectInspector = new ConcreteObjectInspector();
    }

    #region IObjectInspector Members

    public void Clear()
    {
        _CustomObjectInspector.Clear();
    }

    public void Copy(IRow srcRow)
    {
        _CustomObjectInspector.Copy(srcRow);
    }

    public int HWND
    {
        get { return _CustomObjectInspector.HWND; }
    }

    public void Inspect(IEnumRow objects, IEditor Editor)
    {
        _CustomObjectInspector.Inspect(objects, Editor);
    }

    #endregion
}

Thanks for the help :D

share|improve this answer
1  
Did you consider using containment instead of inheritance? What if the classextension contained a list of sub-extensions, then when certain events fire you would loop through the list of contained sub-extensions. I've done this with editor extensions and found it to be effective. Haven't tried with classextensions though it seems like it would work there too. –  Kirk Kuykendall Dec 8 '10 at 15:06
    
Hello Kirk, the suggestion is good. It would work! This one reached my purposes too. As the GOF says, inheritance is too restrictive, composition is always a better way! –  George Dec 8 '10 at 15:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.