/// <summary> /// Gets all decorators that can convert a reference to the given type</summary> /// <typeparam name="T">Decorator type, must be ref type</typeparam> /// <returns>Enumerable returning all decorators of the given type</returns> public IEnumerable <T> AsAll <T>() where T : class { return(Adapters.AsAll <T>(this)); }
// implement the following members as a convenience when extension methods aren't available /// <summary> /// Converts a reference to the given type by first trying a CLR cast, and then /// trying to get an adapter</summary> /// <typeparam name="T">Desired type, must be ref type</typeparam> /// <returns>Converted reference for the given object or null</returns> public T As <T>() where T : class { return(Adapters.As <T>(this)); }
/// <summary> /// Returns a value indicating if the given reference can be converted to one of /// the desired type</summary> /// <typeparam name="T">Adapter type, must be ref type</typeparam> /// <returns>True, iff the given object can be converted</returns> public bool Is <T>() where T : class { return(Adapters.Is <T>(this)); }
/// <summary> /// Converts a reference to the given type by first trying a CLR cast, and then /// trying to get an adapter; if none is available, throws an AdaptationException</summary> /// <typeparam name="T">Desired type, must be ref type</typeparam> /// <returns>Converted reference for the given object</returns> public T Cast <T>() where T : class { return(Adapters.Cast <T>(this)); }
/// <summary> /// Converts a reference to the given type by first trying a CLR cast, and then /// trying to get an adapter; if none is available, throws an AdaptationException</summary> /// <typeparam name="U">Desired type, must be ref type</typeparam> /// <returns>Converted reference for the given object</returns> public U Cast <U>() where U : class { return(Adapters.Cast <U>(this)); }
// implement the following members as a convenience when extension methods aren't available /// <summary> /// Converts a reference to the given type by first trying a CLR cast, and then /// trying to get an adapter</summary> /// <typeparam name="U">Desired type, must be ref type</typeparam> /// <returns>Converted reference for the given object or null</returns> public U As <U>() where U : class { return(Adapters.As <U>(this)); }
/// <summary> /// Returns an enumeration of all decorators that can convert a reference to the given type</summary> /// <typeparam name="U">Decorator type, must be ref type</typeparam> /// <returns>Enumerable returning all decorators of the given type</returns> public IEnumerable <U> AsAll <U>() where U : class { return(Adapters.AsAll <U>(this)); }