Example #1
0
 /// <summary>
 /// Loads the API for the given extension, using the base API.
 /// </summary>
 /// <param name="device">The device of the context.</param>
 /// <param name="baseAPI">The base API instance.</param>
 /// <typeparam name="TContextExtension">The extension type.</typeparam>
 /// <returns>The extension.</returns>
 /// <exception cref="ExtensionNotSupportedException">Thrown if the API doesn't support the extension.</exception>
 internal static TContextExtension LoadContextExtension <TContextExtension>(ALContext baseApi)
     where TContextExtension : NativeExtension <ALContext>
 {
     return(baseApi.IsExtensionPresent(ExtensionAttribute.GetExtensionAttribute(typeof(TContextExtension)).Name)
         ? (TContextExtension)Activator.CreateInstance(typeof(TContextExtension), baseApi.Context)
         : null);
 }
Example #2
0
 public bool TryGetExtension <T>(out T ext)
     where T : NativeExtension <CL>
 {
     ext = IsExtensionPresent(ExtensionAttribute.GetExtensionAttribute(typeof(T)).Name)
         ? (T)Activator.CreateInstance(typeof(T), Context)
         : null;
     return(ext != null);
 }