From: Fang Xiaohui Date: Thu, 22 Apr 2021 03:07:45 +0000 (+0800) Subject: [EXaml] 1.Support List property 2.Support load multi EXaml X-Git-Tag: citest_t1~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=118a8f7b5aaefade94c3f9e66644e484f2bf893b;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [EXaml] 1.Support List property 2.Support load multi EXaml --- diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/AddEventAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/AddEventAction.cs index b929b1a..60fb053 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/AddEventAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/AddEventAction.cs @@ -25,12 +25,14 @@ namespace Tizen.NUI.EXaml { internal class AddEventAction : Action { - public AddEventAction(Action parent) + public AddEventAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -68,7 +70,7 @@ namespace Tizen.NUI.EXaml int elementIndex = (childOp.ValueList[1] as Instance).Index; int propertyIndex = (int)childOp.ValueList[2]; int value = (int)childOp.ValueList[3]; - LoadEXaml.Operations.Add(new AddEvent(instanceIndex, elementIndex, propertyIndex, value)); + globalDataList.Operations.Add(new AddEvent(globalDataList, instanceIndex, elementIndex, propertyIndex, value)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/AddExistInstanceAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/AddExistInstanceAction.cs index f1c0de0..475bd04 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/AddExistInstanceAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/AddExistInstanceAction.cs @@ -24,11 +24,14 @@ namespace Tizen.NUI.EXaml { internal class AddExistInstanceAction : Action { - internal AddExistInstanceAction(Action parent) + internal AddExistInstanceAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } + private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -70,11 +73,11 @@ namespace Tizen.NUI.EXaml if ('q' == sign) { - LoadEXaml.Operations.Add(new GatherConvertedValue(index, value)); + globalDataList.Operations.Add(new GatherConvertedValue(globalDataList, index, value)); } else if ('o' == sign) { - LoadEXaml.Operations.Add(new GatherEnumValue(index, value)); + globalDataList.Operations.Add(new GatherEnumValue(globalDataList, index, value)); } getValueListOp = null; @@ -83,11 +86,5 @@ namespace Tizen.NUI.EXaml private char sign; private GetValueListAction getValueListOp; - - internal static object Root - { - get; - set; - } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/AddToCollectionPropertyAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/AddToCollectionPropertyAction.cs new file mode 100755 index 0000000..f2c42c0 --- /dev/null +++ b/src/Tizen.NUI/src/internal/EXaml/Action/AddToCollectionPropertyAction.cs @@ -0,0 +1,75 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using Tizen.NUI.Binding; +using Tizen.NUI.Binding.Internals; + +namespace Tizen.NUI.EXaml +{ + internal class AddToCollectionPropertyAction : Action + { + public AddToCollectionPropertyAction(GlobalDataList globalDataList, Action parent) + { + this.parent = parent; + this.globalDataList = globalDataList; + } + + private Action parent; + private GlobalDataList globalDataList; + + public Action DealChar(char c) + { + switch (c) + { + case ' ': + case '\n': + case '\r': + break; + + case '(': + childOp = new GetValueListAction(')', this); + return childOp; + + case '~': + parent?.OnActive(); + return parent; + } + + return this; + } + + private GetValueListAction childOp; + + public void Init() + { + childOp = null; + } + + public void OnActive() + { + if (null != childOp) + { + int instanceIndex = (int)childOp.ValueList[0]; + var value = childOp.ValueList[1]; + globalDataList.Operations.Add(new AddToCollectionProperty(globalDataList, instanceIndex, value)); + } + } + } +} diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/AddToResourceDictionary.cs b/src/Tizen.NUI/src/internal/EXaml/Action/AddToResourceDictionary.cs index ce2793b..76874e0 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/AddToResourceDictionary.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/AddToResourceDictionary.cs @@ -25,12 +25,14 @@ namespace Tizen.NUI.EXaml { internal class AddToResourceDictionaryAction : Action { - public AddToResourceDictionaryAction(Action parent) + public AddToResourceDictionaryAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -67,7 +69,7 @@ namespace Tizen.NUI.EXaml int instanceIndex = (childOp.ValueList[0] as Instance).Index; string key = childOp.ValueList[1] as string; var value = childOp.ValueList[2]; - LoadEXaml.Operations.Add(new AddToResourceDictionary(instanceIndex, key, value)); + globalDataList.Operations.Add(new AddToResourceDictionary(globalDataList, instanceIndex, key, value)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/CallAddMethodAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/CallAddMethodAction.cs index 9404c70..701c12f 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/CallAddMethodAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/CallAddMethodAction.cs @@ -25,12 +25,14 @@ namespace Tizen.NUI.EXaml { internal class CallAddMethodAction : Action { - public CallAddMethodAction(Action parent) + public CallAddMethodAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -68,7 +70,7 @@ namespace Tizen.NUI.EXaml int childIndex = (childOp.ValueList[1] as Instance).Index; int methodIndex = (int)childOp.ValueList[2]; - LoadEXaml.Operations.Add(new CallAddMethod(parentIndex, childIndex, methodIndex)); + globalDataList.Operations.Add(new CallAddMethod(globalDataList, parentIndex, childIndex, methodIndex)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/CreateObjectAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/CreateInstanceAction.cs similarity index 83% rename from src/Tizen.NUI/src/internal/EXaml/Action/CreateObjectAction.cs rename to src/Tizen.NUI/src/internal/EXaml/Action/CreateInstanceAction.cs index e1728c0..bd45af1 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/CreateObjectAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/CreateInstanceAction.cs @@ -22,13 +22,16 @@ using Tizen.NUI.Binding.Internals; namespace Tizen.NUI.EXaml { - internal class CreateObjectAction : Action + internal class CreateInstanceAction : Action { - internal CreateObjectAction(Action parent) + internal CreateInstanceAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } + private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -66,11 +69,11 @@ namespace Tizen.NUI.EXaml int typeIndex = (int)getTypeIndexOp.Value; if (null == getParamListOp) { - LoadEXaml.Operations.Add(new CreateInstance(typeIndex)); + globalDataList.Operations.Add(new CreateInstance(globalDataList, typeIndex)); } else { - LoadEXaml.Operations.Add(new CreateInstance(typeIndex, getParamListOp.ValueList)); + globalDataList.Operations.Add(new CreateInstance(globalDataList, typeIndex, getParamListOp.ValueList)); } getParamListOp = null; } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/GetObjectByPropertyAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/GetObjectByPropertyAction.cs new file mode 100755 index 0000000..08e4089 --- /dev/null +++ b/src/Tizen.NUI/src/internal/EXaml/Action/GetObjectByPropertyAction.cs @@ -0,0 +1,87 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +using System; +using System.Collections.Generic; +using System.Text; +using Tizen.NUI.Binding; +using Tizen.NUI.Binding.Internals; + +namespace Tizen.NUI.EXaml +{ + internal class GetObjectByPropertyAction : Action + { + internal GetObjectByPropertyAction(GlobalDataList globalDataList, Action parent) + { + this.parent = parent; + this.globalDataList = globalDataList; + } + + private Action parent; + private GlobalDataList globalDataList; + + public Action DealChar(char c) + { + switch (c) + { + case ' ': + case '\n': + case '\r': + break; + + case '`': + parent?.OnActive(); + return parent; + + case '(': + childOp = new GetValueListAction(')', this); + return childOp; + } + + return this; + } + + public void Init() + { + } + + public void OnActive() + { + if (null != childOp) + { + int instanceIndex = (childOp.ValueList[0] as Instance).Index; + string propertyName = childOp.ValueList[1] as string; + globalDataList.Operations.Add(new GetObjectByProperty(globalDataList, instanceIndex, propertyName)); + } + + childOp = null; + } + + private GetValueListAction childOp; + + internal static object Root + { + get + { + return CreateInstance.Root; + } + set + { + CreateInstance.Root = value; + } + } + } +} diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/GetValueAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/GetValueAction.cs index e1889d8..da6717f 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/GetValueAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/GetValueAction.cs @@ -28,6 +28,7 @@ namespace Tizen.NUI.EXaml this.sign = sign; this.parent = parent; } + private char sign; private Action parent; diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/GetValueListAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/GetValueListAction.cs index 6ff0210..c565afc 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/GetValueListAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/GetValueListAction.cs @@ -27,6 +27,7 @@ namespace Tizen.NUI.EXaml this.sign = sign; this.parent = parent; } + private char sign; private Action parent; diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/RegisterXNameAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/RegisterXNameAction.cs index 5bcc234..c4bb433 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/RegisterXNameAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/RegisterXNameAction.cs @@ -25,12 +25,14 @@ namespace Tizen.NUI.EXaml { internal class RegisterXNameAction : Action { - public RegisterXNameAction(Action parent) + public RegisterXNameAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -65,7 +67,7 @@ namespace Tizen.NUI.EXaml object instance = childOp.ValueList[0]; string xName = childOp.ValueList[1] as string; - LoadEXaml.Operations.Add(new RegisterXName(instance, xName)); + globalDataList.Operations.Add(new RegisterXName(globalDataList, instance, xName)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/SetBindalbePropertyAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/SetBindalbePropertyAction.cs index 19315a7..c48cba5 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/SetBindalbePropertyAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/SetBindalbePropertyAction.cs @@ -25,12 +25,14 @@ namespace Tizen.NUI.EXaml { internal class SetBindalbePropertyAction : Action { - public SetBindalbePropertyAction(Action parent) + public SetBindalbePropertyAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -67,7 +69,7 @@ namespace Tizen.NUI.EXaml int instanceIndex = (childOp.ValueList[0] as Instance).Index; int bindalbePropertyIndex = (int)childOp.ValueList[1]; var value = childOp.ValueList[2]; - LoadEXaml.Operations.Add(new SetBindalbeProperty(instanceIndex, bindalbePropertyIndex, value)); + globalDataList.Operations.Add(new SetBindalbeProperty(globalDataList, instanceIndex, bindalbePropertyIndex, value)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/SetBindingAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/SetBindingAction.cs index d30d831..5036aaf 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/SetBindingAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/SetBindingAction.cs @@ -25,12 +25,14 @@ namespace Tizen.NUI.EXaml { internal class SetBindingAction : Action { - public SetBindingAction(Action parent) + public SetBindingAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -68,7 +70,7 @@ namespace Tizen.NUI.EXaml var propertyIndex = (int)childOp.ValueList[1]; int valueIndex = (childOp.ValueList[2] as Instance).Index; - LoadEXaml.Operations.Add(new SetBinding(instanceIndex, propertyIndex, valueIndex)); + globalDataList.Operations.Add(new SetBinding(globalDataList, instanceIndex, propertyIndex, valueIndex)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/SetDynamicResourceAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/SetDynamicResourceAction.cs index f73b757..6cffcc5 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/SetDynamicResourceAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/SetDynamicResourceAction.cs @@ -22,12 +22,14 @@ namespace Tizen.NUI.EXaml { internal class SetDynamicResourceAction : Action { - public SetDynamicResourceAction(Action parent) + public SetDynamicResourceAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -65,7 +67,7 @@ namespace Tizen.NUI.EXaml int propertyIndex = (int)childOp.ValueList[1]; string key = childOp.ValueList[2] as string; - LoadEXaml.Operations.Add(new SetDynamicResource(instanceIndex, propertyIndex, key)); + globalDataList.Operations.Add(new SetDynamicResource(globalDataList, instanceIndex, propertyIndex, key)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/SetPropertyAction.cs b/src/Tizen.NUI/src/internal/EXaml/Action/SetPropertyAction.cs index c3fa14f..2dc2c06 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/SetPropertyAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Action/SetPropertyAction.cs @@ -25,12 +25,14 @@ namespace Tizen.NUI.EXaml { internal class SetPropertyAction : Action { - public SetPropertyAction(Action parent) + public SetPropertyAction(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -67,7 +69,7 @@ namespace Tizen.NUI.EXaml int instanceIndex = (childOp.ValueList[0] as Instance).Index; int propertyIndex = (int)childOp.ValueList[1]; var value = childOp.ValueList[2]; - LoadEXaml.Operations.Add(new SetProperty(instanceIndex, propertyIndex, value)); + globalDataList.Operations.Add(new SetProperty(globalDataList, instanceIndex, propertyIndex, value)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Block/GatherAssembliesBlock.cs b/src/Tizen.NUI/src/internal/EXaml/Block/GatherAssembliesBlock.cs index 626ab49..0f7c90d 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Block/GatherAssembliesBlock.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Block/GatherAssembliesBlock.cs @@ -23,12 +23,14 @@ namespace Tizen.NUI.EXaml { internal class GatherAssembliesBlock : Action { - public GatherAssembliesBlock(Action parent) + public GatherAssembliesBlock(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -61,7 +63,7 @@ namespace Tizen.NUI.EXaml public void OnActive() { var readedAssemblyName = childOp.Value as string; - LoadEXaml.Operations.Add(new GatherAssembly(readedAssemblyName)); + globalDataList.Operations.Add(new GatherAssembly(globalDataList, readedAssemblyName)); childOp = null; } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Action/GatherBindablePropertiesAction.cs b/src/Tizen.NUI/src/internal/EXaml/Block/GatherBindablePropertiesBlock.cs similarity index 81% rename from src/Tizen.NUI/src/internal/EXaml/Action/GatherBindablePropertiesAction.cs rename to src/Tizen.NUI/src/internal/EXaml/Block/GatherBindablePropertiesBlock.cs index 6911851..1c9ca08 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Action/GatherBindablePropertiesAction.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Block/GatherBindablePropertiesBlock.cs @@ -21,14 +21,16 @@ using System.Text; namespace Tizen.NUI.EXaml { - internal class GatherBindablePropertiesAction : Action + internal class GatherBindablePropertiesBlock : Action { - public GatherBindablePropertiesAction(Action parent) + public GatherBindablePropertiesBlock(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -63,7 +65,7 @@ namespace Tizen.NUI.EXaml int typeIndex = int.Parse(childOp.ValueList[0] as string); string propertyName = childOp.ValueList[1] as string; - LoadEXaml.Operations.Add(new GatherBindableProperties(typeIndex, propertyName)); + globalDataList.Operations.Add(new GatherBindableProperties(globalDataList, typeIndex, propertyName)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Block/GatherEventsBlock.cs b/src/Tizen.NUI/src/internal/EXaml/Block/GatherEventsBlock.cs index 19dcb6e..0caeb7b 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Block/GatherEventsBlock.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Block/GatherEventsBlock.cs @@ -23,12 +23,14 @@ namespace Tizen.NUI.EXaml { internal class GatherEventsBlock : Action { - public GatherEventsBlock(Action parent) + public GatherEventsBlock(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -63,7 +65,7 @@ namespace Tizen.NUI.EXaml int typeIndex = int.Parse(childOp.ValueList[0] as string); string eventName = childOp.ValueList[1] as string; - LoadEXaml.Operations.Add(new GatherEvent(typeIndex, eventName)); + globalDataList.Operations.Add(new GatherEvent(globalDataList, typeIndex, eventName)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Block/GatherMethodsBlock.cs b/src/Tizen.NUI/src/internal/EXaml/Block/GatherMethodsBlock.cs index da89328..44b7dfb 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Block/GatherMethodsBlock.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Block/GatherMethodsBlock.cs @@ -30,12 +30,14 @@ namespace Tizen.NUI.EXaml { internal class GatherMethodsBlock : Action { - public GatherMethodsBlock(Action parent) + public GatherMethodsBlock(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -69,7 +71,7 @@ namespace Tizen.NUI.EXaml { int typeIndex = int.Parse(childOp.ValueList[0] as string); string name = childOp.ValueList[1] as string; - LoadEXaml.Operations.Add(new GatherMethod(typeIndex, name)); + globalDataList.Operations.Add(new GatherMethod(globalDataList, typeIndex, name)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Block/GatherPropertiesBlock.cs b/src/Tizen.NUI/src/internal/EXaml/Block/GatherPropertiesBlock.cs index 5ad6744..3ec8694 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Block/GatherPropertiesBlock.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Block/GatherPropertiesBlock.cs @@ -23,12 +23,14 @@ namespace Tizen.NUI.EXaml { internal class GatherPropertiesBlock : Action { - public GatherPropertiesBlock(Action parent) + public GatherPropertiesBlock(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -63,7 +65,7 @@ namespace Tizen.NUI.EXaml int typeIndex = int.Parse(childOp.ValueList[0] as string); string propertyName = childOp.ValueList[1] as string; - LoadEXaml.Operations.Add(new GatherProperty(typeIndex, propertyName)); + globalDataList.Operations.Add(new GatherProperty(globalDataList, typeIndex, propertyName)); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Block/GatherTypesBlock.cs b/src/Tizen.NUI/src/internal/EXaml/Block/GatherTypesBlock.cs index 872c35e..2f4a280 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Block/GatherTypesBlock.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Block/GatherTypesBlock.cs @@ -23,12 +23,14 @@ namespace Tizen.NUI.EXaml { internal class GatherTypesBlock : Action { - public GatherTypesBlock(Action parent) + public GatherTypesBlock(GlobalDataList globalDataList, Action parent) { this.parent = parent; + this.globalDataList = globalDataList; } private Action parent; + private GlobalDataList globalDataList; public Action DealChar(char c) { @@ -60,7 +62,7 @@ namespace Tizen.NUI.EXaml public void OnActive() { - LoadEXaml.Operations.Add(GatherType(childOp.ValueList)); + globalDataList.Operations.Add(GatherType(childOp.ValueList)); childOp = null; } @@ -78,11 +80,11 @@ namespace Tizen.NUI.EXaml genericTypeIndexs.Add((int)index); } - return new GatherType(assemblyIndex, typeName, genericTypeIndexs); + return new GatherType(globalDataList, assemblyIndex, typeName, genericTypeIndexs); } else { - return new GatherType(assemblyIndex, typeName); + return new GatherType(globalDataList, assemblyIndex, typeName); } } } diff --git a/src/Tizen.NUI/src/internal/EXaml/GlobalDataList.cs b/src/Tizen.NUI/src/internal/EXaml/GlobalDataList.cs new file mode 100755 index 0000000..1786e31 --- /dev/null +++ b/src/Tizen.NUI/src/internal/EXaml/GlobalDataList.cs @@ -0,0 +1,91 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using Tizen.NUI.Binding; + +namespace Tizen.NUI.EXaml +{ + internal class GlobalDataList + { + internal List Operations + { + get; + } = new List(); + + internal List GatheredInstances + { + get; + } = new List(); + + internal List ObjectsFromProperty + { + get; + } = new List(); + + internal List GatheredEvents + { + get; + } = new List(); + + internal List GatheredMethods + { + get; + } = new List(); + + internal List GatheredTypes + { + get; + } = new List(); + + internal List GatheredProperties + { + get; + } = new List(); + + internal List GatheredBindableProperties + { + get; + } = new List(); + + private List assemblyNameList; + internal List AssemblyNameList + { + get + { + if (null == assemblyNameList) + { + assemblyNameList = new List(); + assemblyNameList.Add(EXamlExtensions.MainAssembly.GetName()); + + var assemblyNames = EXamlExtensions.MainAssembly.GetReferencedAssemblies(); + + foreach (var name in assemblyNames) + { + assemblyNameList.Add(name); + } + } + + return assemblyNameList; + } + } + + internal List GatheredAssemblies = new List(); + } +} diff --git a/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs b/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs index aa0dbbd..2afc688 100755 --- a/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs +++ b/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs @@ -24,20 +24,24 @@ namespace Tizen.NUI.EXaml { internal static void Load(object view, string xaml) { - CreateObjectAction.Root = view; + var globalDataList = new GlobalDataList(); + + CreateInstanceAction.Root = view; int index = 0; - var createObject = new CreateObjectAction(null); - var addExistInstance = new AddExistInstanceAction(null); - var registerXName = new RegisterXNameAction(null); - var setProperty = new SetPropertyAction(null); - var addEvent = new AddEventAction(null); - var setBindalbeProperty = new SetBindalbePropertyAction(null); - var addObject = new CallAddMethodAction(null); - var setDynamicResourceAction = new SetDynamicResourceAction(null); - var addToResourceDictionaryAction = new AddToResourceDictionaryAction(null); - var setBindingAction = new SetBindingAction(null); + var createInstance = new CreateInstanceAction(globalDataList, null); + var getObjectByProperty = new GetObjectByPropertyAction(globalDataList, null); + var addExistInstance = new AddExistInstanceAction(globalDataList, null); + var registerXName = new RegisterXNameAction(globalDataList, null); + var setProperty = new SetPropertyAction(globalDataList, null); + var addToCollectionProperty = new AddToCollectionPropertyAction(globalDataList, null); + var addEvent = new AddEventAction(globalDataList, null); + var setBindalbeProperty = new SetBindalbePropertyAction(globalDataList, null); + var addObject = new CallAddMethodAction(globalDataList, null); + var setDynamicResourceAction = new SetDynamicResourceAction(globalDataList, null); + var addToResourceDictionaryAction = new AddToResourceDictionaryAction(globalDataList, null); + var setBindingAction = new SetBindingAction(globalDataList, null); foreach (char c in xaml) { @@ -49,44 +53,49 @@ namespace Tizen.NUI.EXaml case '<': if (0 == index) { - currentOp = new GatherAssembliesBlock(null); + currentOp = new GatherAssembliesBlock(globalDataList, null); currentOp.Init(); index++; } else if (1 == index) { - currentOp = new GatherTypesBlock(null); + currentOp = new GatherTypesBlock(globalDataList, null); currentOp.Init(); index++; } else if (2 == index) { - currentOp = new GatherPropertiesBlock(null); + currentOp = new GatherPropertiesBlock(globalDataList, null); currentOp.Init(); index++; } else if (3 == index) { - currentOp = new GatherEventsBlock(null); + currentOp = new GatherEventsBlock(globalDataList, null); currentOp.Init(); index++; } else if (4 == index) { - currentOp = new GatherMethodsBlock(null); + currentOp = new GatherMethodsBlock(globalDataList, null); currentOp.Init(); index++; } else if (5 == index) { - currentOp = new GatherBindablePropertiesAction(null); + currentOp = new GatherBindablePropertiesBlock(globalDataList, null); currentOp.Init(); index++; } break; case '{': - currentOp = createObject; + currentOp = createInstance; + currentOp.Init(); + break; + + case '`': + currentOp = getObjectByProperty; currentOp.Init(); break; @@ -105,6 +114,11 @@ namespace Tizen.NUI.EXaml currentOp.Init(); break; + case '~': + currentOp = addToCollectionProperty; + currentOp.Init(); + break; + case '#': currentOp = addEvent; currentOp.Init(); @@ -142,22 +156,12 @@ namespace Tizen.NUI.EXaml } } - foreach (var op in Operations) + foreach (var op in globalDataList.Operations) { op.Do(); } } - internal static List GatheredInstances - { - get; - } = new List(); - - internal static List Operations - { - get; - } = new List(); - private static Action currentOp = null; } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/AddEvent.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/AddEvent.cs index 4971a10..2202292 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/AddEvent.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/AddEvent.cs @@ -26,22 +26,25 @@ namespace Tizen.NUI.EXaml { internal class AddEvent : Operation { - public AddEvent(int instanceIndex, int elementIndex, int eventIndex, int valueIndex) + public AddEvent(GlobalDataList globalDataList, int instanceIndex, int elementIndex, int eventIndex, int valueIndex) { this.instanceIndex = instanceIndex; this.elementIndex = elementIndex; this.eventIndex = eventIndex; this.valueIndex = valueIndex; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - object instance = LoadEXaml.GatheredInstances[instanceIndex]; - object element = LoadEXaml.GatheredInstances[elementIndex]; - var eventInfo = GatherEvent.GatheredEvents[eventIndex]; + object instance = globalDataList.GatheredInstances[instanceIndex]; + object element = globalDataList.GatheredInstances[elementIndex]; + var eventInfo = globalDataList.GatheredEvents[eventIndex]; try { - var methodInfo = GatherMethod.GatheredMethods[valueIndex]; + var methodInfo = globalDataList.GatheredMethods[valueIndex]; eventInfo.AddEventHandler(instance, methodInfo.CreateDelegate(eventInfo.EventHandlerType, element)); } catch (ArgumentException ae) diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/AddToCollectionProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/AddToCollectionProperty.cs new file mode 100755 index 0000000..6494e55 --- /dev/null +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/AddToCollectionProperty.cs @@ -0,0 +1,60 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; +using Tizen.NUI.Binding.Internals; + +namespace Tizen.NUI.EXaml +{ + internal class AddToCollectionProperty : Operation + { + public AddToCollectionProperty(GlobalDataList globalDataList, int instanceIndex, object value) + { + this.instanceIndex = instanceIndex; + this.value = value; + this.globalDataList = globalDataList; + } + + private GlobalDataList globalDataList; + + public void Do() + { + var collection = globalDataList.ObjectsFromProperty[instanceIndex] as IList; + + if (null != collection) + { + if (value is Instance) + { + int valueIndex = (value as Instance).Index; + collection.Add(globalDataList.GatheredInstances[valueIndex]); + } + else + { + collection.Add(value); + } + } + } + + private int instanceIndex; + private object value; + } +} diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/AddToResourceDictionary.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/AddToResourceDictionary.cs index 90f04bb..e2187ab 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/AddToResourceDictionary.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/AddToResourceDictionary.cs @@ -26,17 +26,20 @@ namespace Tizen.NUI.EXaml { internal class AddToResourceDictionary : Operation { - internal AddToResourceDictionary(int instanceIndex, string key, object value) + internal AddToResourceDictionary(GlobalDataList globalDataList, int instanceIndex, string key, object value) { this.instanceIndex = instanceIndex; this.key = key; this.value = value; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var instance = LoadEXaml.GatheredInstances[instanceIndex] as ResourceDictionary; - var realValue = (value is Instance) ? LoadEXaml.GatheredInstances[(value as Instance).Index] : value; + var instance = globalDataList.GatheredInstances[instanceIndex] as ResourceDictionary; + var realValue = (value is Instance) ? globalDataList.GatheredInstances[(value as Instance).Index] : value; instance.Add(key, realValue); } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/CallAddMethod.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/CallAddMethod.cs index 22ff577..0a6068b 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/CallAddMethod.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/CallAddMethod.cs @@ -26,18 +26,21 @@ namespace Tizen.NUI.EXaml { internal class CallAddMethod : Operation { - public CallAddMethod(int parentIndex, int childIndex, int methodIndex) + public CallAddMethod(GlobalDataList globalDataList, int parentIndex, int childIndex, int methodIndex) { this.parentIndex = parentIndex; this.childIndex = childIndex; this.methodIndex = methodIndex; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - object parent = LoadEXaml.GatheredInstances[parentIndex]; - object child = LoadEXaml.GatheredInstances[childIndex]; - var method = GatherMethod.GatheredMethods[methodIndex]; + object parent = globalDataList.GatheredInstances[parentIndex]; + object child = globalDataList.GatheredInstances[childIndex]; + var method = globalDataList.GatheredMethods[methodIndex]; method.Invoke(parent, new object[] { child }); } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/CreateInstance.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/CreateInstance.cs index 5af0712..00d4405 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/CreateInstance.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/CreateInstance.cs @@ -26,25 +26,28 @@ namespace Tizen.NUI.EXaml { internal class CreateInstance : Operation { - public CreateInstance(int typeIndex, List paramList = null) + public CreateInstance(GlobalDataList globalDataList, int typeIndex, List paramList = null) { this.typeIndex = typeIndex; this.paramList = paramList; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - if (0 == LoadEXaml.GatheredInstances.Count && null != Root) + if (0 == globalDataList.GatheredInstances.Count && null != Root) { - LoadEXaml.GatheredInstances.Add(Root); + globalDataList.GatheredInstances.Add(Root); } else { - var type = GatherType.GatheredTypes[typeIndex]; + var type = globalDataList.GatheredTypes[typeIndex]; if (null == paramList) { - LoadEXaml.GatheredInstances.Add(Activator.CreateInstance(type)); + globalDataList.GatheredInstances.Add(Activator.CreateInstance(type)); } else { @@ -52,16 +55,16 @@ namespace Tizen.NUI.EXaml { if (paramList[i] is Instance) { - paramList[i] = LoadEXaml.GatheredInstances[(paramList[i] as Instance).Index]; + paramList[i] = globalDataList.GatheredInstances[(paramList[i] as Instance).Index]; } } - LoadEXaml.GatheredInstances.Add(Activator.CreateInstance(type, paramList.ToArray())); + globalDataList.GatheredInstances.Add(Activator.CreateInstance(type, paramList.ToArray())); } } - if (1 == LoadEXaml.GatheredInstances.Count) + if (1 == globalDataList.GatheredInstances.Count) { - var rootObject = LoadEXaml.GatheredInstances[0] as BindableObject; + var rootObject = globalDataList.GatheredInstances[0] as BindableObject; if (null != rootObject) { rootObject.IsCreateByXaml = true; diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherAssembly.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherAssembly.cs index 56b14d4..d45ed08 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherAssembly.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherAssembly.cs @@ -27,48 +27,28 @@ namespace Tizen.NUI.EXaml { internal class GatherAssembly : Operation { - public GatherAssembly(string assemblyName) + public GatherAssembly(GlobalDataList globalDataList, string assemblyName) { this.assemblyName = assemblyName; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { Assembly assembly = null; - foreach (var name in AssemblyNameList) + foreach (var name in globalDataList.AssemblyNameList) { if (name.FullName.StartsWith(assemblyName)) { assembly = Assembly.Load(name); - GatheredAssemblies.Add(assembly); + globalDataList.GatheredAssemblies.Add(assembly); break; } } } - private static List assemblyNameList; - private static List AssemblyNameList - { - get - { - if (null == assemblyNameList) - { - assemblyNameList = new List(); - assemblyNameList.Add(EXamlExtensions.MainAssembly.GetName()); - - var assemblyNames = EXamlExtensions.MainAssembly.GetReferencedAssemblies(); - - foreach (var name in assemblyNames) - { - assemblyNameList.Add(name); - } - } - - return assemblyNameList; - } - } - private string assemblyName; - internal static List GatheredAssemblies = new List(); } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherBindableProperties.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherBindableProperties.cs index 320d7ed..f077d7e 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherBindableProperties.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherBindableProperties.cs @@ -26,26 +26,28 @@ namespace Tizen.NUI.EXaml { internal class GatherBindableProperties : Operation { - public GatherBindableProperties(int typeIndex, string propertyName) + public GatherBindableProperties(GlobalDataList globalDataList, int typeIndex, string propertyName) { this.typeIndex = typeIndex; this.propertyName = propertyName; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var type = GatherType.GatheredTypes[typeIndex]; + var type = globalDataList.GatheredTypes[typeIndex]; var field = type.GetField(fi => fi.Name == propertyName && fi.IsStatic && fi.IsPublic); if (null == field) { field = type.GetField(fi => fi.Name == propertyName && fi.IsStatic && !fi.IsPublic); } - GatheredBindableProperties.Add(field.GetValue(null) as BindableProperty); + globalDataList.GatheredBindableProperties.Add(field.GetValue(null) as BindableProperty); } private int typeIndex; private string propertyName; - internal static List GatheredBindableProperties = new List(); } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherConvertedValue.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherConvertedValue.cs index f7dc442..48805d8 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherConvertedValue.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherConvertedValue.cs @@ -26,16 +26,19 @@ namespace Tizen.NUI.EXaml { internal class GatherConvertedValue : Operation { - public GatherConvertedValue(int converterIndex, string value) + public GatherConvertedValue(GlobalDataList globalDataList, int converterIndex, string value) { this.converterIndex = converterIndex; this.value = value; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var converter = LoadEXaml.GatheredInstances[converterIndex] as TypeConverter; - LoadEXaml.GatheredInstances.Add(converter.ConvertFromInvariantString(value)); + var converter = globalDataList.GatheredInstances[converterIndex] as TypeConverter; + globalDataList.GatheredInstances.Add(converter.ConvertFromInvariantString(value)); } private int converterIndex; diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEnumValue.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEnumValue.cs index 28c6482..edeab5b 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEnumValue.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEnumValue.cs @@ -26,16 +26,19 @@ namespace Tizen.NUI.EXaml { internal class GatherEnumValue : Operation { - public GatherEnumValue(int typeIndex, string value) + public GatherEnumValue(GlobalDataList globalDataList, int typeIndex, string value) { this.typeIndex = typeIndex; this.value = value; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var enumType = GatherType.GatheredTypes[typeIndex]; - LoadEXaml.GatheredInstances.Add(Enum.Parse(enumType, value)); + var enumType = globalDataList.GatheredTypes[typeIndex]; + globalDataList.GatheredInstances.Add(Enum.Parse(enumType, value)); } private int typeIndex; diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEvent.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEvent.cs index 31f957d..cc1509e 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEvent.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherEvent.cs @@ -26,20 +26,22 @@ namespace Tizen.NUI.EXaml { internal class GatherEvent : Operation { - public GatherEvent(int typeIndex, string eventName) + public GatherEvent(GlobalDataList globalDataList, int typeIndex, string eventName) { this.typeIndex = typeIndex; this.eventName = eventName; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var type = GatherType.GatheredTypes[typeIndex]; - GatheredEvents.Add(type.GetEvent(eventName)); + var type = globalDataList.GatheredTypes[typeIndex]; + globalDataList.GatheredEvents.Add(type.GetEvent(eventName)); } private int typeIndex; private string eventName; - internal static List GatheredEvents = new List(); } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherMethod.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherMethod.cs index 6028840..452d44a 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherMethod.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherMethod.cs @@ -27,21 +27,23 @@ namespace Tizen.NUI.EXaml { internal class GatherMethod : Operation { - public GatherMethod(int typeIndex, string methodName) + public GatherMethod(GlobalDataList globalDataList, int typeIndex, string methodName) { this.typeIndex = typeIndex; this.methodName = methodName; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var type = GatherType.GatheredTypes[typeIndex]; + var type = globalDataList.GatheredTypes[typeIndex]; var method = type.GetRuntimeMethods().FirstOrDefault(mi => mi.Name == methodName); - GatheredMethods.Add(method); + globalDataList.GatheredMethods.Add(method); } private int typeIndex; private string methodName; - internal static List GatheredMethods = new List(); } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs index 3e2c7d7..7da82de 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs @@ -26,20 +26,22 @@ namespace Tizen.NUI.EXaml { internal class GatherProperty : Operation { - public GatherProperty(int typeIndex, string propertyName) + public GatherProperty(GlobalDataList globalDataList, int typeIndex, string propertyName) { this.typeIndex = typeIndex; this.propertyName = propertyName; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var type = GatherType.GatheredTypes[typeIndex]; - GatheredProperties.Add(type.GetProperty(propertyName)); + var type = globalDataList.GatheredTypes[typeIndex]; + globalDataList.GatheredProperties.Add(type.GetProperty(propertyName)); } private int typeIndex; private string propertyName; - internal static List GatheredProperties = new List(); } } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherType.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherType.cs index e05dbb3..4aa1145 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherType.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherType.cs @@ -26,16 +26,19 @@ namespace Tizen.NUI.EXaml { internal class GatherType : Operation { - public GatherType(int assemblyIndex, string typeName, List genericTypeIndexs = null) + public GatherType(GlobalDataList globalDataList, int assemblyIndex, string typeName, List genericTypeIndexs = null) { this.assemblyIndex = assemblyIndex; this.typeName = typeName; this.genericTypeIndexs = genericTypeIndexs; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var assembly = GatherAssembly.GatheredAssemblies[assemblyIndex]; + var assembly = globalDataList.GatheredAssemblies[assemblyIndex]; var type = assembly.GetType(typeName); if (null != genericTypeIndexs) @@ -44,20 +47,17 @@ namespace Tizen.NUI.EXaml for (int i = 0; i < genericTypeIndexs.Count; i++) { - args[i] = GatheredTypes[genericTypeIndexs[i]]; + args[i] = globalDataList.GatheredTypes[genericTypeIndexs[i]]; } type = type.MakeGenericType(args); } - GatheredTypes.Add(type); + globalDataList.GatheredTypes.Add(type); } private int assemblyIndex; private string typeName; private List genericTypeIndexs; - - internal static List GatheredTypes = new List(); } - } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs new file mode 100755 index 0000000..e337d9e --- /dev/null +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs @@ -0,0 +1,51 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; +using Tizen.NUI.Binding.Internals; + +namespace Tizen.NUI.EXaml +{ + internal class GetObjectByProperty : Operation + { + public GetObjectByProperty(GlobalDataList globalDataList, int instanceIndex, string propertyName) + { + this.instanceIndex = instanceIndex; + this.propertyName = propertyName; + this.globalDataList = globalDataList; + } + + private GlobalDataList globalDataList; + + public void Do() + { + var instance = globalDataList.GatheredInstances[instanceIndex]; + var property = instance.GetType().GetProperty(propertyName); + + var @object = property.GetMethod.Invoke(instance, Array.Empty()); + globalDataList.ObjectsFromProperty.Add(@object); + } + + private int instanceIndex; + + private string propertyName; + } +} diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/RegisterXName.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/RegisterXName.cs index 0b23a7f..4772d45 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/RegisterXName.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/RegisterXName.cs @@ -26,18 +26,21 @@ namespace Tizen.NUI.EXaml { internal class RegisterXName : Operation { - public RegisterXName(object instance, string name) + public RegisterXName(GlobalDataList globalDataList, object instance, string name) { this.instance = instance; this.name = name; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { object realInstance = null; if (instance is Instance) { - realInstance = LoadEXaml.GatheredInstances[(instance as Instance).Index]; + realInstance = globalDataList.GatheredInstances[(instance as Instance).Index]; } else { diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/SetBindalbeProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/SetBindalbeProperty.cs index 48e0bcb..0ce1ebb 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/SetBindalbeProperty.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/SetBindalbeProperty.cs @@ -26,25 +26,28 @@ namespace Tizen.NUI.EXaml { internal class SetBindalbeProperty : Operation { - public SetBindalbeProperty(int instanceIndex, int bindalbePropertyIndex, object value) + public SetBindalbeProperty(GlobalDataList globalDataList, int instanceIndex, int bindalbePropertyIndex, object value) { this.instanceIndex = instanceIndex; this.bindalbePropertyIndex = bindalbePropertyIndex; this.value = value; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var instance = LoadEXaml.GatheredInstances[instanceIndex] as BindableObject; + var instance = globalDataList.GatheredInstances[instanceIndex] as BindableObject; if (null != instance) { - var property = GatherBindableProperties.GatheredBindableProperties[bindalbePropertyIndex]; + var property = globalDataList.GatheredBindableProperties[bindalbePropertyIndex]; if (value is Instance) { int valueIndex = (value as Instance).Index; - instance.SetValue(property, LoadEXaml.GatheredInstances[valueIndex]); + instance.SetValue(property, globalDataList.GatheredInstances[valueIndex]); } else { diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/SetBinding.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/SetBinding.cs index e634fb3..ea45641 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/SetBinding.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/SetBinding.cs @@ -26,18 +26,21 @@ namespace Tizen.NUI.EXaml { internal class SetBinding : Operation { - public SetBinding(int instanceIndex, int bindablePropertyIndex, int valueIndex) + public SetBinding(GlobalDataList globalDataList, int instanceIndex, int bindablePropertyIndex, int valueIndex) { this.instanceIndex = instanceIndex; this.bindablePropertyIndex = bindablePropertyIndex; this.valueIndex = valueIndex; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - BindableObject bindableObject = LoadEXaml.GatheredInstances[instanceIndex] as BindableObject; - var property = GatherBindableProperties.GatheredBindableProperties[bindablePropertyIndex]; - var value = LoadEXaml.GatheredInstances[valueIndex] as BindingBase; + BindableObject bindableObject = globalDataList.GatheredInstances[instanceIndex] as BindableObject; + var property = globalDataList.GatheredBindableProperties[bindablePropertyIndex]; + var value = globalDataList.GatheredInstances[valueIndex] as BindingBase; bindableObject?.SetBinding(property, value); } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/SetDynamicResource.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/SetDynamicResource.cs index 1f567f1..b650fc0 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/SetDynamicResource.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/SetDynamicResource.cs @@ -26,17 +26,20 @@ namespace Tizen.NUI.EXaml { internal class SetDynamicResource : Operation { - public SetDynamicResource(int instanceIndex, int propertyIndex, string key) + public SetDynamicResource(GlobalDataList globalDataList, int instanceIndex, int propertyIndex, string key) { this.instanceIndex = instanceIndex; this.propertyIndex = propertyIndex; this.key = key; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - var instance = LoadEXaml.GatheredInstances[instanceIndex] as BindableObject; - var property = GatherBindableProperties.GatheredBindableProperties[propertyIndex]; + var instance = globalDataList.GatheredInstances[instanceIndex] as BindableObject; + var property = globalDataList.GatheredBindableProperties[propertyIndex]; instance.SetDynamicResource(property, key); } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs index 1b21e89..1e3e92e 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs @@ -26,27 +26,25 @@ namespace Tizen.NUI.EXaml { internal class SetProperty : Operation { - public SetProperty(int instanceIndex, int propertyIndex, object value) + public SetProperty(GlobalDataList globalDataList, int instanceIndex, int propertyIndex, object value) { this.instanceIndex = instanceIndex; this.propertyIndex = propertyIndex; this.value = value; + this.globalDataList = globalDataList; } + private GlobalDataList globalDataList; + public void Do() { - object instance = LoadEXaml.GatheredInstances[instanceIndex]; - var property = GatherProperty.GatheredProperties[propertyIndex]; - - if (property == null) - { - return; - } + object instance = globalDataList.GatheredInstances[instanceIndex]; + var property = globalDataList.GatheredProperties[propertyIndex]; if (value is Instance) { int valueIndex = (value as Instance).Index; - property.SetMethod.Invoke(instance, new object[] { LoadEXaml.GatheredInstances[valueIndex] }); + property.SetMethod.Invoke(instance, new object[] { globalDataList.GatheredInstances[valueIndex] }); } else { diff --git a/src/Tizen.NUI/src/public/EXaml/EXamlExtensions.cs b/src/Tizen.NUI/src/public/EXaml/EXamlExtensions.cs index 13ddacf..9d752c9 100755 --- a/src/Tizen.NUI/src/public/EXaml/EXamlExtensions.cs +++ b/src/Tizen.NUI/src/public/EXaml/EXamlExtensions.cs @@ -31,6 +31,7 @@ namespace Tizen.NUI.EXaml [EditorBrowsable(EditorBrowsableState.Never)] public static TXaml LoadFromEXamlPath(this TXaml view, string path) { + MainAssembly = view.GetType().Assembly; //This EXaml file will be converted by Tizen.NUI.XamlBuild from the .xaml string xamlScript = GetXamlFromPath(path); LoadEXaml.Load(view, xamlScript); @@ -39,7 +40,7 @@ namespace Tizen.NUI.EXaml /// Internal used, will never be opened. [EditorBrowsable(EditorBrowsableState.Never)] - public static TXaml LoadFromEXamlPath(this TXaml view, Type callingType) + public static T LoadFromEXamlPath(this T view, Type callingType) { if (null == callingType) { @@ -77,6 +78,22 @@ namespace Tizen.NUI.EXaml return view; } + /// Used for TCT and TC coverage, will never be opened. + [EditorBrowsable(EditorBrowsableState.Never)] + public static T LoadFromEXaml(this T view, string eXamlStr) + { + if (null == eXamlStr) + { + return view; + } + + MainAssembly = view.GetType().Assembly; + + LoadEXaml.Load(view, eXamlStr); + + return view; + } + /// Internal used, will never be opened. [EditorBrowsable(EditorBrowsableState.Never)] public static Assembly MainAssembly