C# Класс Spring.Util.ObjectUtils

Helper methods with regard to objects, types, properties, etc.

Not intended to be used directly by applications.

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
EmptyObjects object[]

Открытые методы

Метод Описание
EnumerateElementAtIndex ( IEnumerable enumerable, int index ) : object

Returns the element at the specified index using the supplied enumerable.

EnumerateElementAtIndex ( IEnumerator enumerator, int index ) : object

Returns the element at the specified index using the supplied enumerator.

EnumerateFirstElement ( IEnumerable enumerable ) : object

Returns the first element in the supplied enumerable.

EnumerateFirstElement ( IEnumerator enumerator ) : object

Returns the first element in the supplied enumerator.

GetIdentityHexString ( object obj ) : string

Gets a hex String form of an object's identity hash code.

GetQualifiedMethodName ( MethodInfo method ) : string

Gets the qualified name of the given method, consisting of fully qualified interface/class name + "." method name.

GetZeroArgConstructorInfo ( Type type ) : ConstructorInfo

Gets the zero arg ConstructorInfo object, if the type offers such functionality.

IdentityToString ( object obj ) : object

Return a String representation of an object's overall identity.

InstantiateType ( Assembly assembly, string typeName ) : object

Instantiates the type using the assembly specified to load the type.

This is a convenience in the case of needing to instantiate a type but not wanting to specify in the string the version, culture and public key token.

InstantiateType ( ConstructorInfo constructor, object arguments ) : object

Convenience method to instantiate a System.Type using the given constructor.

As this method doesn't try to instantiate System.Types by name, it should avoid System.Type loading issues.

InstantiateType ( Type type ) : object

Convenience method to instantiate a System.Type using its no-arg constructor.

As this method doesn't try to instantiate System.Types by name, it should avoid System.Type loading issues.

IsAssignable ( Type type, object obj ) : bool

Determine if the given System.Type is assignable from the given value, assuming setting by reflection and taking care of transparent proxies.

Considers primitive wrapper classes as assignable to the corresponding primitive types.

For example used in an object factory's constructor resolution.

IsAssignableAndNotTransparentProxy ( Type type, object instance ) : bool

Checks whether the supplied instance is not a transparent proxy and is assignable to the supplied type.

Neccessary when dealing with server-activated remote objects, because the object is of the type TransparentProxy and regular is testing for assignable types does not work.

