Ejemplo n.º 1
0
 /// <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));
 }
Ejemplo n.º 2
0
        // 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));
        }
Ejemplo n.º 3
0
 /// <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));
 }
Ejemplo n.º 4
0
 /// <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));
 }
Ejemplo n.º 5
0
 /// <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));
 }
Ejemplo n.º 6
0
        // 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));
        }
Ejemplo n.º 7
0
 /// <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));
 }