2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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.
18 using Tizen.Internals.Errors;
20 namespace Tizen.Applications
23 /// Class for getting resource path.
25 public static class ResourceManager
28 /// Enumeration for Resource category.
30 public enum Category : int
53 private static ErrorCode AppResourceManagerGet(Category category, string id, out string path)
59 err = Interop.AppCommon.AppResourceManagerGet(
60 (Interop.AppCommon.ResourceCategory)category, id, out path);
62 catch (System.TypeLoadException)
64 err = Interop.AppCommon.LegacyAppResourceManagerGet(
65 (Interop.AppCommon.ResourceCategory)category, id, out path);
72 /// Converts resource ID to path name.
74 /// <param name="category">Category to search</param>
75 /// <param name="id">ID to search</param>
76 /// <returns>Found resource path</returns>
77 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
78 public static string GetPath(Category category, string id)
81 ErrorCode err = AppResourceManagerGet(category, id, out path);
85 case ErrorCode.InvalidParameter:
86 throw new InvalidOperationException("Invalid parameter");
88 case ErrorCode.OutOfMemory:
89 throw new InvalidOperationException("Out-of-memory at unmanaged code");
91 case ErrorCode.IoError:
92 throw new InvalidOperationException("IO error at unmanaged code");
99 /// Converts resource ID to path name.
101 /// <param name="category">Category to search</param>
102 /// <param name="id">ID to search</param>
103 /// <returns>Found resource path or null when the resource doesn't exist</returns>
104 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
105 public static string TryGetPath(Category category, string id)
108 ErrorCode err = AppResourceManagerGet(category, id, out path);
112 case ErrorCode.InvalidParameter:
113 throw new InvalidOperationException("Invalid parameter");
115 case ErrorCode.OutOfMemory:
116 throw new InvalidOperationException("Out-of-memory at unmanaged code");
118 case ErrorCode.IoError: