C# Class Nettiers.AdventureWorks.Entities.EntityUtil

Provides common utility methods for interacting with objects.
ファイルを表示 Open project: netTiers/netTiers Class Usage Examples

Public Methods

Method Description
Add ( IList list, Object item ) : void

Adds the specified object to the collection of objects.

ChangeGenericType ( Object value, Type conversionType ) : Object

Converts the specified value to the specified generic type.

ChangeGenericType ( Object value, Type conversionType, bool convertBlankToNull ) : Object

Converts the specified value to the specified generic type.

ChangeType ( Object value, Type conversionType ) : Object

Converts the specified value to the specified type.

ChangeType ( Object value, Type conversionType, bool convertBlankToNull ) : Object

Converts the specified value to the specified type.

GetConstructor ( Type type ) : ConstructorInfo

Gets the default constructor for the specified type.

GetConstructor ( Type type, Type types ) : ConstructorInfo

Gets the constructor for the specified type whose parameters match the supplied type array.

GetEntity ( IEnumerable entityList, int index ) : Object

Gets the item within entityList at the position specified by index.

GetEntity ( IList entities, String propertyName, Object propertyValue ) : Object

Gets the item within entityList whose property value matches the specifed value.

GetEntityList ( Object entityList ) : IList

Converts the specified object into a collection of objects.

GetEntityList ( Object entity, String propertyName ) : IList

Gets the value of the property with the specified name and returns it as a collection of objects.

GetMethod ( Object item, String methodName ) : MethodInfo

Gets a MethodInfo object representing the method belonging to the object having the specified name.

GetMethod ( Type type, String methodName ) : MethodInfo

Gets a MethodInfo object representing the method belonging to the runtime type having the specified name.

GetNewEntity ( Type type ) : Object

Creates a new instance of the specified type.

GetNewGenericEntity ( Type genericType ) : Object

Creates a new instance of the specified generic type.

GetNewGenericEntity ( Type typeDefinition, Type typeArguments ) : Object

Creates a new instance of the specified generic type.

GetProperty ( Object item, String propertyName ) : PropertyInfo

Gets a PropertyInfo object representing the property belonging to the object having the specified name.

GetProperty ( Type type, String propertyName ) : PropertyInfo

Gets a PropertyInfo object representing the property belonging to the runtime type having the specified name.

GetPropertyValue ( Object item, String propertyName ) : Object

Gets the value of the property with the specified name.

GetPropertyValue ( Object item, String propertyName, PropertyInfo &property ) : Object

Gets the value of the property with the specified name.

GetStaticPropertyValue ( Type type, String propertyName ) : Object

Gets the value of the static property with the specified name.

GetStaticPropertyValue ( Type type, String propertyName, PropertyInfo &property ) : Object

Gets the value of the static property with the specified name.

GetType ( String typeName ) : Type

Gets the System.Type with the specified name.

GetTypeNames ( ) : string

Outputs a string containing the type names, delimited by ", "

GetTypes ( ) : System.Type[]

Gets an array of System.Type objects which match the specified objects. NOTE: this method will throw an exception if any of the values held within the args array are null.

GuidTryParse ( string s, System.Guid &result ) : bool

Converts the string representation of a Guid to its Guid equivalent. A return value indicates whether the operation succeeded.

HasEntities ( IList entities ) : bool

Gets a value indicating whether the specified list contains any items.

InitEntityDateTimeValues ( Object entity ) : void

Initializes the properties specified in propertyNames with the value of DateTime.Now for the specified entity.

InvokeMethod ( Object entity, String methodName ) : Object

Invokes the specified method on the object using reflection.

InvokeMethod ( Object entity, String methodName, Object args ) : Object

Invokes the specified method on the object using reflection. Passes the supplied arguments as method parameters.

InvokeMethod ( Object entity, String methodName, Object args, Type types ) : Object

Invokes the specified method on the object using reflection. Passes the supplied arguments as method parameters.

IsPropertyValueEqual ( Object item, String propertyName, Object propertyValue ) : bool

Determines if the property with the specified name equals the specified value.

MakeGenericType ( Type typeDefinition, Type typeArguments ) : Type

Creates a reference to a generic type using the specified type definition and the supplied type arguments.

Remove ( IList list, Object item ) : void

Removes the specified object from the collection of objects.

SetEntityKeyValue ( Object entity, String entityKeyName ) : System.Guid

Sets the value of the property with the specified name to the value returned by the Guid.NewGuid() method.

SetEntityValues ( Object entity, IDictionary values ) : void

Sets the properties of the specified entity based on the name/value pairs found in the specified collection.

SetPropertyValue ( Object item, String propertyName, Object propertyValue ) : void

Sets the value of the property with the specified name.

SetPropertyValue ( Object item, String propertyName, Object propertyValue, PropertyInfo &property ) : void

Sets the value of the property with the specified name.

SetPropertyValue ( Object item, String propertyName, Object propertyValue, PropertyInfo &property, bool convertBlankToNull ) : void

Sets the value of the property with the specified name.

SetPropertyValue ( Object item, String propertyName, Object propertyValue, bool convertBlankToNull ) : void

