C# 클래스 Nvelope.TypeExtensions

Some helpers for casting objects using built-in CLR casting operators
파일 보기 프로젝트 열기: TrinityWestern/Nvelope

공개 메소드들

메소드 설명
DynamicCast ( this targetType, object value ) : object

Cast an object from one type to the other using .Net conversion

There's a similar ConvertTo method in this library that is much more complicated and doesn't allow for user defined conversions

GetCastMethod ( Type from, Type to ) : MethodInfo

Gets the most appropriate cast method from one type to another

GetLoadableTypes ( this assembly ) : IEnumerable

Thank you Jon Skeet. http://stackoverflow.com/questions/7889228/how-to-prevent-reflectiontypeloadexception-when-calling-assembly-gettypes Calling GetTypes() on an assembly that inherits from a non-referenced assembly will throw exceptions. This extension method will only get the types from the assembly that we actually can load.

메소드 상세

DynamicCast() 공개 정적인 메소드

Cast an object from one type to the other using .Net conversion
There's a similar ConvertTo method in this library that is much more complicated and doesn't allow for user defined conversions
Thrown if conversion fails
public static DynamicCast ( this targetType, object value ) : object
targetType this
value object
리턴 object

GetCastMethod() 공개 정적인 메소드

Gets the most appropriate cast method from one type to another
public static GetCastMethod ( Type from, Type to ) : MethodInfo
from System.Type Type of initial object
to System.Type Type of casted object
리턴 System.Reflection.MethodInfo

GetLoadableTypes() 공개 정적인 메소드

Thank you Jon Skeet. http://stackoverflow.com/questions/7889228/how-to-prevent-reflectiontypeloadexception-when-calling-assembly-gettypes Calling GetTypes() on an assembly that inherits from a non-referenced assembly will throw exceptions. This extension method will only get the types from the assembly that we actually can load.
public static GetLoadableTypes ( this assembly ) : IEnumerable
assembly this
리턴 IEnumerable