RoomSettings in the containers

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

Moderators: Lapo, Bax

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

RoomSettings in the containers

Postby braza » 22 Mar 2014, 10:30

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: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomSettings in the containers

Postby Lapo » 22 Mar 2014, 16:12

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

Postby braza » 22 Mar 2014, 22:26

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: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomSettings in the containers

Postby Lapo » 23 Mar 2014, 19:24

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 60 guests