2
我正在基於CRM系統中的動態對象生成VS2010中的實體包裝。除了實體代碼之外,我想添加一個EntityBase,其中所有實體都從中繼承。如果該文件存在於以前的項目中,則不應該添加。我正在使用IWizard實現爲發生器提供對象名稱等。如何確定是否使用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;
}
}