jeudi 18 juin 2015

What kind of pattern has a class that contains an instance of itself cast to the interface?

I have recently inherited some code, and I can't figure out the reasoning behind the architecture of one of the classes. The class looks something like this:

[Serializable]
internal class MyClass : MyInterface
{
    private DbModel dataModel { get; set; }
    private MyInterface IThis { get { return (MyInterface)this; } }

    public string SomeProperty { get { return IThis.SomeProperty } }
    ...
    string MyInterface.SomeProperty { get { return dataModel.GetSomeProperty(); } }
}

Is this some sort of common (or uncommon) design pattern that I've just never seen? Why would we want to access the properties this way? What benefit do we get from this? Notice that the IThis is not static, so it isn't some sort of Singleton pattern.

Aucun commentaire:

Enregistrer un commentaire