예제 #1
0
 public signals.IBlock[] Discover()
 {
     // discovery can be expensive, so we just use a large buffer rather than call things multiple times
     if (!m_canDiscover) throw new NotSupportedException("Driver cannot discover objects.");
     IntPtr[] ptrArr = new IntPtr[BufferSize];
     GCHandle pin = GCHandle.Alloc(ptrArr, GCHandleType.Pinned);
     uint numObj;
     try
     {
         numObj = m_native.Discover(pin.AddrOfPinnedObject(), (uint)BufferSize);
     }
     finally
     {
         pin.Free();
     }
     signals.IBlock[] objArr = new signals.IBlock[numObj];
     for (int idx = 0; idx < numObj; idx++)
     {
         if (ptrArr[idx] != IntPtr.Zero)
         {
             signals.IBlock newObj = (signals.IBlock)Registration.retrieveObject(ptrArr[idx]);
             if (newObj == null) newObj = new CppProxyBlock(this, null, ptrArr[idx]);
             objArr[idx] = newObj;
         }
     }
     return objArr;
 }
예제 #2
0
 public signals.IBlock Create()
 {
     if (!m_canCreate) throw new NotSupportedException("Driver cannot create objects.");
     IntPtr newObjRef = m_native.Create();
     if (newObjRef == IntPtr.Zero) return null;
     signals.IBlock newObj = (signals.IBlock)Registration.retrieveObject(newObjRef);
     if (newObj == null) newObj = new CppProxyBlock(this, null, newObjRef);
     return newObj;
 }