src/Misc/EFTools/EntityDesign/VisualStudio/VsUtils.cs
// <summary>
//     Attempts to run the custom tool for the project item
//     Should work with both client and web project items.
//     This will attempt to checkout the file, or not do anything
//     if the file is not editable
// </summary>
Attempts to run the custom tool for the project item
Should work with both client and web project items.
This will attempt to checkout the file, or not do anything
if the file is not editable
Attempts to run the custom tool for the project item Should work with both client and web project items . This will attempt to checkout the file or not do anything if the file is not editable
internal static void RunCustomTool(ProjectItem projectItem)
        {
            var canEdit = false;
            var generatedCodeItem = GetGeneratedCodeProjectItem(projectItem);
            if (generatedCodeItem == null)
            {
                if (IsWebSiteProject(projectItem.ContainingProject))
                {
                    canEdit = true;
                }
                else
                {
                    bool projectHasFilename;
                    var projectFullPath = GetProjectPathWithName(projectItem.ContainingProject, out projectHasFilename);
                    if (projectHasFilename)
                    {
                        canEdit = VSHelpers.CheckOutFilesIfEditable(Services.ServiceProvider, new[] { projectFullPath });
                    }
                }
            }
            else
            {
                canEdit = VSHelpers.CheckOutFilesIfEditable(Services.ServiceProvider, new[] { generatedCodeItem.get_FileNames(1) });
            }
            if (canEdit)
            {
                var piObj = GetProjectItemObject(projectItem);
                var vsProjectItem = piObj as VSProjectItem;
                var vsWebProjectItem2 = piObj as VSWebProjectItem2;
                if (vsProjectItem != null)
                {
                    vsProjectItem.RunCustomTool();
                }
                else if (vsWebProjectItem2 != null)
                {
                    vsWebProjectItem2.RunCustomTool();
                }
            }
        }
internal static void RunCustomTool ( ProjectItem projectItem ) { var canEdit = false ; var generatedCodeItem = GetGeneratedCodeProjectItem ( projectItem ) ; if ( generatedCodeItem == null ) { if ( IsWebSiteProject ( projectItem . ContainingProject ) ) { canEdit = true ; } else { bool projectHasFilename ; var projectFullPath = GetProjectPathWithName ( projectItem . ContainingProject , out projectHasFilename ) ; if ( projectHasFilename ) { canEdit = VSHelpers . CheckOutFilesIfEditable ( Services . ServiceProvider , new [ ] { projectFullPath } ) ; } } } else { canEdit = VSHelpers . CheckOutFilesIfEditable ( Services . ServiceProvider , new [ ] { generatedCodeItem . get_FileNames ( 1 ) } ) ; } if ( canEdit ) { var piObj = GetProjectItemObject ( projectItem ) ; var vsProjectItem = piObj as VSProjectItem ; var vsWebProjectItem2 = piObj as VSWebProjectItem2 ; if ( vsProjectItem != null ) { vsProjectItem . RunCustomTool ( ) ; } else if ( vsWebProjectItem2 != null ) { vsWebProjectItem2 . RunCustomTool ( ) ; } } }
Attempts to run the custom tool for the project item
Should work with both client and web project items.
Attempts to run the custom tool for the project item Should work with both client and web project items .
// If we don't have a generated code item then it is about to be created. // Need to ensure the project is editable so that we can add the generated code file. // no project file to check out for a Website project
projectItem
ProjectItem