все.В настоящее время я пытаюсь отправить производный класс (или реализацию интерфейса) с сервера на клиент.Я не могу сделать это, потому что он не будет вызывать метод в клиенте.Я попытался извлечь наследство и отправить его, и оно работает правильно, поэтому проблема заключается в попытке отправить производный класс клиенту.Заранее спасибо
Вот классы:
Интерфейс:
public interface ISquare
{
Uri Image
{
get;
set;
}
List<Player> PlayerList
{
get;
set;
}
}
Реализации:
public class Property: ISquare
{
private Uri image { get; set; }
private List<Player> playerList { get; set; }
public int price { get; set; }
public int nHouses { get; set; }
public bool hasHotel { get; set; }
public bool isBought { get; set; }
public ColorProperty color { get; set; }
public int moneyToPay { get; set; }
public Player buyer { get; set; }
public int squarePosition { get; set; }
public Uri Image
{
get
{
return image;
}
set
{
image = value;
}
}
public List<Player> PlayerList
{
get
{
return playerList;
}
set
{
playerList = value;
}
}
public Property(int price, int nHouses, bool hasHotel, bool isBought, ColorProperty color, int moneyToPay, Player buyer, int squarePosition, Uri image, List<Player> playerList)
{
this.price = price;
this.nHouses = nHouses;
this.hasHotel = hasHotel;
this.isBought = isBought;
this.color = color;
this.dineroAPagar = moneyToPay;
this.buyer = buyer;
this.squarePosition = squarePosition;
this.image = image;
this.playerList = playerList;
}
public Property(int price, ColorPropiedad color, int squarePosition)
{
this.price = price;
this.nHouses = 0;
this.hasHotel = false;
this.isBought = false;
this.color = color;
this.dineroAPagar = 0;
this.buyer = null;
this.squarePosition = squarePosition;
this.image = image;
this.playerList = new List<Player>();
}
}
public class Square : ISquare
{
private Uri image { get; set; }
public SquareType type { get; set; }
private List<Player> playerList { get; set; }
public Uri Image
{
get
{
return image;
}
set
{
image = value;
}
}
public List<Player> playerList
{
get
{
return playerList ;
}
set
{
playerList = value;
}
}
public Square(SquareType type, List<Player> playerList)
{
this.type = type;
this.playerList = playerList;
}
public Square(SquareType type)
{
this.image = null;
this.type = type;
this.playerList= new List<Player>();
}
public Square()
{
this.image = null;
this.type = SquareType.PROPERTY;
this.playerList = new List<Player>();
}
}
Вот как выглядит клиент:
private async void joinGame(Player playerServer)
{
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
if (playerServer != null)
{
_navigationService.Navigate(
typeof(GameView),
new PlayerWithLobby()
{
player = playerServer,
lobby = _lobby
}
);
}
else
{
throw new NotImplementedException("Player is null");
}
}
);
}