Exemplo n.º 1
0
        public void TestNuspec()
        {
            var metaData = new PackageMetaData()
            {
                Id            = "Id1",
                Version       = "1.0.0.0",
                Title         = "Title",
                Author        = "Auth1",
                Owner         = "Owner1",
                Copyright     = "CP1",
                Desciption    = "Desc1",
                Tags          = "T1",
                ReleaseNotes  = "RN1",
                CustomLibrary = new List <string>()
                {
                    "A.exe"
                },
                CustomReference = new List <string>(),
            };

            var         nuspecDoc = new NuSpecDocument(projectADocument.Object, metaData);
            XmlDocument doc       = nuspecDoc.Generate().Result;

            Assert.IsNotNull(doc);
            CheckDependencies(doc);
            CheckReferences(doc, metaData);
            CheckContentFile(doc);
            CheckFiles(doc, metaData);
        }
Exemplo n.º 2
0
        private void CheckFiles(XmlDocument doc, PackageMetaData metaData)
        {
            string queryPath = NuSpecDocument.PACKAGE_NODE + "/" + NuSpecDocument.FILES_NODE + "/"
                               + NuSpecDocument.FILE_NODE + "[@src = \"bin\\release\\{0}\" and @target= \"lib\\net461\"]";
            string queryPath2 = NuSpecDocument.PACKAGE_NODE + "/" + NuSpecDocument.FILES_NODE + "/"
                                + NuSpecDocument.FILE_NODE + "[@src = \"bin\\release\\{0}\" and @target= \"ref\\net461\"]";

            foreach (IProjectDocument r in projectADocument.Object.AllProjectReferences)
            {
                Assert.IsTrue(doc.SelectNodes(string.Format(queryPath, Path.GetFileNameWithoutExtension(r.ProjectPath) + ".dll")).Count == 1);
                Assert.IsTrue(doc.SelectNodes(string.Format(queryPath2, Path.GetFileNameWithoutExtension(r.ProjectPath) + ".dll")).Count == 1);
            }

            foreach (string r in metaData.CustomLibrary)
            {
                Assert.IsTrue(doc.SelectNodes(string.Format(queryPath, r)).Count == 1);
            }

            string queryPath3 = NuSpecDocument.PACKAGE_NODE + "/" + NuSpecDocument.FILES_NODE + "/"
                                + NuSpecDocument.FILE_NODE + "[@src = \"bin\\release\\{0}\" and @target= \"contentFiles\\any\\any\\{0}\"]";

            foreach (string cf in projectADocument.Object.ContentFiles)
            {
                Assert.IsTrue(doc.SelectNodes(string.Format(queryPath3, cf)).Count == 1);
            }
        }
Exemplo n.º 3
0
        public Package Init(Repository repo, IAbsoluteDirectoryPath directory, PackageMetaData initialMetaData = null)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }

            if (initialMetaData == null)
            {
                initialMetaData = new PackageMetaData(PackifyPath(directory.ToString()));
            }

            if (string.IsNullOrWhiteSpace(initialMetaData.Name))
            {
                throw new Exception("Initial metadata lacks Package Name");
            }

            if (initialMetaData.Version == null)
            {
                throw new Exception("Initial metadata lacks Version");
            }

            var depName = initialMetaData.GetFullName();

            if (repo.HasPackage(depName))
            {
                throw new Exception("Package and version already exists: " + depName);
            }

            return(new Package(directory, initialMetaData, repo));
        }
Exemplo n.º 4
0
        public void TestNuspec_Content()
        {
            var metaData = new PackageMetaData()
            {
                Id            = "Id1",
                Version       = "1.0.0.0",
                Title         = "Title",
                Author        = "Auth1",
                Owner         = "Owner1",
                Copyright     = "CP1",
                Desciption    = "Desc1",
                Tags          = "T1",
                ReleaseNotes  = "RN1",
                CustomLibrary = new List <string>()
                {
                    "A.exe"
                },
                CustomReference = new List <string>(),
            };

            var         nuspecDoc = new NuSpecDocument(projectADocument.Object, metaData);
            XmlDocument doc       = nuspecDoc.Generate().Result;

            string expectedValue = @"<?xml version=""1.0"" encoding=""utf-8""?><package><metadata><id>Id1</id><version>1.0.0.0</version><title>Title</title><authors>Auth1</authors><owners>Owner1</owners><description>Desc1</description><releaseNotes>RN1</releaseNotes><copyright>CP1</copyright><tags>T1</tags><dependencies><group><dependency id=""PackageOne"" version=""1.0.0.0"" /><dependency id=""PackageTwo"" version=""2.0.0.0"" /><dependency id=""PackageThree"" version=""1.0.0.0"" /><dependency id=""PackageFour"" version=""3.0.0.0"" /><dependency id=""PackageFive"" version=""1.0.0.0"" /></group><group targetFramework=""net461""><dependency id=""PackageOne"" version=""1.0.0.0"" /><dependency id=""PackageTwo"" version=""2.0.0.0"" /><dependency id=""PackageThree"" version=""1.0.0.0"" /><dependency id=""PackageFour"" version=""3.0.0.0"" /><dependency id=""PackageFive"" version=""1.0.0.0"" /></group></dependencies><references><group><reference file=""B.dll"" /><reference file=""C.dll"" /></group><group targetFramework=""net461""><reference file=""B.dll"" /><reference file=""C.dll"" /></group></references><contentFiles><files include=""/any/any/Config/CNF.xml"" buildAction=""None"" copyToOutput=""true"" /><files include=""/any/any/Data/MyData.json"" buildAction=""None"" copyToOutput=""true"" /></contentFiles></metadata><files><file src=""bin\release\B.dll"" target=""ref\net461"" /><file src=""bin\release\C.dll"" target=""ref\net461"" /><file src=""bin\release\B.dll"" target=""lib\net461"" /><file src=""bin\release\C.dll"" target=""lib\net461"" /><file src=""bin\release\A.exe"" target=""lib\net461"" /><file src=""bin\release\Config\CNF.xml"" target=""contentFiles\any\any\Config\CNF.xml"" /><file src=""bin\release\Data\MyData.json"" target=""contentFiles\any\any\Data\MyData.json"" /></files></package>";

            Assert.AreEqual(doc.InnerXml, expectedValue);
        }
Exemplo n.º 5
0
        void UpdateFileMetaData(PackageMetaData metaData, FileObjectMapping x, ICollection <string> paths)
        {
            metaData.Size += new FileInfo(Path.Combine(WorkingPath.ToString(), x.FilePath)).Length;
            var path = Repository.GetObjectPath(x.Checksum);

            if (paths.Contains(path.ToString()))
            {
                return;
            }
            paths.Add(path.ToString());
            metaData.SizePacked += new FileInfo(path.ToString()).Length;
        }
Exemplo n.º 6
0
        public bool Commit(string desiredVersion, bool force = false, bool downCase = true)
        {
            var metaData = CreateUpdatedMetaData(desiredVersion, downCase);

            if (!force && MetaData.Compare(metaData))
            {
                return(false);
            }

            MetaData = metaData;
            Save();
            return(true);
        }
Exemplo n.º 7
0
        public void TestSameInstanceDto() {
            var package = new PackageMetaData("abc") {
                Additional = new Dictionary<string, string>(),
                Authors = new Dictionary<string, string> {{"abc", "cba"}}
            };
            var mappedPackage = Repository.MappingEngine.Map<PackageMetaDataDto>(package);

            mappedPackage.Additional.Should().Equal(package.Additional);
            mappedPackage.Authors.Should().Equal(package.Authors);

            ReferenceEquals(mappedPackage.Additional, package.Additional).Should().BeFalse();
            ReferenceEquals(mappedPackage.Authors, package.Authors).Should().BeFalse();
        }
Exemplo n.º 8
0
    public void OnLoginClicked()
    {
        SendData LoginData = new SendData(-1);

        LoginData.GetDataPackage().AddLoginInfo(AccountInput.text, PasswordInput.text);
        int sendNum = LoginData.Send();

        Debug.Log("Here we send the login data to the server! The send Num is: " + sendNum);



        PackageMetaData LoginRecvPackage = ReceiveData.GetSingleton().GetLatestPackage("Login");

        int times = 0;

        while (true)
        {
            if (times >= 3)
            {
                break;
            }
            if (LoginRecvPackage == null)
            {
                Thread.Sleep(1000);
            }
            else
            {
                break;
            }
            LoginRecvPackage = ReceiveData.GetSingleton().GetLatestPackage("Login");
            times           += 1;
            Debug.Log("Waitting for server login message!");
        }

        if (LoginRecvPackage == null)
        {
            Debug.Log("Please check you internet ,it's seems disconnected!");
            return;
        }

        if (Convert.ToBoolean(LoginRecvPackage.Get("LoginReturn")) == true)
        {
            //if (AccountInput.text == "123456" && PasswordInput.text == "654321")
            //{
            SceneManager.LoadScene("GameScene", LoadSceneMode.Single);
        }
        else
        {
            Debug.Log("密码错误");
        }
    }
Exemplo n.º 9
0
        private void RecvAndParseData()
        {
            while (true)
            {
                if (nQuitTimes >= 999)
                {
                    Debug.Log("Please check your internet,you might disconnected! The QuitTimes is :" + nQuitTimes + " now!");
                    return;
                }

                if (NetworkManager.GetSingleton().RecvPackFromServer(ref RecvData) <= 0)
                {
                    nQuitTimes += 1;
                    Thread.Sleep(5);
                    Debug.Log("Here the nQuitTimes is : " + nQuitTimes + "When it comes to 999,end the thread!");
                    continue;
                }
                nQuitTimes = 0;

                Debug.Log("Here we receive a package from server and parse it!");
                PackageMetaData RecvPackage = RecvPackage = ParsePackageService.Parse(RecvData);

                //这里获取一下包的类型,以便于选择是否创建新的队列
                var PackageType = RecvPackage.Get("Type");
                if (!RecvDataPool.ContainsKey(PackageType))
                {
                    var TypeQueue = new Queue <PackageMetaData>();
                    RecvDataPool.Add(PackageType, TypeQueue);
                    Debug.Log("Here we create a new queue!");
                }

                if (firstTimeRecvOtherPlayer == false)
                {
                    nOtherID = Convert.ToInt32(RecvPackage.Get("ID"));
                    if (nOtherID > 0)
                    {
                        firstTimeRecvOtherPlayer = true;
                    }
                }

                if (RecvDataPool[PackageType].Count > nQueueMaxLen)
                {
                    Debug.Log("Too many packages in the queue, let's delete the front one!");
                    RecvDataPool[PackageType].Dequeue();
                }
                Debug.Log("Here we add a parsed package to the queue!");
                RecvDataPool[PackageType].Enqueue(RecvPackage);
            }
        }
Exemplo n.º 10
0
        private void CheckReferences(XmlDocument doc, PackageMetaData metaData)
        {
            string queryPath = NuSpecDocument.PACKAGE_NODE + "/" + NuSpecDocument.METADATA_NODE + "/"
                               + NuSpecDocument.REFERENCES_NODE + "/" + NuSpecDocument.GROUP_NODE + "/" + NuSpecDocument.REFERENCE_NODE + "[@file = \"{0}\"]";

            foreach (IProjectDocument r in projectADocument.Object.AllProjectReferences)
            {
                Assert.IsTrue(doc.SelectNodes(string.Format(queryPath, Path.GetFileNameWithoutExtension(r.ProjectPath) + ".dll")).Count == 2);
            }

            foreach (string r in metaData.CustomReference)
            {
                Assert.IsTrue(doc.SelectNodes(string.Format(queryPath, r)).Count == 2);
            }
        }
