3 using System.Reflection;
6 using Tizen.NUI.Binding.Internals;
8 // [assembly:Dependency(typeof(Tizen.NUI.Xaml.ResourcesLoader))]
9 namespace Tizen.NUI.Xaml
11 internal class ResourcesLoader : IResourcesLoader
13 public T CreateFromResource<T>(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo) where T : new()
15 var alternateResource = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), resourcePath);
16 if (alternateResource != null)
19 rd.LoadFromXaml(alternateResource);
23 var resourceId = XamlResourceIdAttribute.GetResourceIdForPath(assembly, resourcePath);
24 if (resourceId == null)
25 throw new XamlParseException($"Resource '{resourcePath}' not found.", lineInfo);
27 using (var stream = assembly.GetManifestResourceStream(resourceId))
30 throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
31 using (var reader = new StreamReader(stream))
34 rd.LoadFromXaml(reader.ReadToEnd());
40 public string GetResource(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo)
42 var alternateResource = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), resourcePath);
43 if (alternateResource != null)
44 return alternateResource;
46 var resourceId = XamlResourceIdAttribute.GetResourceIdForPath(assembly, resourcePath);
47 if (resourceId == null)
48 throw new XamlParseException($"Resource '{resourcePath}' not found.", lineInfo);
50 using (var stream = assembly.GetManifestResourceStream(resourceId))
53 throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
54 using (var reader = new StreamReader(stream))
55 return reader.ReadToEnd();