[NUI] Add license, delete unnecessary code (#2679)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / Internals / ResourceLoader.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.IO;
19 using System.Reflection;
20 using Tizen.NUI.Xaml;
21
22 namespace Tizen.NUI.Binding.Internals
23 {
24     internal static class ResourceLoader
25     {
26         static Func<AssemblyName, string, string> resourceProvider = (asmName, path) =>
27         {
28             if (typeof(Theme).Assembly.GetName().FullName != asmName.FullName)
29             {
30                 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
31                 path = resource + path;
32             }
33
34             string ret = File.ReadAllText(path);
35             return ret;
36         };
37
38         //takes a resource path, returns string content
39         public static Func<AssemblyName, string, string> ResourceProvider
40         {
41             get => resourceProvider;
42             internal set
43             {
44                 DesignMode.IsDesignModeEnabled = true;
45                 resourceProvider = value;
46             }
47         }
48
49         internal static Action<Exception> ExceptionHandler { get; set; }
50     }
51 }