Search code examples
c#calendarkentico

Replacing 'GetTimeZoneTypeEnum' class with kentico 9 API


I upgraded my kentico project from 8.2 to 9. In version 9 'GetTimeZoneTypeEnum' class is removed but in my project it is used at some places. How Can I replace that with version 9 API. I referred kentico 9 API, they said to use 'EnumStringRepresentationExtensions' class. I tried to work with that but that isn't working.

My code snippet is:

if (GetValue("timezonetype") != null)            
{
  timePicker.TimeZone = TimeZoneInfoProvider.**GetTimeZoneTypeEnum**(ValidationHelper.GetString(GetValue("timezonetype"), ""));
}

Getting error at GetTimeZoneTypeEnum. Can anyone give some more details to resolve this?


Solution

  • You need to replace this function and use the EnumStrinRepresentaionExtensions.

    To get the enum value from the property timezonetype

    if (GetValue("timezonetype") != null)
    {
           timePicker.TimeZone = EnumStringRepresentationExtensions.ToEnum<CMS.Globalization.TimeZoneTypeEnum>(ValidationHelper.GetString(GetValue("timezonetype"), ""));
    }
    

    to set the property:

    SetValue("timezonetype",EnumStringRepresentationExtensions.ToStringRepresentation<CMS.Globalization.TimeZoneTypeEnum>(value))
    

    value should be of type CMS.Globalization.TimeZoneTypeEnum