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

Class DataSourceHelper

Utility for implementing Data Source Controls.

Inheritance
System.Object
DataSourceHelper
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.Web.WebControls
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
public static class DataSourceHelper

Fields

TAB

Tab column name

Declaration
public static readonly string TAB
Field Value
Type Description
System.String

TYPE

Type column name

Declaration
public static readonly string TYPE
Field Value
Type Description
System.String

Methods

ConvertToBool(Object)

Converts object to bool.

Declaration
public static bool ConvertToBool(object value)
Parameters
Type Name Description
System.Object value

The value.

Returns
Type Description
System.Boolean
Exceptions
Type Condition
System.ArgumentException

If conversion fails

ConvertToContentReference(Object)

Converts object to content reference.

Declaration
public static ContentReference ConvertToContentReference(object o)
Parameters
Type Name Description
System.Object o

The o.

Returns
Type Description
ContentReference
Exceptions
Type Condition
System.ArgumentException

If conversion fails

ConvertToEnum(Object, Type)

Converts object to enum.

Declaration
public static Enum ConvertToEnum(object o, Type type)
Parameters
Type Name Description
System.Object o

The o.

System.Type type

The type.

Returns
Type Description
System.Enum
Exceptions
Type Condition
System.ArgumentException

If conversion fails

ConvertToGuid(Object)

Converts object to GUID.

Declaration
public static Guid ConvertToGuid(object o)
Parameters
Type Name Description
System.Object o

The o.

Returns
Type Description
System.Guid
Exceptions
Type Condition
System.ArgumentException

If conversion fails

ConvertToInt(Object)

Converts to int.

Declaration
public static int ConvertToInt(object value)
Parameters
Type Name Description
System.Object value

The value.

Returns
Type Description
System.Int32
Exceptions
Type Condition
System.ArgumentException

If conversion fails

ConvertToPageReference(Object)

Converts object to page reference.

Declaration
public static PageReference ConvertToPageReference(object o)
Parameters
Type Name Description
System.Object o

The o.

Returns
Type Description
PageReference
Exceptions
Type Condition
System.ArgumentException

If conversion fails

ConvertToType(Object)

Converts objetc to Type.

Declaration
public static Type ConvertToType(object o)
Parameters
Type Name Description
System.Object o

The o.

Returns
Type Description
System.Type
Exceptions
Type Condition
System.ArgumentException

If conversion fails

GetAccessor(Type, String)

Gets the AccessorInfo for the property with name propertyName for type

Declaration
public static AccessorInfo GetAccessor(Type type, string propertyName)
Parameters
Type Name Description
System.Type type

The type.

System.String propertyName

Name of the property.

Returns
Type Description
AccessorInfo

AccessorInfo.Empty if type doesn't have given property

GetAccessors(Type)

Gets all property accessors for a type

Declaration
public static Dictionary<string, AccessorInfo> GetAccessors(Type type)
Parameters
Type Name Description
System.Type type

The type.

Returns
Type Description
System.Collections.Generic.Dictionary<System.String, AccessorInfo>

GetProperty(Object, String)

Gets a property value for an object

Declaration
public static object GetProperty(object target, string propertyName)
Parameters
Type Name Description
System.Object target

The target.

System.String propertyName

Name of the property.

Returns
Type Description
System.Object

property value

LoadPageDefinitionType(IDictionary)

Method to assure that if Type or PageDefinitionTypeId is present in dictionary then try assure Type is of type PageDefinitionType.

Declaration
public static void LoadPageDefinitionType(IDictionary values)
Parameters
Type Name Description
System.Collections.IDictionary values

LoadTabDefinition(IDictionary)

Method to assure that if Tab or TabDefinitionId is present in dictionary then try assure Tab is of type TabDefinition.

Declaration
public static void LoadTabDefinition(IDictionary values)
Parameters
Type Name Description
System.Collections.IDictionary values

Match(Object, IOrderedDictionary)

Checks wether some property in parameters differs from properties on item

Declaration
public static bool Match(object item, IOrderedDictionary parameters)
Parameters
Type Name Description
System.Object item

The item.

System.Collections.Specialized.IOrderedDictionary parameters

The parameters.

Returns
Type Description
System.Boolean

true if all property values on item matches values in parameters, else false

MergeDictionaries(IDictionary, IDictionary)

Merges two dictionaries.

Declaration
public static void MergeDictionaries(IDictionary source, IDictionary destination)
Parameters
Type Name Description
System.Collections.IDictionary source

The source.

System.Collections.IDictionary destination

The destination.

SetProperties(IDictionary, Object)

Sets properties on an object

Declaration
public static void SetProperties(IDictionary values, object target)
Parameters
Type Name Description
System.Collections.IDictionary values

The values.

System.Object target

The target.

Remarks

Throws exception if property doesnot exist on object

SetProperties(IDictionary, Object, Boolean)

Sets properties on an object

Declaration
public static void SetProperties(IDictionary values, object target, bool throwOnPropertyNotFound)
Parameters
Type Name Description
System.Collections.IDictionary values

The values.

System.Object target

The target.

System.Boolean throwOnPropertyNotFound

if set to true [throw on property not found].

SetProperty(Object, String, Object)

Sets a property on an object

Declaration
public static void SetProperty(object target, string propertyName, object value)
Parameters
Type Name Description
System.Object target

The target object

System.String propertyName

Name of the property.

System.Object value

The value.

Remarks

throws exception if property does not exist

SetProperty(Object, String, Object, Boolean)

Sets a property on an object

Declaration
public static void SetProperty(object target, string propertyName, object value, bool throwOnPropertyNotFound)
Parameters
Type Name Description
System.Object target

The target.

System.String propertyName

Name of the property.

System.Object value

The value.

System.Boolean throwOnPropertyNotFound

if set to true [throw on property not found].

TryConvertInt(Object, out Int32)

Tries to convert object to int

Declaration
public static bool TryConvertInt(object value, out int id)
Parameters
Type Name Description
System.Object value

The value.

System.Int32 id

The id.

Returns
Type Description
System.Boolean

true if conversion succeeds else false