STDMETHODIMP EvcSolverPropPage::Applies(VARIANT unkArray, VARIANT_BOOL* pApplies) { if (!pApplies) return E_INVALIDARG; (*pApplies) = VARIANT_FALSE; if (V_VT(&unkArray) != (VT_ARRAY|VT_UNKNOWN)) return E_INVALIDARG; // Retrieve the safe array and retrieve the data SAFEARRAY *saArray = unkArray.parray; HRESULT hr = ::SafeArrayLock(saArray); IUnknownPtr *pUnk; hr = ::SafeArrayAccessData(saArray,reinterpret_cast<void**> (&pUnk)); if (FAILED(hr)) return hr; // Loop through the elements and see if an NALayer with a valid IEvcSolver is present long lNumElements = saArray->rgsabound->cElements; for (long i = 0; i < lNumElements; i++) { INALayerPtr ipNALayer(pUnk[i]); if (!ipNALayer) continue; VARIANT_BOOL isValid; INetworkDatasetPtr ipNetworkDataset; IDEDatasetPtr ipDEDataset; IDENetworkDatasetPtr ipDENet; INASolverPtr ipSolver; INAContextPtr ipNAContext; ipNALayer->get_Context(&ipNAContext); if (!ipNAContext) continue; ipNAContext->get_Solver(&ipSolver); if (!(IEvcSolverPtr)ipSolver) continue; ((ILayerPtr)ipNALayer)->get_Valid(&isValid); if (isValid == VARIANT_FALSE) continue; ipNAContext->get_NetworkDataset(&ipNetworkDataset); if (!ipNetworkDataset) continue; ((IDatasetComponentPtr)ipNetworkDataset)->get_DataElement(&ipDEDataset); ipDENet = ipDEDataset; if (!ipDENet) continue; (*pApplies) = VARIANT_TRUE; break; } // Cleanup hr = ::SafeArrayUnaccessData(saArray); if (FAILED(hr)) return hr; hr = ::SafeArrayUnlock(saArray); if (FAILED(hr)) return hr; return S_OK; }
STDMETHODIMP ConnSolverPropPage::SetObjects(ULONG nObjects, IUnknown** ppUnk) { m_ipNALayer = 0; m_ipConnectivitySolver = 0; m_ipDENet = 0; // Loop through the objects to find one that supports // the INALayer interface. for (ULONG i=0; i < nObjects; i ++) { INALayerPtr ipNALayer(ppUnk[i]); if (!ipNALayer) continue; VARIANT_BOOL isValid; INetworkDatasetPtr ipNetworkDataset; IDEDatasetPtr ipDEDataset; IDENetworkDatasetPtr ipDENet; INASolverPtr ipSolver; INAContextPtr ipNAContext; ipNALayer->get_Context(&ipNAContext); if (!ipNAContext) continue; ipNAContext->get_Solver(&ipSolver); if (!(IConnectivitySolverPtr)ipSolver) continue; ((ILayerPtr)ipNALayer)->get_Valid(&isValid); if (isValid == VARIANT_FALSE) continue; ipNAContext->get_NetworkDataset(&ipNetworkDataset); if (!ipNetworkDataset) continue; ((IDatasetComponentPtr)ipNetworkDataset)->get_DataElement(&ipDEDataset); ipDENet = ipDEDataset; if (!ipDENet) continue; m_ipNALayer = ipNALayer; m_ipConnectivitySolver = ipSolver; m_ipDENet = ipDENet; } // Let the IPropertyPageImpl know what objects we have return IPropertyPageImpl<ConnSolverPropPage>::SetObjects(nObjects, ppUnk); }