Sets the value of the property with the specified name.

Method Details

Add() public static method

Adds the specified object to the collection of objects.
public static Add ( IList list, Object item ) : void
list IList A collection of objects.
item Object The obejct to add.
return void

ChangeGenericType() public static method

Converts the specified value to the specified generic type.
public static ChangeGenericType ( Object value, Type conversionType ) : Object
value Object The value to convert.
conversionType System.Type A System.Type to convert to.
return Object

ChangeGenericType() public static method

Converts the specified value to the specified generic type.
public static ChangeGenericType ( Object value, Type conversionType, bool convertBlankToNull ) : Object
value Object The value to convert.
conversionType System.Type A System.Type to convert to.
convertBlankToNull bool A value indicating whether to treat /// empty string objects as null values.
return Object

ChangeType() public static method

Converts the specified value to the specified type.
public static ChangeType ( Object value, Type conversionType ) : Object
value Object The value to convert.
conversionType System.Type A System.Type to convert to.
return Object

ChangeType() public static method

Converts the specified value to the specified type.
public static ChangeType ( Object value, Type conversionType, bool convertBlankToNull ) : Object
value Object The value to convert.
conversionType System.Type A System.Type to convert to.
convertBlankToNull bool A value indicating whether to treat /// empty string objects as null values.
return Object

GetConstructor() public static method

Gets the default constructor for the specified type.
public static GetConstructor ( Type type ) : ConstructorInfo
type System.Type The runtime type.
return System.Reflection.ConstructorInfo

GetConstructor() public static method

Gets the constructor for the specified type whose parameters match the supplied type array.
public static GetConstructor ( Type type, Type types ) : ConstructorInfo
type System.Type The runtime type.
types System.Type An array of constructor parameter types.
return System.Reflection.ConstructorInfo

GetEntity() public static method

Gets the item within entityList at the position specified by index.
public static GetEntity ( IEnumerable entityList, int index ) : Object
entityList IEnumerable The collection of business objects.
index int The position within entityList that contains the current item.
return Object

GetEntity() public static method

Gets the item within entityList whose property value matches the specifed value.
public static GetEntity ( IList entities, String propertyName, Object propertyValue ) : Object
entities IList A collection of objects.
propertyName String The property name.
propertyValue Object The property value.
return Object

GetEntityList() public static method

Converts the specified object into a collection of objects.
public static GetEntityList ( Object entityList ) : IList
entityList Object An object instance.
return IList

GetEntityList() public static method

Gets the value of the property with the specified name and returns it as a collection of objects.
public static GetEntityList ( Object entity, String propertyName ) : IList
entity Object An object instance.
propertyName String The property name.
return IList

GetMethod() public static method

Gets a MethodInfo object representing the method belonging to the object having the specified name.
public static GetMethod ( Object item, String methodName ) : MethodInfo
item Object An object instance.
methodName String The method name.
return System.Reflection.MethodInfo

GetMethod() public static method

Gets a MethodInfo object representing the method belonging to the runtime type having the specified name.
public static GetMethod ( Type type, String methodName ) : MethodInfo
type System.Type The runtime type.
methodName String The method name.
return System.Reflection.MethodInfo

GetNewEntity() public static method

Creates a new instance of the specified type.
public static GetNewEntity ( Type type ) : Object
type System.Type The runtime type to instantiate.
return Object

GetNewGenericEntity() public static method

Creates a new instance of the specified generic type.
public static GetNewGenericEntity ( Type genericType ) : Object
genericType System.Type The runtime type.
return Object

GetNewGenericEntity() public static method

Creates a new instance of the specified generic type.
public static GetNewGenericEntity ( Type typeDefinition, Type typeArguments ) : Object
typeDefinition System.Type A generic type definition.
typeArguments System.Type An array of System.Type arguments.
return Object

GetProperty() public static method

Gets a PropertyInfo object representing the property belonging to the object having the specified name.
public static GetProperty ( Object item, String propertyName ) : PropertyInfo
item Object An object instance.
propertyName String The property name.
return System.Reflection.PropertyInfo

GetProperty() public static method

Gets a PropertyInfo object representing the property belonging to the runtime type having the specified name.
public static GetProperty ( Type type, String propertyName ) : PropertyInfo
type System.Type The runtime type.
propertyName String The property name.
return System.Reflection.PropertyInfo

GetPropertyValue() public static method

Gets the value of the property with the specified name.
public static GetPropertyValue ( Object item, String propertyName ) : Object
item Object An object instance.
propertyName String The property name.
return Object

GetPropertyValue() public static method

Gets the value of the property with the specified name.
public static GetPropertyValue ( Object item, String propertyName, PropertyInfo &property ) : Object
item Object An object instance.
propertyName String The property name.
property System.Reflection.PropertyInfo A reference to the object.
return Object

GetStaticPropertyValue() public static method

Gets the value of the static property with the specified name.
public static GetStaticPropertyValue ( Type type, String propertyName ) : Object
type System.Type The runtime type.
propertyName String The property name.
return Object

GetStaticPropertyValue() public static method

