用 kentico 9 API 替换 'GetTimeZoneTypeEnum' class
Replacing 'GetTimeZoneTypeEnum' class with kentico 9 API
我将我的 kentico 项目从 8.2 升级到 9。
在版本 9 'GetTimeZoneTypeEnum' class 中被删除,但在我的项目中它在某些地方使用。我如何用版本 9 API 替换它?
我提到了 kentico 9 API,他们说使用 'EnumStringRepresentationExtensions' class。我尝试使用它,但它不起作用。
我的代码片段是:
if (GetValue("timezonetype") != null)
{
timePicker.TimeZone = TimeZoneInfoProvider.**GetTimeZoneTypeEnum**(ValidationHelper.GetString(GetValue("timezonetype"), ""));
}
在 GetTimeZoneTypeEnum 处出现错误。谁能提供更多细节来解决这个问题?
您需要替换此函数并使用 EnumStrinRepresentaionExtensions。
从 属性 时区类型
获取枚举值
if (GetValue("timezonetype") != null)
{
timePicker.TimeZone = EnumStringRepresentationExtensions.ToEnum<CMS.Globalization.TimeZoneTypeEnum>(ValidationHelper.GetString(GetValue("timezonetype"), ""));
}
设置属性:
SetValue("timezonetype",EnumStringRepresentationExtensions.ToStringRepresentation<CMS.Globalization.TimeZoneTypeEnum>(value))
值的类型应为 CMS.Globalization.TimeZoneTypeEnum
该方法已删除。您需要使用 TimeZoneTypeEnum 本身:
Inherit 0 Indicates whether time zone type is inherited.
Server 1 Server timezone type.
WebSite 2 WebSite timezone type.
User 3 User timezone type.
Custom 4 Custom timezone type.
如果您有一些字符串格式的时区,请将它们转换为上面的枚举或索引(switch-case,第二列)。
我将我的 kentico 项目从 8.2 升级到 9。 在版本 9 'GetTimeZoneTypeEnum' class 中被删除,但在我的项目中它在某些地方使用。我如何用版本 9 API 替换它? 我提到了 kentico 9 API,他们说使用 'EnumStringRepresentationExtensions' class。我尝试使用它,但它不起作用。
我的代码片段是:
if (GetValue("timezonetype") != null)
{
timePicker.TimeZone = TimeZoneInfoProvider.**GetTimeZoneTypeEnum**(ValidationHelper.GetString(GetValue("timezonetype"), ""));
}
在 GetTimeZoneTypeEnum 处出现错误。谁能提供更多细节来解决这个问题?
您需要替换此函数并使用 EnumStrinRepresentaionExtensions。
从 属性 时区类型
获取枚举值if (GetValue("timezonetype") != null)
{
timePicker.TimeZone = EnumStringRepresentationExtensions.ToEnum<CMS.Globalization.TimeZoneTypeEnum>(ValidationHelper.GetString(GetValue("timezonetype"), ""));
}
设置属性:
SetValue("timezonetype",EnumStringRepresentationExtensions.ToStringRepresentation<CMS.Globalization.TimeZoneTypeEnum>(value))
值的类型应为 CMS.Globalization.TimeZoneTypeEnum
该方法已删除。您需要使用 TimeZoneTypeEnum 本身:
Inherit 0 Indicates whether time zone type is inherited.
Server 1 Server timezone type.
WebSite 2 WebSite timezone type.
User 3 User timezone type.
Custom 4 Custom timezone type.
如果您有一些字符串格式的时区,请将它们转换为上面的枚举或索引(switch-case,第二列)。