Finally I managed to solve the problem in the following way:
Instead of the array I created a list of objects (WCF):
[DataMember]
public List<DataItem> WorkDays { get; set; }
DataItem.cs:
[DataContract]
public class DataItem
{
[DataMember]
public string Key;
[DataMember]
public CustomDay Value;
}
I sent the list like this(JS):
function CreateWorkDaysDictonary() {
var workdaysdic = new Array();
if ($('#checkbox-sunday').is(':checked')) {
var starttime = { Hour: $('#select-from-hour-sunday').val(),
Minute: $('#select-from-minute-sunday').val()
};
var endtime = { Hour: $('#select-until-hour-sunday').val(),
Minute: $('#select-until-minute-sunday').val()
};
workdaysdic.push({ Key: "Sunday", Value: { Start: starttime, End: endtime} });
}
if ($('#checkbox-monday').is(':checked')) {
var starttime = { Hour: $('#select-from-hour-monday').val(),
Minute: $('#select-from-minute-monday').val()
};
var endtime = { Hour: $('#select-until-hour-monday').val(),
Minute: $('#select-until-minute-monday').val()
};
workdaysdic.push({ Key: "Monday", Value: { Start: starttime, End: endtime} });
}
//and so on...
return workdaysdic;
}
And it works! :)
I will mention here that it works with a dictionary and I have not used it because I had to do serialization to xml file.