Transparent proxy instances always return when tested with the 'is' operator (C#). This method only checks if the object is assignable to the type if it is not a transparent proxy.

IsEmpty ( object array ) : bool

Determines whether the specified array is null or empty.

IsInstantiable ( Type type ) : void

Determines whether the specified type is instantiable, i.e. not an interface, abstract class or contains open generic type parameters.

IsPrimitiveArray ( Type type ) : bool

Check if the given class represents a primitive array, i.e. boolean, byte, char, short, int, long, float, or double.

IsSimpleProperty ( Type type ) : bool

Check if the given System.Type represents a "simple" property, i.e. a primitive, a System.String, a System.Type, or a corresponding array.

Used to determine properties to check for a "simple" dependency-check.

NullSafeEquals ( object o1, object o2 ) : bool

Determine if the given objects are equal, returning if both are respectively if only one is .

NullSafeHashCode ( object o1 ) : int

Return as hash code for the given object; typically the value of {@link Object#hashCode()}. If the object is an array, this method will delegate to any of the nullSafeHashCode methods for arrays in this class. If the object is null, this method returns 0.

Приватные методы

Метод Описание
ObjectUtils ( ) : System

Описание методов

EnumerateElementAtIndex() публичный статический Метод

Returns the element at the specified index using the supplied enumerable.
/// If the supplied was less than zero, or the /// supplied did not contain enough elements /// to be able to reach the supplied . /// /// If the supplied is . ///
public static EnumerateElementAtIndex ( IEnumerable enumerable, int index ) : object
enumerable IEnumerable /// The to use to enumerate /// elements until the supplied is reached. ///
index int /// The index of the element in the enumeration to return. ///
Результат object

EnumerateElementAtIndex() публичный статический Метод

Returns the element at the specified index using the supplied enumerator.
/// If the supplied was less than zero, or the /// supplied did not contain enough elements /// to be able to reach the supplied . ///
public static EnumerateElementAtIndex ( IEnumerator enumerator, int index ) : object
enumerator IEnumerator /// The to use to enumerate /// elements until the supplied is reached. ///
index int /// The index of the element in the enumeration to return. ///
Результат object

EnumerateFirstElement() публичный статический Метод

Returns the first element in the supplied enumerable.
/// If the supplied did not have any elements. /// /// If the supplied is . ///
public static EnumerateFirstElement ( IEnumerable enumerable ) : object
enumerable IEnumerable /// The to use to enumerate /// elements. ///
Результат object

EnumerateFirstElement() публичный статический Метод

Returns the first element in the supplied enumerator.
/// If the supplied did not have any elements. ///
public static EnumerateFirstElement ( IEnumerator enumerator ) : object
enumerator IEnumerator /// The to use to enumerate /// elements. ///
Результат object

GetIdentityHexString() публичный статический Метод

Gets a hex String form of an object's identity hash code.
public static GetIdentityHexString ( object obj ) : string
obj object The obj.
Результат string

GetQualifiedMethodName() публичный статический Метод

Gets the qualified name of the given method, consisting of fully qualified interface/class name + "." method name.
public static GetQualifiedMethodName ( MethodInfo method ) : string
method MethodInfo The method.
Результат string

GetZeroArgConstructorInfo() публичный статический Метод

Gets the zero arg ConstructorInfo object, if the type offers such functionality.
/// If the type is an interface, abstract, open generic type, or does not have a zero-arg constructor. ///
public static GetZeroArgConstructorInfo ( Type type ) : ConstructorInfo
type System.Type The type.
Результат System.Reflection.ConstructorInfo

IdentityToString() публичный статический Метод

Return a String representation of an object's overall identity.
public static IdentityToString ( object obj ) : object
obj object The object (may be null).
Результат object

InstantiateType() публичный статический Метод

Instantiates the type using the assembly specified to load the type.
This is a convenience in the case of needing to instantiate a type but not wanting to specify in the string the version, culture and public key token.
/// If the or is /// /// If cannot load the type from the assembly or the call to InstantiateType(Type) fails. ///
public static InstantiateType ( Assembly assembly, string typeName ) : object
assembly System.Reflection.Assembly The assembly.
typeName string Name of the type.
Результат object

InstantiateType() публичный статический Метод

Convenience method to instantiate a System.Type using the given constructor.

As this method doesn't try to instantiate System.Types by name, it should avoid System.Type loading issues.

/// If the is /// /// If the 's declaring type is an abstract class, /// an interface, an open generic type or does not have a public no-argument constructor. ///
public static InstantiateType ( ConstructorInfo constructor, object arguments ) : object
constructor System.Reflection.ConstructorInfo /// The constructor to use for the instantiation. ///
arguments object /// The arguments to be passed to the constructor. ///
Результат object

InstantiateType() публичный статический Метод

Convenience method to instantiate a System.Type using its no-arg constructor.

As this method doesn't try to instantiate System.Types by name, it should avoid System.Type loading issues.

/// If the is /// /// If the is an abstract class, an interface, /// an open generic type or does not have a public no-argument constructor. ///
public static InstantiateType ( Type type ) : object
type System.Type /// The to instantiate* ///
Результат object

IsAssignable() публичный статический Метод

Determine if the given System.Type is assignable from the given value, assuming setting by reflection and taking care of transparent proxies.

Considers primitive wrapper classes as assignable to the corresponding primitive types.

For example used in an object factory's constructor resolution.

public static IsAssignable ( Type type, object obj ) : bool
type System.Type The target .
obj object The value that should be assigned to the type.
Результат bool

IsAssignableAndNotTransparentProxy() публичный статический Метод

Checks whether the supplied instance is not a transparent proxy and is assignable to the supplied type.

Neccessary when dealing with server-activated remote objects, because the object is of the type TransparentProxy and regular is testing for assignable types does not work.

Transparent proxy instances always return when tested with the 'is' operator (C#). This method only checks if the object is assignable to the type if it is not a transparent proxy.

public static IsAssignableAndNotTransparentProxy ( Type type, object instance ) : bool
type System.Type The target to be checked.
instance object The value that should be assigned to the type.
Результат bool

IsEmpty() публичный статический Метод

Determines whether the specified array is null or empty.
public static IsEmpty ( object array ) : bool
array object The array to check.
Результат bool

IsInstantiable() публичный статический Метод

Determines whether the specified type is instantiable, i.e. not an interface, abstract class or contains open generic type parameters.
public static IsInstantiable ( Type type ) : void
type System.Type The type.
Результат void

IsPrimitiveArray() публичный статический Метод

Check if the given class represents a primitive array, i.e. boolean, byte, char, short, int, long, float, or double.
public static IsPrimitiveArray ( Type type ) : bool
type System.Type
Результат bool

IsSimpleProperty() публичный статический Метод

Check if the given System.Type represents a "simple" property, i.e. a primitive, a System.String, a System.Type, or a corresponding array.

Used to determine properties to check for a "simple" dependency-check.

public static IsSimpleProperty ( Type type ) : bool
type System.Type /// The to check. ///
Результат bool

NullSafeEquals() публичный статический Метод

Determine if the given objects are equal, returning if both are respectively if only one is .
public static NullSafeEquals ( object o1, object o2 ) : bool
o1 object The first object to compare.
o2 object The second object to compare.
Результат bool

NullSafeHashCode() публичный статический Метод

Return as hash code for the given object; typically the value of {@link Object#hashCode()}. If the object is an array, this method will delegate to any of the nullSafeHashCode methods for arrays in this class. If the object is null, this method returns 0.
public static NullSafeHashCode ( object o1 ) : int
o1 object
Результат int

Описание свойств

EmptyObjects публичное статическое свойство

An empty object array.
public static object[] EmptyObjects
Результат object[]