CodeTV.GraphBuilderWDM.FindCrossbarPin C# (CSharp) Method

FindCrossbarPin() public method

public FindCrossbarPin ( IAMCrossbar pXBar, PhysicalConnectorType PhysicalType, PinDirection Dir, int &pIndex ) : int
pXBar IAMCrossbar
PhysicalType PhysicalConnectorType
Dir PinDirection
pIndex int
return int
        public int FindCrossbarPin(IAMCrossbar pXBar, PhysicalConnectorType PhysicalType,
            PinDirection Dir, out int pIndex)
        {
            pIndex = -1;
            bool bInput = (Dir == PinDirection.Input ? true : false);

            // Find out how many pins the crossbar has.
            int cOut, cIn;
            int hr = pXBar.get_PinCounts(out cOut, out cIn);
            if (hr < 0) return hr;
            // Enumerate pins and look for a matching pin.
            int count = (bInput ? cIn : cOut);
            for (int i = 0; i < count; i++)
            {
                int iRelated = 0;
                PhysicalConnectorType ThisPhysicalType = 0;
                hr = pXBar.get_CrossbarPinInfo(bInput, i, out iRelated, out ThisPhysicalType);
                if (hr >= 0 && ThisPhysicalType == PhysicalType)
                {
                    // Found a match, return the index.
                    pIndex = i;
                    return 0;
                }
            }
            // Did not find a matching pin.
            return -1;
        }