public bool UseInjection { get; set; }
+ public int XamlOptimization { get; set; } = 2;
+
public IAssemblyResolver DefaultAssemblyResolver { get; set; }
public string Type { get; set; }
continue;
}
- bool currentRetOfType;
- IList<Exception> currentExceptionsOfType;
+ bool currentRetOfType = false;
+ IList<Exception> currentExceptionsOfType = null;
- if (UseInjection)
+ if(UseInjection) XamlOptimization = 1;
+ LoggingHelper.LogWarning($"XamlOptimization is {XamlOptimization}.");
+ if (0 == XamlOptimization)
+ {//Use Xaml
+ currentRetOfType = true;
+ }
+ else if (1 == XamlOptimization)
{
currentRetOfType = DoInjection(typeDef, resource, out currentExceptionsOfType);
}
public string RootClrNamespace { get; private set; }
public string RootType { get; private set; }
public bool AddXamlCompilationAttribute { get; set; }
+ public int XamlOptimization { get; set; }
bool GenerateDefaultCtor { get; set; }
bool HideFromIntellisense { get; set; }
bool XamlResourceIdOnly { get; set; }
declType.Members.Add(initcomp);
//Create and initialize fields
- var loadExaml_invoke = new CodeMethodInvokeExpression(
- new CodeTypeReferenceExpression(new CodeTypeReference($"global::Tizen.NUI.EXaml.EXamlExtensions")),
- "LoadFromEXamlByRelativePath", new CodeThisReferenceExpression(),
- new CodeMethodInvokeExpression()
- { Method = new CodeMethodReferenceExpression() { MethodName = "GetEXamlPath" } });
-
- CodeAssignStatement assignEXamlObject = new CodeAssignStatement(
- new CodeVariableReferenceExpression("eXamlData"), loadExaml_invoke);
- initcomp.Statements.Add(assignEXamlObject);
+ if(0 == XamlOptimization)
+ {
+ initcomp.Statements.Add(new CodeMethodInvokeExpression(
+ new CodeTypeReferenceExpression(new CodeTypeReference($"global::{typeof(Extensions).FullName}")),
+ "LoadFromXaml", new CodeThisReferenceExpression(), new CodeTypeOfExpression(declType.Name)));
+ }
+ else
+ {
+ var loadExaml_invoke = new CodeMethodInvokeExpression(
+ new CodeTypeReferenceExpression(new CodeTypeReference($"global::Tizen.NUI.EXaml.EXamlExtensions")),
+ "LoadFromEXamlByRelativePath", new CodeThisReferenceExpression(),
+ new CodeMethodInvokeExpression()
+ { Method = new CodeMethodReferenceExpression() { MethodName = "GetEXamlPath" } });
+
+ CodeAssignStatement assignEXamlObject = new CodeAssignStatement(
+ new CodeVariableReferenceExpression("eXamlData"), loadExaml_invoke);
+
+ initcomp.Statements.Add(assignEXamlObject);
+ }
foreach (var namedField in NamedFields) {
if(namedField.Type.BaseType.Contains("-"))
initcomp.Statements.Add(assign);
}
- declType.Members.Add(new CodeMemberField
- {
- Name = "eXamlData",
- Type = new CodeTypeReference("System.Object"),
- Attributes = MemberAttributes.Private,
- CustomAttributes = { GeneratedCodeAttrDecl }
- });
-
- var getEXamlPathcomp = new CodeMemberMethod()
- {
- Name = "GetEXamlPath",
- ReturnType = new CodeTypeReference(typeof(string)),
- CustomAttributes = { GeneratedCodeAttrDecl }
- };
+ if(0 != XamlOptimization)
+ {
+ declType.Members.Add(new CodeMemberField
+ {
+ Name = "eXamlData",
+ Type = new CodeTypeReference("System.Object"),
+ Attributes = MemberAttributes.Private,
+ CustomAttributes = { GeneratedCodeAttrDecl }
+ });
- getEXamlPathcomp.Statements.Add(new CodeMethodReturnStatement(new CodeDefaultValueExpression(new CodeTypeReference(typeof(string)))));
+ var getEXamlPathcomp = new CodeMemberMethod()
+ {
+ Name = "GetEXamlPath",
+ ReturnType = new CodeTypeReference(typeof(string)),
+ CustomAttributes = { GeneratedCodeAttrDecl }
+ };
- declType.Members.Add(getEXamlPathcomp);
+ getEXamlPathcomp.Statements.Add(new CodeMethodReturnStatement(new CodeDefaultValueExpression(new CodeTypeReference(typeof(string)))));
- GenerateMethodExitXaml(declType);
+ declType.Members.Add(getEXamlPathcomp);
+ GenerateMethodExitXaml(declType);
+ }
writeAndExit:
//write the result
using (var writer = new StreamWriter(outFilePath))