2 * Copyright (c) 2019 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 System.Reflection;
19 using System.Runtime.Loader;
21 using System.Collections.Generic;
23 namespace Tizen.Init {
27 // key : assembly name, value : list of types
28 static IDictionary<string, List<string>> assem_type = new Dictionary<string, List<string>>
30 {"ElmSharp", new List<string>(){
35 "ElmSharp.Conformant",
36 "ElmSharp.DateTimeSelector",
37 "ElmSharp.DisplayRotation",
38 "ElmSharp.EdjeObject",
39 "ElmSharp.EdjeObject+SignalData",
40 "ElmSharp.EdjeTextPartObject",
41 "ElmSharp.Elementary",
43 "ElmSharp.EvasKeyEventArgs",
45 "ElmSharp.EvasObject",
46 "ElmSharp.FocusDirection",
48 "ElmSharp.GestureLayer+GestureType",
49 "ElmSharp.IInvalidatable",
51 "ElmSharp.ItemObject+SignalData",
57 "ElmSharp.ProgressBar",
69 {"ElmSharp.Wearable", new List<string>(){
70 "ElmSharp.Wearable.CircleDateTimeSelector",
71 "ElmSharp.Wearable.CircleGenList",
72 "ElmSharp.Wearable.CircleScroller",
73 "ElmSharp.Wearable.CircleSpinner",
74 "ElmSharp.Wearable.ICircleWidget",
75 "ElmSharp.Wearable.IRotaryActionWidget",
77 {"System.IO.FileSystem", new List<string>(){
79 "<PrivateImplementationDetails>",
81 {"System.Security.Cryptography.Algorithms", new List<string>(){
83 "System.Security.Cryptography.MD5"}},
84 {"System.Collections", new List<string>(){
85 "<PrivateImplementationDetails>",
86 "System.Collections.Generic.HashSet`1",
87 "System.Collections.Generic.Queue`1"}},
88 {"System.Private.Uri", new List<string>(){
89 "<PrivateImplementationDetails>",
91 {"System.Private.Xml", new List<string>(){
92 "<PrivateImplementationDetails>",
93 "System.Xml.IXmlLineInfo",
94 "System.Xml.IXmlNamespaceResolver"}},
95 {"System.Runtime", new List<string>(){
96 "System.Collections.Generic.ISet`1",
97 "System.Reflection.RuntimeReflectionExtensions"}},
98 {"System.ObjectModel", new List<string>(){
99 "System.Collections.ObjectModel.ObservableCollection`1",
100 "System.Collections.Specialized.INotifyCollectionChanged",
101 "System.Collections.Specialized.NotifyCollectionChangedAction",
102 "System.Collections.Specialized.NotifyCollectionChangedEventArgs",
103 "System.Collections.Specialized.NotifyCollectionChangedEventHandler",
104 "System.ComponentModel.INotifyPropertyChanged",
105 "System.ComponentModel.PropertyChangedEventArgs",
106 "System.ComponentModel.PropertyChangedEventHandler",
107 "System.Windows.Input.ICommand"}},
108 {"System.ComponentModel", new List<string>(){
109 "System.IServiceProvider"}},
110 {"System.Linq", new List<string>(){
111 "System.Linq.Enumerable",
112 "System.Linq.EnumerableSorter`1",
113 "System.Linq.IIListProvider`1",
114 "System.Linq.IOrderedEnumerable`1",
115 "System.Linq.IPartition`1",
116 "System.Linq.OrderedEnumerable`1"}},
117 {"System.Linq.Expressions", new List<string>(){
118 "System.Linq.Expressions.ExpressionVisitor"}},
119 {"System.Security.Cryptography.Primitives", new List<string>(){
120 "System.Security.Cryptography.HashAlgorithm"}},
121 {"Tizen.Applications.Common", new List<string>(){
123 "Tizen.Applications.Application",
124 "Tizen.Applications.CoreApplication",
125 "Tizen.Applications.CoreBackend.EventType",
126 "Tizen.Applications.TizenSynchronizationContext"}},
127 {"Tizen.Applications.UI", new List<string>(){
128 "Tizen.Applications.CoreUIApplication",
130 {"Tizen", new List<string>(){
132 {"Tizen.Log", new List<string>(){
135 {"Tizen.System.Information", new List<string>(){
136 "Tizen.System.Information"}}
139 static void PreloadEnd()
143 GC.WaitForPendingFinalizers();
146 static void PreloadTypes()
148 foreach (KeyValuePair<string, List<string>> item in assem_type)
150 Assembly asm = LoadAssembly(item.Key);
152 foreach (string t in item.Value)
164 static Assembly LoadAssembly(string name)
166 var context = AssemblyLoadContext.Default;
171 ret = context.LoadFromAssemblyName(new AssemblyName(name));
175 Console.WriteLine(e.ToString());
182 static void LoadType(Assembly assem, string typeName)
186 var tp = assem.GetType(typeName);
190 Console.WriteLine("Tizen.Init.TypeLoader.PreloadTypes can't load type " + typeName + " from assembly " + assem.ToString());
194 // CU loading makes launching time much slower.
195 // To prevent that kind of overhead, preload ICU by calling String.ToLower()
196 static void PreloadLibICU()
198 // to preinitialize icu, do string compare
199 if ("A".ToLower() != "a") {
200 Console.WriteLine("Failed to String.ToLower()");