0

Inside my template file I use the safeitemname template variable to define my class name. The Item Template is intended to create a class that subclasses MXApplication. The result after exporting the template and utilizing it to create a new class is essentially the class inherits from itself. If I try adding a namespace to the class, I just get the namespace prefixed before the value substituted for safeitemname.

Here is the Template class (trimmed for explanation purposes):

namespace $rootnamespace$
{
  public class $safeitemname$ : MonoCross.Navigation.MXApplication
  {
    public override void OnAppLoad()
    {
        //Do the work
    }
  }
}



The result when I use the template to create MyApp is:

namespace MyNameSpace
{
  public class MyApp : MonoCross.Navigation.MyApp
  {
    public override void OnAppLoad()
    {
        //Do the work
    }
  }
}

I've tried to export this template using VS2012 (and VS2013).

Any advice would be much appreciated. I've been trying to update my Item Templates in Visual Studio 2012 (they worked in 2010) but I keep running into this issue. I've tried it on several of my existing templates; and even tried recreating the .csproj and adding my existing templates to the .csprog file created using Visual Studio 2012. All of my attempts result in the same class inheritance issue.

This is the MSDN Doc I've been using for reference: http://msdn.microsoft.com/en-us/library/vstudio/tsyyf0yh.aspx

4

1 回答 1

0

查看由导出模板命令创建的 .zip 文件时,该问题很明显。包含在模板 .zip 中的 .cs 文件内容如下:

namespace $rootnamespace$
{
  class $safeitemname$ :  MonoCross.Navigation.$safeitemname$
  {
    public override void OnAppLoad()
    {
      //Do the work
    }
  }
}


使我的模板正常工作的修复方法是手动编辑 .cs 文件并替换最后一个文件$safeitemname$MXApplication然后将 .cs 文件放回它来自的 .zip 文件中。

于 2013-09-17T18:40:25.297 回答