Gets the value of the static property with the specified name.
public static GetStaticPropertyValue ( Type type, String propertyName, PropertyInfo &property ) : Object
type System.Type The runtime type.
propertyName String The property name.
property System.Reflection.PropertyInfo A reference to the object.
return Object

GetType() public static method

Gets the System.Type with the specified name.
public static GetType ( String typeName ) : Type
typeName String The name of the type to get.
return System.Type

GetTypeNames() public static method

Outputs a string containing the type names, delimited by ", "
public static GetTypeNames ( ) : string
return string

GetTypes() public static method

Gets an array of System.Type objects which match the specified objects. NOTE: this method will throw an exception if any of the values held within the args array are null.
public static GetTypes ( ) : System.Type[]
return System.Type[]

GuidTryParse() public static method

Converts the string representation of a Guid to its Guid equivalent. A return value indicates whether the operation succeeded.
/// Thrown if is . ///
public static GuidTryParse ( string s, System.Guid &result ) : bool
s string A string containing a Guid to convert.
result System.Guid /// When this method returns, contains the Guid value equivalent to /// the Guid contained in , if the conversion /// succeeded, or if the conversion failed. /// The conversion fails if the parameter is a /// reference ( in /// Visual Basic), or is not of the correct format. ///
return bool

HasEntities() public static method

Gets a value indicating whether the specified list contains any items.
public static HasEntities ( IList entities ) : bool
entities IList A collection of objects.
return bool

InitEntityDateTimeValues() public static method

Initializes the properties specified in propertyNames with the value of DateTime.Now for the specified entity.
public static InitEntityDateTimeValues ( Object entity ) : void
entity Object The instance of an object to set the properties on.
return void

InvokeMethod() public static method

Invokes the specified method on the object using reflection.
public static InvokeMethod ( Object entity, String methodName ) : Object
entity Object An object instance.
methodName String The method name.
return Object

InvokeMethod() public static method

Invokes the specified method on the object using reflection. Passes the supplied arguments as method parameters.
public static InvokeMethod ( Object entity, String methodName, Object args ) : Object
entity Object An object instance.
methodName String The method name.
args Object The method parameters.
return Object

InvokeMethod() public static method

Invokes the specified method on the object using reflection. Passes the supplied arguments as method parameters.
public static InvokeMethod ( Object entity, String methodName, Object args, Type types ) : Object
entity Object An object instance.
methodName String The method name.
args Object The method parameters.
types System.Type The method parameter types.
return Object

IsPropertyValueEqual() public static method

Determines if the property with the specified name equals the specified value.
public static IsPropertyValueEqual ( Object item, String propertyName, Object propertyValue ) : bool
item Object An object instance.
propertyName String The property name.
propertyValue Object The property value.
return bool

MakeGenericType() public static method

Creates a reference to a generic type using the specified type definition and the supplied type arguments.
public static MakeGenericType ( Type typeDefinition, Type typeArguments ) : Type
typeDefinition System.Type A generic type definition.
typeArguments System.Type An array of System.Type arguments.
return System.Type

Remove() public static method

Removes the specified object from the collection of objects.
public static Remove ( IList list, Object item ) : void
list IList A collection of objects.
item Object The object to remove.
return void

SetEntityKeyValue() public static method

Sets the value of the property with the specified name to the value returned by the Guid.NewGuid() method.
public static SetEntityKeyValue ( Object entity, String entityKeyName ) : System.Guid
entity Object An object instance.
entityKeyName String The property name.
return System.Guid

SetEntityValues() public static method

Sets the properties of the specified entity based on the name/value pairs found in the specified collection.
public static SetEntityValues ( Object entity, IDictionary values ) : void
entity Object The instance of an object to set the properties on.
values IDictionary An instance of System.Collections.IDictionary containing the name/value pairs.
return void

SetPropertyValue() public static method

Sets the value of the property with the specified name.
public static SetPropertyValue ( Object item, String propertyName, Object propertyValue ) : void
item Object An object instance.
propertyName String The property name.
propertyValue Object The property value.
return void

SetPropertyValue() public static method

Sets the value of the property with the specified name.
public static SetPropertyValue ( Object item, String propertyName, Object propertyValue, PropertyInfo &property ) : void
item Object An object instance.
propertyName String The property name.
propertyValue Object The property value.
property System.Reflection.PropertyInfo A reference to the object.
return void

SetPropertyValue() public static method

Sets the value of the property with the specified name.
public static SetPropertyValue ( Object item, String propertyName, Object propertyValue, PropertyInfo &property, bool convertBlankToNull ) : void
item Object An object instance.
propertyName String The property name.
propertyValue Object The property value.
property System.Reflection.PropertyInfo A reference to the object.
convertBlankToNull bool Boolean indicating whether empty strings should be converted to null values.
return void

SetPropertyValue() public static method

Sets the value of the property with the specified name.
public static SetPropertyValue ( Object item, String propertyName, Object propertyValue, bool convertBlankToNull ) : void
item Object An object instance.
propertyName String The property name.
propertyValue Object The property value.
convertBlankToNull bool Boolean indicating whether empty strings should be converted to null values.
return void