--- /dev/null
+/*
+ * Copyright(c) 2022 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 Mono.Cecil;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.NUI.EXaml.Build.Tasks;
+
+namespace Tizen.NUI.EXaml
+{
+ internal class EXamlCreateResourceDictionary : EXamlCreateObject
+ {
+ public EXamlCreateResourceDictionary(EXamlContext context, TypeReference type, string content = null) : base(context, null, type)
+ {
+ if (null != content)
+ {
+ Content = content;
+ }
+ }
+
+ private string content;
+ public string Content
+ {
+ get
+ {
+ return content;
+ }
+ set
+ {
+ content = value;
+ indexRangeOfContent = eXamlContext.GetLongStringIndexs(content);
+ }
+ }
+
+ private (int, int) indexRangeOfContent;
+
+ internal override string Write()
+ {
+ if (false == IsValid)
+ {
+ return "";
+ }
+
+ string ret = String.Format("({0} ({1} {2} {3}))\n",
+ eXamlContext.GetValueString((int)EXamlOperationType.CreateResourceDictionary),
+ eXamlContext.GetValueString(eXamlContext.GetTypeIndex(Type)),
+ eXamlContext.GetValueString(indexRangeOfContent.Item1),
+ eXamlContext.GetValueString(indexRangeOfContent.Item2));
+
+ return ret;
+ }
+ }
+}
+
{
internal class EXamlContext
{
- public EXamlContext(TypeDefinition type, ModuleDefinition module, FieldDefinition parentContextValues = null)
+ public EXamlContext(TypeDefinition type, ModuleDefinition module, string embeddedResourceNameSpace, FieldDefinition parentContextValues = null)
{
Values = new Dictionary<INode, object>();
Variables = new Dictionary<IElementNode, VariableDefinition>();
ParentContextValues = parentContextValues;
Type = type;
Module = module;
+ EmbeddedResourceNameSpace = embeddedResourceNameSpace;
}
public Dictionary<INode, object> Values { get; private set; }
public ModuleDefinition Module { get; private set; }
+ public string EmbeddedResourceNameSpace { get; }
+
public List<EXamlOperation> eXamlOperations = new List<EXamlOperation>();
private string GetAssemblyName(AssemblyDefinition assembly)
using static Mono.Cecil.Cil.OpCodes;
using Tizen.NUI.Xaml.Build.Tasks;
using ArrayExtension = Tizen.NUI.Xaml.Build.Tasks.ArrayExtension;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.EXaml.Build.Tasks
{
var accordingType = this.GetType().Assembly.GetType(typeref.FullName);
- if (null != accordingType && accordingType != typeof(Binding.Setter))
+ if (null != accordingType && accordingType != typeof(Binding.Setter) && accordingType != typeof(ResourceDictionary))
{
Context.Values[node] = new EXamlCreateObject(Context, Activator.CreateInstance(accordingType), typeref);
}
var fieldRef = bindableProperty.DeclaringType.ResolveCached().Fields.FirstOrDefault(a => a.FullName == bindableProperty.FullName);
context.Values[node] = new EXamlCreateObject(context, bindableProperty.DeclaringType, fieldRef, null);
}
+ else if ("Tizen.NUI.Binding.ResourceDictionary" == propertyType.FullName)
+ {
+ context.Values[node] = GetResourceDictionaryByXaml(parent, node, context, iXmlLineInfo);
+ }
else
{
var converterType = valueNode.GetConverterType(new ICustomAttributeProvider[] { property, propertyType.ResolveCached() });
return false;
}
- static void SetDataTemplate(ElementNode parentNode, ElementNode rootnode, EXamlContext parentContext,
- IXmlLineInfo xmlLineInfo)
+ static void SetDataTemplate(ElementNode parentNode, ElementNode rootnode, EXamlContext parentContext, IXmlLineInfo xmlLineInfo)
{
var typeref = parentContext.Module.ImportReference(rootnode.XmlType.GetTypeReference(XmlTypeExtensions.ModeOfGetType.Both, parentContext.Module, rootnode));
- var visitorContext = new EXamlContext(typeref.ResolveCached(), typeref.Module);
+ var visitorContext = new EXamlContext(typeref.ResolveCached(), typeref.Module, parentContext.EmbeddedResourceNameSpace);
rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null);
rootnode.Accept(new EXamlExpandMarkupsVisitor(visitorContext), null);
}
}
+ static EXamlCreateResourceDictionary GetResourceDictionaryByXaml(EXamlCreateObject parentObject, INode nodeOfXaml, EXamlContext parentContext, IXmlLineInfo xmlLineInfo)
+ {
+ var module = parentContext.Module;
+
+ string xamlName = "";
+
+ if (nodeOfXaml is ValueNode valueNode)
+ {
+ xamlName = valueNode.Value as string;
+ }
+
+ EmbeddedResource matchedResource = null;
+
+ foreach (var resource in module.Resources.OfType<EmbeddedResource>())
+ {
+ if (resource.Name.StartsWith(parentContext.EmbeddedResourceNameSpace) && resource.Name.EndsWith(xamlName))
+ {
+ matchedResource = resource;
+ break;
+ }
+ }
+
+ if (null == matchedResource)
+ {
+ foreach (var resource in module.Resources.OfType<EmbeddedResource>())
+ {
+ if (resource.Name.EndsWith(xamlName))
+ {
+ matchedResource = resource;
+ break;
+ }
+ }
+ }
+
+ if (null != matchedResource)
+ {
+ string classname;
+
+ if (matchedResource.IsResourceDictionaryXaml(module, out classname))
+ {
+ int lastIndex = classname.LastIndexOf('.');
+ var realClassName = classname.Substring(lastIndex + 1);
+ var typeref = XmlTypeExtensions.GetTypeReference(realClassName, module, nodeOfXaml as BaseNode, XmlTypeExtensions.ModeOfGetType.Both);
+
+ var visitorContext = new EXamlContext(typeref.ResolveCached(), typeref.Module, parentContext.EmbeddedResourceNameSpace);
+ var rootnode = XamlTask.ParseXaml(matchedResource.GetResourceStream(), typeref);
+
+ var rootInstance = new EXamlCreateObject(visitorContext, null, typeref);
+ visitorContext.Values[rootnode] = rootInstance;
+
+ rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null);
+ rootnode.Accept(new EXamlExpandMarkupsVisitor(visitorContext), null);
+ rootnode.Accept(new PruneIgnoredNodesVisitor(), null);
+ rootnode.Accept(new EXamlCreateObjectVisitor(visitorContext), null);
+ rootnode.Accept(new EXamlSetNamescopesAndRegisterNamesVisitor(visitorContext), null);
+ rootnode.Accept(new EXamlSetFieldVisitor(visitorContext), null);
+ rootnode.Accept(new EXamlSetResourcesVisitor(visitorContext), null);
+ rootnode.Accept(new EXamlSetPropertiesVisitor(visitorContext, true), null);
+
+ foreach (var pair in visitorContext.resourceDictionary)
+ {
+ parentContext.resourceDictionary.Add(pair.Key, pair.Value);
+ }
+
+ return new EXamlCreateResourceDictionary(parentContext, typeref, visitorContext.GenerateEXamlString());
+ }
+ }
+
+ return null;
+ }
+
bool TrySetRuntimeName(XmlName propertyName, EXamlCreateObject variableDefinition, ValueNode node)
{
if (null == variableDefinition)
RegisterXName,
GetLongString,
CreateDPObject,
+ CreateResourceDictionary,
MAX
}
}
using Tizen.NUI.Xaml.Build.Tasks;
using Tizen.NUI.Xaml;
using Tizen.NUI.Binding;
+using System.Linq;
namespace Tizen.NUI.Xaml.Core.XamlC
{
{
public IEnumerable<Instruction> ConvertFromString(string value, ILContext context, BaseNode node)
{
- var module = context.Body.Method.Module;
- var body = context.Body;
-
- INode rootNode = node;
- while (!(rootNode is ILRootNode))
- rootNode = rootNode.Parent;
-
- var rdNode = node.Parent as IElementNode;
-
- var rootTargetPath = XamlTask.GetPathForType(module, ((ILRootNode)rootNode).TypeReference);
- var uri = new Uri(value, UriKind.Relative);
-
- var resourcePath = ResourceDictionary.RDSourceTypeConverter.GetResourcePath(uri, rootTargetPath);
-
- //fail early
- var resourceId = XamlTask.GetResourceIdForPath(module, resourcePath);
- if (resourceId == null)
- throw new XamlParseException($"Resource '{value}' not found.", node);
-
-
- //abuse the converter, produce some side effect, but leave the stack untouched
- //public void SetAndLoadSource(Uri value, string resourceID, Assembly assembly, System.Xml.IXmlLineInfo lineInfo)
- yield return Create(Ldloc, context.Variables[rdNode]); //the resourcedictionary
- foreach (var instruction in (new UriTypeConverter()).ConvertFromString(value, context, node))
- yield return instruction; //the Uri
-
- //keep the Uri for later
- yield return Create(Dup);
- var uriVarDef = new VariableDefinition(module.ImportReference(("System", "System", "Uri")));
- body.Variables.Add(uriVarDef);
- yield return Create(Stloc, uriVarDef);
- yield return Create(Ldstr, resourcePath); //resourcePath
- yield return Create(Ldtoken, module.ImportReference(((ILRootNode)rootNode).TypeReference));
- yield return Create(Call, module.ImportMethodReference(("mscorlib", "System", "Type"), methodName: "GetTypeFromHandle", parameterTypes: new[] { ("mscorlib", "System", "RuntimeTypeHandle") }, isStatic: true));
- yield return Create(Call, module.ImportMethodReference(("mscorlib", "System.Reflection", "IntrospectionExtensions"), methodName: "GetTypeInfo", parameterTypes: new[] { ("mscorlib", "System", "Type") }, isStatic: true));
- yield return Create(Callvirt, module.ImportPropertyGetterReference(("mscorlib", "System.Reflection", "TypeInfo"), propertyName: "Assembly", flatten: true));
-
- foreach (var instruction in node.PushXmlLineInfo(context))
- yield return instruction; //lineinfo
- yield return Create(Callvirt, module.ImportMethodReference((XamlTask.bindingAssemblyName, XamlTask.bindingNameSpace, "ResourceDictionary"),
- methodName: "SetAndLoadSource",
- parameterTypes: new[] { ("System", "System", "Uri"), ("mscorlib", "System", "String"), ("mscorlib", "System.Reflection", "Assembly"), ("System.Xml.ReaderWriter", "System.Xml", "IXmlLineInfo") }));
- //ldloc the stored uri as return value
- yield return Create(Ldloc, uriVarDef);
+ var module = context.Module;
+
+ EmbeddedResource matchedResource = null;
+
+ foreach (var resource in module.Resources.OfType<EmbeddedResource>())
+ {
+ if (resource.Name.StartsWith(context.EmbeddedResourceNameSpace) && resource.Name.EndsWith(value))
+ {
+ matchedResource = resource;
+ break;
+ }
+ }
+
+ if (null == matchedResource)
+ {
+ foreach (var resource in module.Resources.OfType<EmbeddedResource>())
+ {
+ if (resource.Name.EndsWith(value))
+ {
+ matchedResource = resource;
+ break;
+ }
+ }
+ }
+
+ if (null != matchedResource)
+ {
+ string classname;
+ if (matchedResource.IsResourceDictionaryXaml(module, out classname))
+ {
+ int lastIndex = classname.LastIndexOf('.');
+ var realClassName = classname.Substring(lastIndex + 1);
+ var typeref = XmlTypeExtensions.GetTypeReference(realClassName, module, node, XmlTypeExtensions.ModeOfGetType.Both);
+
+ var typeName = matchedResource.Name.Replace('.', '_');
+ var typeDefOfGetResource = module.Types.FirstOrDefault(type => type.FullName == "GetResource." + typeName);
+ if (null != typeDefOfGetResource)
+ {
+ module.Types.Remove(typeDefOfGetResource);
+ typeDefOfGetResource = null;
+ }
+
+ if (null == typeDefOfGetResource)
+ {
+ typeDefOfGetResource = new TypeDefinition("GetResource", typeName, TypeAttributes.NotPublic);
+ typeDefOfGetResource.BaseType = typeref;
+ module.Types.Add(typeDefOfGetResource);
+
+ typeDefOfGetResource.AddDefaultConstructor(typeref);
+ }
+
+ var methodName = "GetResource";
+ var methodOfGetResource = typeDefOfGetResource.Methods.FirstOrDefault(m => m.Name == methodName);
+
+ if (null == methodOfGetResource)
+ {
+ methodOfGetResource = new MethodDefinition(methodName, MethodAttributes.Public, typeref);
+ typeDefOfGetResource.Methods.Add(methodOfGetResource);
+ }
+
+ var constructor = typeDefOfGetResource.Methods.FirstOrDefault(m => m.IsConstructor);
+
+ if (null != constructor)
+ {
+ constructor.Body.Instructions.Insert(constructor.Body.Instructions.Count - 1, Instruction.Create(OpCodes.Ldarg_0));
+ constructor.Body.Instructions.Insert(constructor.Body.Instructions.Count - 1, Instruction.Create(OpCodes.Call, methodOfGetResource));
+ constructor.Body.Instructions.Insert(constructor.Body.Instructions.Count - 1, Instruction.Create(OpCodes.Pop));
+ }
+
+ var rootnode = XamlTask.ParseXaml(matchedResource.GetResourceStream(), typeref);
+
+ Exception exception;
+ TryCoreCompile(methodOfGetResource, rootnode, context.EmbeddedResourceNameSpace, out exception);
+
+ yield return Create(Newobj, constructor);
+ }
+ }
}
internal static string GetPathForType(ModuleDefinition module, TypeReference type)
{
- foreach (var ca in type.Module.GetCustomAttributes()) {
+ foreach (var ca in type.Module.GetCustomAttributes())
+ {
if (!TypeRefComparer.Default.Equals(ca.AttributeType, module.ImportReference((XamlTask.xamlAssemblyName, XamlTask.xamlNameSpace, "XamlResourceIdAttribute"))))
continue;
if (!TypeRefComparer.Default.Equals(ca.ConstructorArguments[2].Value as TypeReference, type))
}
return null;
}
+
+ private bool TryCoreCompile(MethodDefinition initComp, ILRootNode rootnode, string resourceName, out Exception exception)
+ {
+ try
+ {
+ var body = new MethodBody(initComp);
+ var module = body.Method.Module;
+ var type = initComp.DeclaringType;
+
+ body.InitLocals = true;
+ var il = body.GetILProcessor();
+ il.Emit(OpCodes.Ldarg_0);
+ var resourcePath = GetPathForType(module, type);
+
+ il.Emit(Nop);
+
+ List<Instruction> insOfAddEvent = new List<Instruction>();
+
+ var visitorContext = new ILContext(il, body, insOfAddEvent, module, resourceName);
+
+ rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null);
+ rootnode.Accept(new Tizen.NUI.Xaml.Build.Tasks.ExpandMarkupsVisitor(visitorContext), null);
+ rootnode.Accept(new PruneIgnoredNodesVisitor(), null);
+ rootnode.Accept(new CreateObjectVisitor(visitorContext), null);
+
+ rootnode.Accept(new SetNamescopesAndRegisterNamesVisitor(visitorContext), null);
+ rootnode.Accept(new SetFieldVisitor(visitorContext), null);
+ rootnode.Accept(new SetResourcesVisitor(visitorContext), null);
+ rootnode.Accept(new SetPropertiesVisitor(visitorContext, true), null);
+
+ il.Emit(Ret);
+ initComp.Body = body;
+ exception = null;
+ return true;
+ }
+ catch (Exception e)
+ {
+ XamlParseException xamlParseException = e as XamlParseException;
+ if (null != xamlParseException)
+ {
+ XamlParseException ret = new XamlParseException(xamlParseException.Message, xamlParseException.XmlInfo, xamlParseException.InnerException);
+ exception = ret;
+ }
+ else
+ {
+ exception = e;
+ }
+
+ return false;
+ }
+ }
}
}
-
+
{
class ILContext
{
- public ILContext(ILProcessor il, MethodBody body, List<Instruction> insOfAddEvent, ModuleDefinition module, FieldDefinition parentContextValues = null)
+ public ILContext(ILProcessor il, MethodBody body, List<Instruction> insOfAddEvent, ModuleDefinition module, string embeddedResourceNameSpace, FieldDefinition parentContextValues = null)
{
IL = il;
Body = body;
Variables = new Dictionary<IElementNode, VariableDefinition>();
Scopes = new Dictionary<INode, Tuple<VariableDefinition, IList<string>>>();
TypeExtensions = new Dictionary<INode, TypeReference>();
+ EmbeddedResourceNameSpace = embeddedResourceNameSpace;
ParentContextValues = parentContextValues;
Module = module;
}
public Dictionary<INode, TypeReference> TypeExtensions { get; }
+ public string EmbeddedResourceNameSpace { get; }
+
public FieldDefinition ParentContextValues { get; private set; }
public object Root { get; set; } //FieldDefinition or VariableDefinition
//Fill the loadTemplate Body
var templateIl = loadTemplate.Body.GetILProcessor();
templateIl.Emit(OpCodes.Nop);
- var templateContext = new ILContext(templateIl, loadTemplate.Body, null, module, parentValues)
+ var templateContext = new ILContext(templateIl, loadTemplate.Body, null, module, parentContext.EmbeddedResourceNameSpace, parentValues)
{
Root = root
};
return success;
}
+ private string GetNameSpaceOfResource(EmbeddedResource resource)
+ {
+ var index = resource.Name.LastIndexOf('.');
+ var resourceNameWithoutSubfix = resource.Name.Substring(0, index);
+
+ index = resourceNameWithoutSubfix.LastIndexOf('.');
+ var nameSpace = resourceNameWithoutSubfix.Substring(0, index);
+
+ return nameSpace;
+ }
+
bool DoInjection(TypeDefinition typeDef, EmbeddedResource resource, out IList<Exception> thrownExceptions)
{
thrownExceptions = null;
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Replacing {0}.InitializeComponent ()");
Exception e;
- if (!TryCoreCompile(initComp, rootnode, out e))
+
+ var embeddedResourceNameSpace = GetNameSpaceOfResource(resource);
+ if (!TryCoreCompile(initComp, rootnode, embeddedResourceNameSpace, out e))
{
LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}failed.");
(thrownExceptions = thrownExceptions ?? new List<Exception>()).Add(e);
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Replacing {0}.InitializeComponent ()");
Exception e;
- var visitorContext = new EXamlContext(typeDef, typeDef.Module);
+ var embeddedResourceNameSpace = GetNameSpaceOfResource(resource);
+ var visitorContext = new EXamlContext(typeDef, typeDef.Module, embeddedResourceNameSpace);
if (!TryCoreCompile(rootnode, visitorContext, out e))
{
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Replacing {0}.InitializeComponent ()");
Exception e;
- var visitorContext = new EXamlContext(typeDef, module);
+ var visitorContext = new EXamlContext(typeDef, module, null);
if (!TryCoreCompile(rootnode, visitorContext, out e))
{
return true;
}
- bool TryCoreCompile(MethodDefinition initComp, ILRootNode rootnode, out Exception exception)
+ bool TryCoreCompile(MethodDefinition initComp, ILRootNode rootnode, string embeddedResourceNameSpace, out Exception exception)
{
try
{
List<Instruction> insOfAddEvent = new List<Instruction>();
- var visitorContext = new ILContext(il, body, insOfAddEvent, module);
+ var visitorContext = new ILContext(il, body, insOfAddEvent, module, embeddedResourceNameSpace);
rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null);
rootnode.Accept(new ExpandMarkupsVisitor(visitorContext), null);
initcomp.Statements.Add(new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression(new CodeTypeReference($"global::{typeof(Extensions).FullName}")),
"LoadFromXaml", new CodeThisReferenceExpression(), new CodeTypeOfExpression(declType.Name)));
- }
+
+ var exitXamlComp = new CodeMemberMethod()
+ {
+ Name = "ExitXaml",
+ CustomAttributes = { GeneratedCodeAttrDecl },
+ Attributes = MemberAttributes.Assembly | MemberAttributes.Final
+ };
+ declType.Members.Add(exitXamlComp);
+ }
else
{
var loadExaml_invoke = new CodeMethodInvokeExpression(
var exitXamlComp = new CodeMemberMethod()
{
Name = "ExitXaml",
- CustomAttributes = { GeneratedCodeAttrDecl }
+ CustomAttributes = { GeneratedCodeAttrDecl },
+ Attributes = MemberAttributes.Assembly | MemberAttributes.Final
};
exitXamlComp.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression()
public static class CecilExtensions
{
+ public static bool IsResourceDictionaryXaml(this EmbeddedResource resource, ModuleDefinition module, out string classname)
+ {
+ classname = null;
+
+ if (!resource.Name.EndsWith(".xaml", StringComparison.InvariantCulture))
+ return false;
+
+ using (var resourceStream = resource.GetResourceStream())
+ {
+ var xmlDoc = new XmlDocument();
+ xmlDoc.Load(resourceStream);
+
+ var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
+
+ var root = xmlDoc.SelectSingleNode("/*", nsmgr);
+ if (root == null)
+ return false;
+
+ var rootClass = root.Attributes["Class", XamlParser.X2006Uri] ??
+ root.Attributes["Class", XamlParser.X2009Uri];
+ if (rootClass != null)
+ {
+ classname = rootClass.Value;
+ return true;
+ }
+
+ if ("ResourceDictionary" == root.Name)
+ {
+ classname = "Tizen.NUI.Binding.ResourceDictionary";
+ return true;
+ }
+
+ return false;
+ }
+ }
+
public static bool IsXaml(this EmbeddedResource resource, ModuleDefinition module, out string classname)
{
classname = null;
var operation = new CreateDPObject(globalDataList, opInfo);
globalDataList.Operations.Add(operation);
};
+
+ createOperations[(int)EXamlOperationType.CreateResourceDictionary] = (GlobalDataList globalDataList, List<object> opInfo) =>
+ {
+ var operation = new CreateResourceDictionary(globalDataList, opInfo);
+ globalDataList.Operations.Add(operation);
+ };
}
}
}
--- /dev/null
+/*
+ * Copyright(c) 2022 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;
+
+namespace Tizen.NUI.EXaml
+{
+ class CreateResourceDictionary : Operation
+ {
+ public CreateResourceDictionary(GlobalDataList globalDataList, List<object> operationInfo)
+ {
+ typeIndex = (int)operationInfo[0];
+ indexRangeOfContent = ((int)operationInfo[1], (int)operationInfo[2]);
+ this.globalDataList = globalDataList;
+ }
+
+ private GlobalDataList globalDataList;
+ private int typeIndex;
+ private (int, int) indexRangeOfContent;
+
+ public void Do()
+ {
+ var content = globalDataList.LongStrings.Substring(indexRangeOfContent.Item1, indexRangeOfContent.Item2 - indexRangeOfContent.Item1 + 1);
+ var resourceDictionary = EXamlExtensions.CreateObjectFromEXaml(content) as ResourceDictionary;
+
+ globalDataList.GatheredInstances.Add(resourceDictionary);
+
+ if (null == globalDataList.Root)
+ {
+ globalDataList.Root = resourceDictionary;
+ }
+ }
+ }
+}
RegisterXName,
GetLongString,
CreateDPObject,
+ CreateResourceDictionary,
MAX
}
}
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
+
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Xaml;
namespace Tizen.NUI.Binding
}
/// <summary>
- /// Gets or sets the URI of the merged resource dictionary.
+ /// Gets or sets the resource dictionary.
/// </summary>
- /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// Internal using, will never open.
[EditorBrowsable(EditorBrowsableState.Never)]
[TypeConverter(typeof(RDSourceTypeConverter))]
- public Uri Source
+ public ResourceDictionary Source
{
- get { return source; }
+ get
+ {
+ return this;
+ }
set
{
- if (source == value)
- return;
- throw new InvalidOperationException("Source can only be set from XAML."); //through the RDSourceTypeConverter
+ OnValuesChanged(value.ToArray());
+
+ foreach (var pair in value)
+ {
+ Add(pair.Key, pair.Value);
+ }
}
}