C# Class Nettiers.AdventureWorks.Entities.EntityUtil

Provides common utility methods for interacting with objects.
Afficher le fichier Open project: netTiers/netTiers Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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.
Résultat void

ChangeGenericType() public static méthode

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.
Résultat Object

ChangeGenericType() public static méthode

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.
Résultat Object

ChangeType() public static méthode

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.
Résultat Object

ChangeType() public static méthode

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.
Résultat Object

GetConstructor() public static méthode

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

GetConstructor() public static méthode

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.
Résultat System.Reflection.ConstructorInfo

GetEntity() public static méthode

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.
Résultat Object

GetEntity() public static méthode

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.
Résultat Object

GetEntityList() public static méthode

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

GetEntityList() public static méthode

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.
Résultat IList

GetMethod() public static méthode

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.
Résultat System.Reflection.MethodInfo

GetMethod() public static méthode

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.
Résultat System.Reflection.MethodInfo

GetNewEntity() public static méthode

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

GetNewGenericEntity() public static méthode

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

GetNewGenericEntity() public static méthode

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.
Résultat Object

GetProperty() public static méthode

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.
Résultat System.Reflection.PropertyInfo

GetProperty() public static méthode

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.
Résultat System.Reflection.PropertyInfo

GetPropertyValue() public static méthode

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.
Résultat Object

GetPropertyValue() public static méthode

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.
Résultat Object

GetStaticPropertyValue() public static méthode

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.
Résultat Object

GetStaticPropertyValue() public static méthode

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.
Résultat Object

GetType() public static méthode

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

GetTypeNames() public static méthode

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

GetTypes() public static méthode

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[]
Résultat System.Type[]

GuidTryParse() public static méthode

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. ///
Résultat bool

HasEntities() public static méthode

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

InitEntityDateTimeValues() public static méthode

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.
Résultat void

InvokeMethod() public static méthode

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.
Résultat Object

InvokeMethod() public static méthode

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.
Résultat Object

InvokeMethod() public static méthode

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.
Résultat Object

IsPropertyValueEqual() public static méthode

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.
Résultat bool

MakeGenericType() public static méthode

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.
Résultat System.Type

Remove() public static méthode

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.
Résultat void

SetEntityKeyValue() public static méthode

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.
Résultat System.Guid

SetEntityValues() public static méthode

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.
Résultat void

SetPropertyValue() public static méthode

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.
Résultat void

SetPropertyValue() public static méthode

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.
Résultat void

SetPropertyValue() public static méthode

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.
Résultat void

SetPropertyValue() public static méthode

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.
Résultat void