2 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Reflection;
22 namespace Tizen.NUI.Binding.Internals
24 internal static class ResourceLoader
26 static Func<ResourceLoadingQuery, ResourceLoadingResponse> _resourceProvider = (resourceLoadingQuery) => {
27 if (typeof(Theme).Assembly.GetName().FullName != resourceLoadingQuery.AssemblyName.FullName)
29 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
30 resourceLoadingQuery.ResourcePath = resource + resourceLoadingQuery.ResourcePath;
33 string ret = File.ReadAllText(resourceLoadingQuery.ResourcePath);
34 return new ResourceLoadingResponse { ResourceContent = ret };
36 public static Func<ResourceLoadingQuery, ResourceLoadingResponse> ResourceProvider
38 get => _resourceProvider;
41 DesignMode.IsDesignModeEnabled = value != null;
42 _resourceProvider = value;
46 internal static Action<(Exception exception, string filepath)> ExceptionHandler { get; set; }
48 public class ResourceLoadingQuery
50 public AssemblyName AssemblyName { get; set; }
51 public string ResourcePath { get; set; }
52 public object Instance { get; set; }
55 public class ResourceLoadingResponse
57 public string ResourceContent { get; set; }
58 public bool UseDesignProperties { get; set; }