Creates the ResourceLoader instance using the static method GetForCurrentView() instead of the constructor to resolve the Visual Studio 2013 compiler warning

This commit is contained in:
Christian Resma Helle
2013-10-23 21:56:08 +02:00
parent abeb5e25ab
commit b2429f3add
6 changed files with 17 additions and 7 deletions
@@ -84,21 +84,31 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
new CodeVariableReferenceExpression("currentAssemblyName"),
new CodeArrayIndexerExpression(new CodeVariableReferenceExpression("currentAssemblySplit"), new CodePrimitiveExpression(1)));
// TODO: Call GetForCurrentView() instead of the constructor method because the constructor will be depracted after future versions of Windows 8.1
var createResourceLoader = new CodeConditionStatement(
new CodeSnippetExpression("executingAssemblyName.Equals(currentAssemblyName)"),
new CodeStatement[] // true
{
new CodeAssignStatement(
new CodeFieldReferenceExpression(null, "resourceLoader"),
new CodeObjectCreateExpression(new CodeTypeReference("ResourceLoader"),
new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("ResourceLoader"), "GetForCurrentView",
new CodeSnippetExpression("\"" + className + "\"")))
//new CodeAssignStatement(
// new CodeFieldReferenceExpression(null, "resourceLoader"),
// new CodeObjectCreateExpression(new CodeTypeReference("ResourceLoader"),
// new CodeSnippetExpression("\"" + className + "\"")))
},
new CodeStatement[] // false
{
new CodeAssignStatement(
new CodeFieldReferenceExpression(null, "resourceLoader"),
new CodeObjectCreateExpression(new CodeTypeReference("ResourceLoader"),
new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("ResourceLoader"), "GetForCurrentView",
new CodeSnippetExpression("currentAssemblyName + \"/" + className + "\"")))
//new CodeAssignStatement(
// new CodeFieldReferenceExpression(null, "resourceLoader"),
// new CodeObjectCreateExpression(new CodeTypeReference("ResourceLoader"),
// new CodeSnippetExpression("currentAssemblyName + \"/" + className + "\"")))
});
constructor.Statements.Add(executingAssemblyVar);