VsTeXProject.VisualStudio.Project.ProjectNode.AddComponent C# (CSharp) Метод

AddComponent() публичный Метод

Add Components to the Project. Used by the environment to add components specified by the user in the Component Selector dialog to the specified project
public AddComponent ( VSADDCOMPOPERATION dwAddCompOperation, uint cComponents, IntPtr rgpcsdComponents, IntPtr hwndDialog, VSADDCOMPRESULT pResult ) : int
dwAddCompOperation VSADDCOMPOPERATION The component operation to be performed.
cComponents uint Number of components to be added
rgpcsdComponents System.IntPtr array of component selector data
hwndDialog System.IntPtr Handle to the component picker dialog
pResult VSADDCOMPRESULT Result to be returned to the caller
Результат int
        public virtual int AddComponent(VSADDCOMPOPERATION dwAddCompOperation, uint cComponents,
            IntPtr[] rgpcsdComponents, IntPtr hwndDialog, VSADDCOMPRESULT[] pResult)
        {
            if (rgpcsdComponents == null || pResult == null)
            {
                return VSConstants.E_FAIL;
            }

            //initalize the out parameter
            pResult[0] = VSADDCOMPRESULT.ADDCOMPRESULT_Success;

            var references = GetReferenceContainer();
            if (null == references)
            {
                // This project does not support references or the reference container was not created.
                // In both cases this operation is not supported.
                return VSConstants.E_NOTIMPL;
            }
            for (var cCount = 0; cCount < cComponents; cCount++)
            {
                var selectorData = new VSCOMPONENTSELECTORDATA();
                var ptr = rgpcsdComponents[cCount];
                selectorData = (VSCOMPONENTSELECTORDATA) Marshal.PtrToStructure(ptr, typeof (VSCOMPONENTSELECTORDATA));
                if (null == references.AddReferenceFromSelectorData(selectorData))
                {
                    //Skip further proccessing since a reference has to be added
                    pResult[0] = VSADDCOMPRESULT.ADDCOMPRESULT_Failure;
                    return VSConstants.S_OK;
                }
            }
            return VSConstants.S_OK;
        }
ProjectNode