Beispiel #1
0
        private void ListPackageVersions(
            ClientConnection clientConnection,
            ClientRequest clientRequest)
        {
            // request
            XmlDocument xmlDocument = new XmlDocument();

            using (MemoryStream memoryStream = new MemoryStream(clientRequest.Message.Data))
            {
                xmlDocument.Load(memoryStream);
            }

            XmlMessageListPackages listPackagesMessage = XmlMessageCreator.CreateXmlMessageListPackages(xmlDocument);

            // response
            XmlMessageListPackageVersions packageVersions = XmlMessageCreator.CreateXmlMessageListPackageVersions();

            foreach (KeyValuePair <string, List <string> > repositoryItem in listPackagesMessage.Repositories)
            {
                Repository repository = _repositoryManager.GetRepository(repositoryItem.Key);
                foreach (string packageName in repositoryItem.Value)
                {
                    List <string> versions = repository.GetPackageVersions(packageName);
                    if (!packageVersions.AddRepositoryPackageVersions(repository.Name, packageName, versions))
                    {
                        Console.WriteLine("ERROR: Cannot add package versions!");
                    }
                }
            }

            SendClientXmlResponse(clientConnection, clientRequest, PacketMessageType.S_PACKAGE_VERSIONS, packageVersions);
        }
        private void OnListPackageVersionsReceived(PacketMessage packetMessage)
        {
            XmlDocument xmlDocument = CreateXmlDocumentFromMessage(packetMessage);
            //Console.WriteLine("DEBUG: Received S_PACKAGE_VERSIONS: " + xmlDocument.OuterXml);
            XmlMessageListPackageVersions message = XmlMessageCreator.CreateXmlMessageListPackageVersions(xmlDocument);

            if (ListPackageVersionsReceived != null)
            {
                ListPackageVersionsReceived(this, message);
            }
        }
 private static void OnListPackageVersionsReceived(object sender, XmlMessageListPackageVersions message)
 {
     foreach (KeyValuePair <string, Dictionary <string, List <string> > > repository in message.Repositories)
     {
         Console.WriteLine("# Packages versions of '" + repository.Key + "' repository:");
         foreach (KeyValuePair <string, List <string> > package in repository.Value)
         {
             Console.WriteLine("   * " + package.Key);
             foreach (string version in package.Value)
             {
                 Console.WriteLine("      - " + version);
             }
         }
     }
 }