{
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)
{
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));
}
}
}
{
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)
{
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;
private char sign;
private GetValueListAction getValueListOp;
-
- internal static object Root
- {
- get;
- set;
- }
}
}
--- /dev/null
+/*
+ * 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));
+ }
+ }
+ }
+}
{
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)
{
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));
}
}
}
{
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)
{
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));
}
}
}
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)
{
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;
}
--- /dev/null
+/*
+ * 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;
+ }
+ }
+ }
+}
this.sign = sign;
this.parent = parent;
}
+
private char sign;
private Action parent;
this.sign = sign;
this.parent = parent;
}
+
private char sign;
private Action parent;
{
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)
{
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));
}
}
}
{
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)
{
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));
}
}
}
{
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)
{
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));
}
}
}
{
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)
{
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));
}
}
}
{
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)
{
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));
}
}
}
{
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)
{
public void OnActive()
{
var readedAssemblyName = childOp.Value as string;
- LoadEXaml.Operations.Add(new GatherAssembly(readedAssemblyName));
+ globalDataList.Operations.Add(new GatherAssembly(globalDataList, readedAssemblyName));
childOp = null;
}
}
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)
{
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));
}
}
}
{
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)
{
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));
}
}
}
{
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)
{
{
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));
}
}
}
{
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)
{
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));
}
}
}
{
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)
{
public void OnActive()
{
- LoadEXaml.Operations.Add(GatherType(childOp.ValueList));
+ globalDataList.Operations.Add(GatherType(childOp.ValueList));
childOp = null;
}
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);
}
}
}
--- /dev/null
+/*
+ * 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<Operation> Operations
+ {
+ get;
+ } = new List<Operation>();
+
+ internal List<object> GatheredInstances
+ {
+ get;
+ } = new List<object>();
+
+ internal List<object> ObjectsFromProperty
+ {
+ get;
+ } = new List<object>();
+
+ internal List<EventInfo> GatheredEvents
+ {
+ get;
+ } = new List<EventInfo>();
+
+ internal List<MethodInfo> GatheredMethods
+ {
+ get;
+ } = new List<MethodInfo>();
+
+ internal List<Type> GatheredTypes
+ {
+ get;
+ } = new List<Type>();
+
+ internal List<PropertyInfo> GatheredProperties
+ {
+ get;
+ } = new List<PropertyInfo>();
+
+ internal List<BindableProperty> GatheredBindableProperties
+ {
+ get;
+ } = new List<BindableProperty>();
+
+ private List<AssemblyName> assemblyNameList;
+ internal List<AssemblyName> AssemblyNameList
+ {
+ get
+ {
+ if (null == assemblyNameList)
+ {
+ assemblyNameList = new List<AssemblyName>();
+ assemblyNameList.Add(EXamlExtensions.MainAssembly.GetName());
+
+ var assemblyNames = EXamlExtensions.MainAssembly.GetReferencedAssemblies();
+
+ foreach (var name in assemblyNames)
+ {
+ assemblyNameList.Add(name);
+ }
+ }
+
+ return assemblyNameList;
+ }
+ }
+
+ internal List<Assembly> GatheredAssemblies = new List<Assembly>();
+ }
+}
{
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)
{
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;
currentOp.Init();
break;
+ case '~':
+ currentOp = addToCollectionProperty;
+ currentOp.Init();
+ break;
+
case '#':
currentOp = addEvent;
currentOp.Init();
}
}
- foreach (var op in Operations)
+ foreach (var op in globalDataList.Operations)
{
op.Do();
}
}
- internal static List<object> GatheredInstances
- {
- get;
- } = new List<object>();
-
- internal static List<Operation> Operations
- {
- get;
- } = new List<Operation>();
-
private static Action currentOp = null;
}
}
{
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)
--- /dev/null
+/*
+ * 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;
+ }
+}
{
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);
}
{
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 });
}
{
internal class CreateInstance : Operation
{
- public CreateInstance(int typeIndex, List<object> paramList = null)
+ public CreateInstance(GlobalDataList globalDataList, int typeIndex, List<object> 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
{
{
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;
{
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<AssemblyName> assemblyNameList;
- private static List<AssemblyName> AssemblyNameList
- {
- get
- {
- if (null == assemblyNameList)
- {
- assemblyNameList = new List<AssemblyName>();
- 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<Assembly> GatheredAssemblies = new List<Assembly>();
}
}
{
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<BindableProperty> GatheredBindableProperties = new List<BindableProperty>();
}
}
{
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;
{
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;
{
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<EventInfo> GatheredEvents = new List<EventInfo>();
}
}
{
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<MethodInfo> GatheredMethods = new List<MethodInfo>();
}
}
{
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<PropertyInfo> GatheredProperties = new List<PropertyInfo>();
}
}
{
internal class GatherType : Operation
{
- public GatherType(int assemblyIndex, string typeName, List<int> genericTypeIndexs = null)
+ public GatherType(GlobalDataList globalDataList, int assemblyIndex, string typeName, List<int> 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)
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<int> genericTypeIndexs;
-
- internal static List<Type> GatheredTypes = new List<Type>();
}
-
}
--- /dev/null
+/*
+ * 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<object>());
+ globalDataList.ObjectsFromProperty.Add(@object);
+ }
+
+ private int instanceIndex;
+
+ private string propertyName;
+ }
+}
{
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
{
{
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
{
{
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);
}
{
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);
}
{
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
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static TXaml LoadFromEXamlPath<TXaml>(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);
/// Internal used, will never be opened.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static TXaml LoadFromEXamlPath<TXaml>(this TXaml view, Type callingType)
+ public static T LoadFromEXamlPath<T>(this T view, Type callingType)
{
if (null == callingType)
{
return view;
}
+ /// Used for TCT and TC coverage, will never be opened.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static T LoadFromEXaml<T>(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