RoomSettings in the containers

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Post Reply
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

RoomSettings in the containers

Post by braza »

Hi,

I`ve stumbled upon the piece of code that I immediately stealed for my project:

http://docs2x.smartfoxserver.com/api-do ... Index.html

But there`s an issue with

Code: Select all

    List<SFSRoomVariable> roomVars = new List<SFSRoomVariable>();
    roomVars.Add(new SFSRoomVariable("desc", "Darts game, public, bestScore > 100"));
    settings.variables = roomVars;
Compiler can`t process the last assignemnt because it cant cast from List<SFSRoomvariable> to List<RoomVariable>.

This article explains why it might be a bad idea http://stackoverflow.com/questions/1817 ... tbaseclass

Could please anybody cooment if I`m Ok to use

Code: Select all

settings.Variables = roomVars.ConvertAll(x => (RoomVariable)x);
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomSettings in the containers

Post by Lapo »

The link doesn't point to the example but you can use this instead:

Code: Select all

List<RoomVariable> roomVars = new List<RoomVariable>();
SFSRoomVariable is subclass of RoomVariable, so you can add SFSRoomVariables to a List<RoomVariable>
Lapo
--
gotoAndPlay()
...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: RoomSettings in the containers

Post by braza »

Lapo wrote:The link doesn't point to the example but you can use this instead:

Code: Select all

List<RoomVariable> roomVars = new List<RoomVariable>();
SFSRoomVariable is subclass of RoomVariable, so you can add SFSRoomVariables to a List<RoomVariable>
Yes, that`s right, thanks! If you`re interested in the correct link: http://docs2x.smartfoxserver.com/api-do ... 27a5b9.htm
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomSettings in the containers

Post by Lapo »

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply