コード例 #1
0
 /// <summary>
 /// Determines whether the specified <c>sockets</c> satisfy 
 /// the condition on required sockets (<c>neededSockets</c>) 
 /// i.e. if there are sockets of the same name and the same type 
 /// (<see cref="F:Ferda.Modules.Serializer.BoxSerializer.NeededSocket.FunctionIceId"/>)
 /// as required.
 /// </summary>
 /// <param name="neededSockets">The needed sockets.</param>
 /// <param name="sockets">The sockets.</param>
 /// <returns>
 /// <c>true</c> if the specified <c>sockets</c>satisfy 
 /// <c>neededSockets</c> restrictions; otherwise, <c>false</c>.
 /// </returns>
 private static bool hasSockets(NeededSocket[] neededSockets, SocketInfo[] sockets)
 {
     // creates dictionary of sockets
     Dictionary<string, SocketInfo> socketsDict = new Dictionary<string, SocketInfo>();
     foreach (SocketInfo socket in sockets)
     {
         socketsDict[socket.name] = socket;
     }
     // tests if each needed socket is present and implements required interface
     foreach (NeededSocket socketNeeded in neededSockets)
     {
         // tests if needed socket is present
         SocketInfo socketInfo;
         if (!socketsDict.TryGetValue(socketNeeded.socketName, out socketInfo))
         {
             // needed socket is not present
             return false;
         }
         // tests if the socket has needed boxtype
         BoxType[] boxTypeSeq = socketInfo.socketType;
         bool finded = false;
         foreach (BoxType boxType in boxTypeSeq)
         {
             if (boxType.functionIceId == socketNeeded.functionIceId)
             {
                 // the socket has needed boxtype
                 finded = true;
                 break;
             }
         }
         // the socket has not needed boxtype
         if (!finded)
             return false;
     }
     return true;
 }
コード例 #2
0
 protected bool hasSockets(NeededSocket[] neededSockets)
 {
     Dictionary<string,SocketInfo> socketsDict = new Dictionary<string,SocketInfo>();
     foreach (SocketInfo socket in Sockets)
     {
         socketsDict[socket.name] = socket;
     }
     foreach (NeededSocket socketNeeded in neededSockets)
     {
         SocketInfo sockNfo;
         if(!socketsDict.TryGetValue(socketNeeded.socketName,out sockNfo))
         {
             return false;
         }
         BoxType[] boxTypeSeq = sockNfo.socketType;
         bool finded = false;
         foreach (BoxType boxType in boxTypeSeq)
         {
             if (boxType.functionIceId == socketNeeded.functionIceId)
             {
                 finded = true;
                 break;
             }
         }
         if (!finded) return false;
     }
     return true;
 }
コード例 #3
0
 private bool hasSockets(NeededSocket[] neededSockets, BoxModuleFactoryCreatorPrx creator)
 {
     Dictionary<string,SocketInfo> socketsDict = new Dictionary<string,SocketInfo>();
     BoxModuleFactoryPrx factory = creator.createBoxModuleFactory(
         helper.LocalePrefs,
         helper.ManagersEnginePrx);
     SocketInfo[] sockets = factory.getSockets();
     factory.destroy();
     foreach (SocketInfo socket in sockets)
     {
         socketsDict[socket.name] = socket;
     }
     foreach (NeededSocket socketNeeded in neededSockets)
     {
         SocketInfo sockNfo;
         if (!socketsDict.TryGetValue(socketNeeded.socketName, out sockNfo))
             return false;
         BoxType[] boxTypeSeq = sockNfo.socketType;
         bool finded = false;
         foreach (BoxType boxType in boxTypeSeq)
         {
             if (boxType.functionIceId == socketNeeded.functionIceId)
             {
                 finded = true;
                 break;
             }
         }
         if (!finded) return false;
     }
     return true;
 }