/// <summary> /// Helper method to get named object from <see cref="UsesProviderQuery"/> when the type of the object is known at compile time. /// </summary> /// <typeparam name="T">The type of the object to get.</typeparam> /// <param name="uses">The <see cref="UsesProviderQuery"/>.</param> /// <param name="name">The name of the object. May be <c>null</c> in order to search for unnamed object.</param> /// <returns>Result of <see cref="UsesProviderQuery.GetObjectForName(Type, String)"/>.</returns> /// <exception cref="NullReferenceException">If <paramref name="uses"/> is <c>null</c> or if <typeparamref name="T"/> is value type and <see cref="UsesProviderQuery.GetObjectForName(Type, String)"/> returned <c>null</c>.</exception> /// <seealso cref="UsesProviderQuery.GetObjectForName(Type, String)"/> public static T GetForName <T>(this UsesProviderQuery uses, String name) { return((T)uses.GetObjectForName(typeof(T), name)); }
/// <summary> /// Helper method to get unnamed object from <see cref="UsesProviderQuery"/>. /// </summary> /// <param name="uses">The <see cref="UsesProviderQuery"/>.</param> /// <param name="type">The type of the unnamed object to get.</param> /// <returns>Result of <see cref="UsesProviderQuery.GetObjectForName(Type, String)"/>.</returns> /// <exception cref="NullReferenceException">If <paramref name="uses"/> is <c>null</c>.</exception> /// <seealso cref="UsesProviderQuery.GetObjectForName(Type, String)"/> public static Object Get(this UsesProviderQuery uses, Type type) { return(uses.GetObjectForName(type, null)); }
/// <summary> /// Helper method to get unnamed object from <see cref="UsesProviderQuery"/> when the type of the object is known at compile time. /// </summary> /// <typeparam name="T">The type of the object to get.</typeparam> /// <param name="uses">The <see cref="UsesProviderQuery"/>.</param> /// <returns>Result of <see cref="UsesProviderQuery.GetObjectForName(Type, String)"/>.</returns> /// <exception cref="NullReferenceException">If <paramref name="uses"/> is <c>null</c> or if <typeparamref name="T"/> is value type and <see cref="UsesProviderQuery.GetObjectForName(Type, String)"/> returned <c>null</c>.</exception> /// <seealso cref="UsesProviderQuery.GetObjectForName(Type, String)"/> public static T Get <T>(this UsesProviderQuery uses) { return((T)uses.Get(typeof(T))); }