简体   繁体   中英

Marshall By Reference Inherit from class

I've got a problem with multiple inheritance and MarshallByRefObj

The problem i have is that I need to inherit from an abstract class AND MarshallByRefObj

The abstract class (stripped down) :

public abstract class Drawable : IDrawable
{
    //... Several unimportant methods...
    public IEnumerable<ICard> Shuffle (IEnumerable<ICard>)
    {
        //...shuffle the cards here...
    }
}

The class I'm trying to make, which needs to be accessed by reference through wcf Stripped down, obviously...:

public class Deck : Drawable, MarshallByRefObject
{
    //... public stuff that implements a deck to include 
    // search/draw/discard functions...
}

Try deriving from MarshalByRefObject, and implementing the interface of the other class. Then, define a member of that class' type and make your interface just proxy calls to it. It's a pain, but it's straightforward.

public class Deck : MarshalByRefObject, IDrawable
{
    Drawable _drawable = new Drawable(...);

    // Implement IDrawable
    void IDrawable.Foo() { _drawable.Foo(); }
    void IDrawable.Bar() { _drawable.Bar(); }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM