【发布时间】:2010-06-14 12:20:56
【问题描述】:
我在 VS2010 中基于 CRM 系统中的动态对象生成实体包装器。除了实体代码之外,我还想添加一个所有实体都继承自的 EntityBase。如果该文件存在于以前的项目中,则不应添加。我正在使用 IWizard 实现为生成器提供对象名称等。
是否可以在 IWizard 实现中确定是否添加之前项目中存在的项目?如何在 ShouldAddProjectItem 方法中或之前获取项目句柄及其项?
到目前为止我的代码(未完成):
public class EntityWizardImplementation : IWizard
{
public void BeforeOpeningFile(ProjectItem projectItem)
{
//Note: Nothing here.
}
public void ProjectFinishedGenerating(Project project)
{
//Note: Nothing here.
}
public void ProjectItemFinishedGenerating(ProjectItem projectItem)
{
//Note: Nothing here.
}
public void RunFinished()
{
//Note: Nothing here.
}
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
try
{
var window = new WizardWindow();
// Replace parameters gathered from the wizard
replacementsDictionary.Add("$crmEntity$", window.CrmEntity);
replacementsDictionary.Add("$crmOrganization$", window.CrmOrganization);
replacementsDictionary.Add("$crmMetadataServiceUrl$", window.CrmMetadataUrl);
window.Close();
}
catch (SoapException se)
{
MessageBox.Show(se.ToString());
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
public bool ShouldAddProjectItem(string filePath)
{
// This is where I assume it is correct to handle the preexisting file.
return true;
}
}
【问题讨论】:
标签: c# visual-studio-2010 wizard