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;
}