/// <summary> /// Resolves the type of the attribute. /// </summary> /// <param name="desc">The desc.</param> /// <param name="engineImportService">The engine import service.</param> /// <returns></returns> public static Type ResolveAttributeType(AnnotationDesc desc, EngineImportService engineImportService) { // CLR attributes use a different notation that Java annotations. Format // the attribute according to CLR conventions. var attributeTypeName = desc.Name; var attributeTypeNameForCLR = (attributeTypeName.EndsWith("Attribute")) ? attributeTypeName : String.Format("{0}Attribute", attributeTypeName); // resolve attribute type try { engineImportService.GetClassLoader(); // Currently unused return(engineImportService.ResolveAnnotation(attributeTypeNameForCLR)); } catch (EngineImportException e) { throw new AttributeException("Failed to resolve @-annotation class: " + e.Message); } }
public static Module ReadResource( String resource, EngineImportService engineImportService, IResourceManager resourceManager) { Stream stream = null; var stripped = resource.StartsWith("/") ? resource.Substring(1) : resource; var classLoader = engineImportService.GetClassLoader(); if (classLoader != null) { stream = classLoader.GetResourceAsStream(stripped); } if (stream == null) { stream = resourceManager.GetResourceAsStream(stripped); } if (stream == null) { throw new IOException("Failed to find resource '" + resource + "' in classpath"); } try { return(ReadInternal(stream, resource)); } finally { try { stream.Close(); } catch (IOException e) { Log.Debug("Error closing input stream", e); } } }