简体   繁体   English

Marshall By Reference从类继承

[英]Marshall By Reference Inherit from class

I've got a problem with multiple inheritance and MarshallByRefObj 我有多重继承和MarshallByRefObj的问题

The problem i have is that I need to inherit from an abstract class AND MarshallByRefObj 我遇到的问题是我需要从一个抽象类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...: 我正在尝试制作的类,需要通过wcf参考访问被剥离,显然......:

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. 尝试从MarshalByRefObject派生,并实现其他类的接口。 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(); }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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