static Calendar CreateCalendar (int calendarType)
{
string name = null;
switch (calendarType >> CalendarTypeBits) {
case 1:
GregorianCalendarTypes greg_type;
greg_type = (GregorianCalendarTypes) (calendarType & 0xFF);
return new GregorianCalendar (greg_type);
case 2:
name = "System.Globalization.ThaiBuddhistCalendar";
break;
case 3:
name = "System.Globalization.UmAlQuraCalendar";
break;
case 4:
name = "System.Globalization.HijriCalendar";
break;
default:
throw new NotImplementedException ("Unknown calendar type: " + calendarType);
}
Type type = Type.GetType (name, false);
if (type == null)
return CreateCalendar (1 << CalendarTypeBits); // return invariant calandar if not found
return (Calendar) Activator.CreateInstance (type);
}