2 * Copyright(c) 2021 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.Collections.Generic;
21 using System.Reflection;
23 using Tizen.NUI.Binding;
24 using Tizen.NUI.EXaml.Build.Tasks;
25 using Tizen.NUI.Xaml.Build.Tasks;
27 namespace Tizen.NUI.EXaml
30 internal class EXamlAddEvent : EXamlOperation
32 internal override string Write()
34 if (false == Instance.IsValid)
41 ret += String.Format("({0} ({1} {2} {3} {4}))\n",
42 eXamlContext.GetValueString((int)EXamlOperationType.AddEvent),
43 eXamlContext.GetValueString(Instance.Index),
44 eXamlContext.GetValueString(Element.Index),
45 eXamlContext.GetValueString(eXamlContext.definedEvents.GetIndex(eventDef.DeclaringType, eventDef)),
46 eXamlContext.GetValueString(eXamlContext.definedMethods.GetIndex(Value.DeclaringType, Value)));
51 public EXamlAddEvent(EXamlContext context, EXamlCreateObject instance, EXamlCreateObject element, string eventName, MethodDefinition value)
54 TypeReference typeref;
55 var eventDef = instance.Type.GetEvent(fi=>fi.Name==eventName, out typeref);
61 DeclaringType = typeref;
63 this.eventDef = eventDef;
65 Instance.AddEvent(DeclaringType, eventDef);
67 eXamlContext.eXamlOperations.Add(this);
68 eXamlContext.eXamlAddEventList.Add(this);
72 throw new Exception("Property is not element");
76 internal EXamlCreateObject Instance
81 internal EXamlCreateObject Element
86 internal TypeReference DeclaringType
91 internal MethodDefinition Value
96 private EventDefinition eventDef;