Exemplo n.º 11
0
        public Package(IAbsoluteDirectoryPath workingDirectory, PackageMetaData metaData, Repository repository)
        {
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }
            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }

            WorkingPath = workingDirectory;
            Repository  = repository;
            ConfirmPathValidity();
            MetaData   = metaData;
            StatusRepo = new StatusRepo();
        }
Exemplo n.º 12
0
        PackageMetaData UpdateMetaData(bool downCase, PackageMetaData metaData)
        {
            metaData.Files = Repository.Commit(WorkingPath, downCase);
            var paths = new List <string>();

            GetMetaDataFilesOrderedBySize(metaData).ForEach(x => UpdateFileMetaData(metaData, x, paths));

            if (string.IsNullOrWhiteSpace(metaData.ContentType))
            {
                return(metaData);
            }
            Repository.SetContentType(metaData.Name, metaData.ContentType);
            Repository.Save();
            // TODO: This should be done in one go, now its done twice once at Repository.Commit and once here :S

            return(metaData);
        }
Exemplo n.º 13
0
        public void TestSameInstanceDto()
        {
            var package = new PackageMetaData("abc")
            {
                Additional = new Dictionary <string, string>(),
                Authors    = new Dictionary <string, string> {
                    { "abc", "cba" }
                }
            };
            var mappedPackage = Repository.MappingEngine.Map <PackageMetaDataDto>(package);

            mappedPackage.Additional.Should().Equal(package.Additional);
            mappedPackage.Authors.Should().Equal(package.Authors);

            ReferenceEquals(mappedPackage.Additional, package.Additional).Should().BeFalse();
            ReferenceEquals(mappedPackage.Authors, package.Authors).Should().BeFalse();
        }
Exemplo n.º 14
0
        public Package Init(Repository repo, IAbsoluteDirectoryPath directory, PackageMetaData initialMetaData = null) {
            Contract.Requires<ArgumentNullException>(directory != null);

            if (initialMetaData == null)
                initialMetaData = new PackageMetaData(PackifyPath(directory.ToString()));

            if (string.IsNullOrWhiteSpace(initialMetaData.Name))
                throw new Exception("Initial metadata lacks Package Name");

            if (initialMetaData.Version == null)
                throw new Exception("Initial metadata lacks Version");

            var depName = initialMetaData.GetFullName();
            if (repo.HasPackage(depName))
                throw new Exception("Package and version already exists: " + depName);

            return new Package(directory, initialMetaData, repo);
        }
Exemplo n.º 15
0
        private void RunCreatePackage()
        {
            var packageMetaData = new PackageMetaData
            {
                Author  = this.commandOptions.Author,
                Name    = this.commandOptions.Name,
                Tokens  = this.commandOptions.Tokens.Select(kvp => kvp.Value).ToList(),
                Version = this.commandOptions.Version
            };

            var package = this.packageBuilder.Build(this.commandOptions.Path, packageMetaData);

            var clonedPackage    = this.clonePackageBuilder.Build(package);
            var tokenisedPackage = this.packageTokeniser.Tokenise(clonedPackage, this.commandOptions.Tokens);

            this.archiveBuilder.Build(tokenisedPackage, this.commandOptions.Path, this.commandOptions.PackageRepositoryPath);
            this.cleanUpProcessor.Process(FilePaths.TemporaryPackageRepository);
        }
Exemplo n.º 16
0
 static IOrderedEnumerable <FileObjectMapping> GetMetaDataFilesOrderedBySize(PackageMetaData metaData)
 => metaData.GetFiles()
 .OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FilePath));
Exemplo n.º 17
0
 public PackageItem(PackageMetaData metaData, RepositoryHandler handler, IEnumerable <SpecificVersion> packages)
     : this(metaData.Name, handler, packages)
 {
     ActualDependency = metaData.ToSpecificVersion();
     Current          = metaData;
 }
