Ejemplo n.º 1
0
        public void VerifyObject(Boolean forceInterfaceUpdateFromServer, RemoteNpcObject expectedObject)
        {
            if (expectedInterfaces == null)
            {
                throw new InvalidOperationException(String.Format(
                                                        "Cannot call VerifyObject because there were no expectedInterfaces passed to the constructor"));
            }

            GetServerInterface(forceInterfaceUpdateFromServer);

            Boolean foundObject = false;

            for (int serverObjectIndex = 0; serverObjectIndex < cachedServerObjects.Count; serverObjectIndex++)
            {
                RemoteNpcObject serverObject = cachedServerObjects[serverObjectIndex];

                if (expectedObject.name.Equals(serverObject.name))
                {
                    foundObject = true;

                    // Check that the interfaces are the same
                    for (int expectedInterfaceIndex = 0; expectedInterfaceIndex < expectedObject.interfaces.Length; expectedInterfaceIndex++)
                    {
                        RemoteNpcInterface expectedInterface = expectedObject.interfaces[expectedInterfaceIndex];
                        Boolean            foundInterface    = false;

                        for (int serverInterfaceIndex = 0; serverInterfaceIndex < serverObject.interfaces.Length; serverInterfaceIndex++)
                        {
                            RemoteNpcInterface serverInterface = serverObject.interfaces[serverInterfaceIndex];

                            if (expectedInterface.name.Equals(serverInterface.name))
                            {
                                foundInterface = true;
                                // Note: the interface definition does not need to be checked because it was already checked
                                break;
                            }
                        }

                        if (!foundInterface)
                        {
                            throw new InvalidOperationException(String.Format("Server object '{0}' is missing the '{1}' interface", serverObject.name, expectedInterface.name));
                        }
                    }

                    break;
                }
            }
            if (!foundObject)
            {
                throw new InvalidOperationException(String.Format("Server missing '{0}' object", expectedObject.name));
            }
        }
        // returns false if interactive mode should stop
        Boolean ProcessInteractiveCommand(String command)
        {
            if (command.Equals("help", StringComparison.CurrentCultureIgnoreCase))
            {
                //
                // Request methods from server
                //
                Console.WriteLine("Format: <Interface> <Method> [<Parameters>...]");

                List <RemoteNpcObject> objects = client.GetServerInterface(false);
                for (int objectIndex = 0; objectIndex < objects.Count; objectIndex++)
                {
                    RemoteNpcObject npcObject = objects[objectIndex];
                    Console.WriteLine(interfaceMapping.NpcToUserInterface(npcObject.name));

                    for (int interfaceIndex = 0; interfaceIndex < npcObject.interfaces.Length; interfaceIndex++)
                    {
                        RemoteNpcInterface npcInterface = npcObject.interfaces[interfaceIndex];
                        for (int i = 0; i < npcInterface.methods.Length; i++)
                        {
                            SosMethodDefinition method = npcInterface.methods[i];

                            Console.Write("   {0}", method.methodName);
                            if (method.parameters != null)
                            {
                                foreach (SosMethodDefinition.Parameter parameter in method.parameters)
                                {
                                    Console.Write(" {0}", parameter.name);
                                }
                            }
                            Console.WriteLine();
                        }
                    }
                }
            }
            else if (command.Equals("exit", StringComparison.CurrentCultureIgnoreCase) ||
                     command.Equals("q", StringComparison.CurrentCultureIgnoreCase) ||
                     command.Equals("quit", StringComparison.CurrentCultureIgnoreCase))
            {
                return(false);
            }
            else
            {
                Console.WriteLine("Error: Unknown interface/command '{0}'", command);
            }
            return(true);
        }
Ejemplo n.º 3
0
 public void VerifyObject(Boolean forceInterfaceUpdateFromServer, RemoteNpcObject expectedObject)
 {
     client.VerifyObject(forceInterfaceUpdateFromServer, expectedObject);
 }