English 中文(简体)
我如何确定是否使用IWizard补充项目项目?
原标题:How can I determine whether or not to add project items using IWizard?

我正在根据CRM系统的动态物体在VS2010年制作实体包裹。 除了实体法之外,我还要加上所有实体继承的实体基础。 如果项目前有档案,则不应添加。 我正在利用伊瓦希德执行,向发电机提供标名等。

在IWizard执行中,如果项目从前存在,是否可以确定是否增列一个项目? 我如何在“是否应当”项目方法中或之前处理项目及其项目?

我的法典(尚未完成):

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;
    }
}
最佳回答

自动化 运行标准方法中的目标代表了视觉演播室的环境或背景。 它可投向一个DTE物体,而且你可以从该物体获得解决办法、项目等。 如果你作为项目模板或项目模板 launch,而不是按方案进行,情况就是如此。 在这种情况下,接触物体很可能失败。

public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
    if (automationObject is DTE)
    {
        DTE dte = (DTE)automationObject;
        Array activeProjects = (Array)dte.ActiveSolutionProjects;

        if (activeProjects.Length > 0)
        {
            Project activeProj = (Project)activeProjects.GetValue(0);

            foreach (ProjectItem pi in activeProj.ProjectItems)
            {
                // Do something for the project items like filename checks etc.
            }
        }
    }
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签