Exemplo n.º 18
0
        private void BuildToc()
        {
            InstalledBooks xml = _catalogXml.InstalledBooks;

            if (xml == null)
            {
                return;
            }

            treeView1.BeginUpdate();
            try
            {
                TreeNode tn;
                TreeNode tn2;
                TreeNode tn3;
                TreeNode tn4;

                treeView1.Nodes.Add("Catalog Location: " + _catalogXml.CatalogLocation);
                treeView1.Nodes.Add("Catalog Version: " + xml.version);
                if (_catalogXml.CatalogTypeXmlFound)
                {
                    nodeCatalogTypeXml = treeView1.Nodes.Add("UserManaged=" + _catalogXml.UserManaged);
                }
                else
                {
                    nodeCatalogTypeXml = treeView1.Nodes.Add("UserManaged=<CatalogType.xml not found>");
                }
                nodeCatalogTypeXml.ToolTipText = "CatalogType.xml";

                Color infoColor    = Color.DimGray;
                Color packageColor = Color.SaddleBrown;

                foreach (LocaleListItem localeListItem in xml.localeList)
                {
                    tn = treeView1.Nodes.Add(localeListItem.locale);
                    foreach (BookListItem bookListItem in localeListItem.bookList)
                    {
                        tn2             = tn.Nodes.Add(bookListItem.displayname);
                        tn2.ToolTipText = "Book display name";
                        tn2.Nodes.Add("kind: " + bookListItem.kind);
                        tn2.Nodes.Add("path: " + bookListItem.path);
                        tn2.Nodes.Add("productgroupname: " + bookListItem.productgroupname);
                        tn2.Nodes.Add("productname: " + bookListItem.productname);
                        tn2.Nodes.Add("ref: " + bookListItem.ref_);
                        tn2.Nodes.Add("source: " + bookListItem.source);
                        tn2.Nodes.Add("vendorname: " + bookListItem.vendorname);

                        tn3 = tn2.Nodes.Add("packages");
                        foreach (String package in bookListItem.packageList)
                        {
                            tn4             = tn3.Nodes.Add(package);
                            tn4.ForeColor   = packageColor;
                            tn4.ToolTipText = "Package name. Sub-items are extracted from\n" + package + ".metadata";

                            //Show meta data (extracted from <package>.metadata file)
                            if (!String.IsNullOrEmpty(package) && _catalogPackageMetaData.Count > 0)
                            {
                                PackageMetaData metadata = _catalogPackageMetaData[package];
                                if (metadata != null)
                                {
                                    tn4.Nodes.Add("Date: " + metadata.Date).ForeColor = infoColor;
                                    tn4.Nodes.Add("ETag: " + metadata.ETag).ForeColor = infoColor;
                                    tn4.Nodes.Add("PackageType: " + metadata.PackageType).ForeColor = infoColor;
                                    tn4.Nodes.Add("Size: " + metadata.Size).ForeColor             = infoColor;
                                    tn4.Nodes.Add("Url: " + metadata.Url).ForeColor               = infoColor;
                                    tn4.Nodes.Add("VendorName: " + metadata.VendorName).ForeColor = infoColor;
                                }
                            }
                        }
                    }
                }


                tn = treeView1.Nodes.Add("Branding Packages");
                foreach (BrandingPackage brandingPackage in xml.brandingPackages)
                {
                    tn2 = tn.Nodes.Add(brandingPackage.package);
                    tn2.Nodes.Add("vendorName:" + brandingPackage.vendorName);
                    tn2.Nodes.Add("locale:" + brandingPackage.locale);
                }
            }
            finally
            {
                treeView1.EndUpdate();

                //Select something
                if (treeView1.Nodes.Count > 0)
                {
                    treeView1.SelectedNode = treeView1.Nodes[0];
                    treeView1.Select();
                }
            }
        }