Page 1 of 1

RoomSettings in the containers

Posted: 22 Mar 2014, 10:30
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);

Re: RoomSettings in the containers

Posted: 22 Mar 2014, 16:12
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>

Re: RoomSettings in the containers

Posted: 22 Mar 2014, 22:26
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

Re: RoomSettings in the containers

Posted: 23 Mar 2014, 19:24
by Lapo
Thanks