November Happy Hour will be moved to Thursday December 5th.

Class Converter

Helper functions for common converter scenarios

Inheritance
System.Object
Converter
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 9.12.2
Syntax
public class Converter

Constructors

Converter()

Declaration
public Converter()

Methods

ToIntZero(Object)

Returns 0 if parameter is anything else than of type System.Int32, also supports converting of False to 0 and True to 1.

Declaration
public static int ToIntZero(object val)
Parameters
Type Name Description
System.Object val
Returns
Type Description
System.Int32

ToScriptSafeIdentifier(String)

Make string safe to be used as a identifier in a script block, by replacing any characters that would invalidate the script with script-safe characters.

Declaration
[Obsolete("Use ClientScriptUtility.ToScriptSafeIdentifier")]
public static string ToScriptSafeIdentifier(string s)
Parameters
Type Name Description
System.String s

String that needs to be script-safe

Returns
Type Description
System.String

Script-safe identifier

ToScriptSafeString(String)

Make a string safe to be embedded into a script block, by replacing any characters that would invalidate the script with script-safe characters.

Declaration
[Obsolete("Use ClientScriptUtility.ToScriptSafeString")]
public static string ToScriptSafeString(string s)
Parameters
Type Name Description
System.String s

Text that needs to be script-safe

Returns
Type Description
System.String

Script-safe text

ToStringEmpty(Object)

Returns String.Empty if parameter is anything else than of type System.String.

Declaration
public static string ToStringEmpty(object val)
Parameters
Type Name Description
System.Object val
Returns
Type Description
System.String

ToStringNull(Object)

Tries to cast to a string.

Declaration
public static string ToStringNull(object val)
Parameters
Type Name Description
System.Object val

The object to cast.

Returns
Type Description
System.String

val cast to a string if it is a string, otherwise null.

ToSystemNull(Object)

Converts from System.DBNull to null.

Declaration
public static object ToSystemNull(object val)
Parameters
Type Name Description
System.Object val

The object to convert.

Returns
Type Description
System.Object

null if val is System.DBNull, otherwise val unchanged.

Extension Methods