예제 #1
0
        public void AddReleaseNote(ReleaseItem pluginReadme)
        {
            if (items == null)
            {
                items = new List <ReleaseItem> {
                    pluginReadme
                };
            }
            else
            {
                bool exist = false;
                foreach (var item in items)
                {
                    if (item.version == pluginReadme.version)
                    {
                        item.content = pluginReadme.content;
                        item.author  = pluginReadme.author;
                        exist        = true;
                        break;
                    }
                }

                if (!exist)
                {
                    items.Add(pluginReadme);
                }
            }
        }
예제 #2
0
        protected override void OnBegin()
        {
            Dictionary <string, string> headers = null;

            if (User.Logined)
            {
                headers = new Dictionary <string, string>()
                {
                    { "Authorization", "Token " + User.Token }
                };
            }

            ObservableWWW.Get("http://liangxiegame.com/api/packages/", headers).Subscribe(response =>
            {
                var responseJson     = JArray.Parse(response);
                var packageInfosJson = responseJson;

                var packageDatas = new List <PackageData> ();
                foreach (var packageInfo in packageInfosJson)
                {
                    var name = packageInfo["name"].Value <string>();

                    var package = packageDatas.Find(packageData => packageData.Name == name);

                    if (package == null)
                    {
                        package = new PackageData()
                        {
                            Name = name,
                        };

                        packageDatas.Add(package);
                    }

                    var version      = packageInfo["version"].Value <string>();
                    var url          = packageInfo["file"].Value <string>();           // download_url
                    var installPath  = packageInfo["install_path"].Value <string>();
                    var release_note = packageInfo["release_note"].Value <string>();

                    var releaseItem     = new ReleaseItem(version, release_note, "liangxie", "now");
                    var typeName        = packageInfo["type"].Value <string>();
                    var accessRightName = packageInfo["access_right"].Value <string>();

                    var packageType = PackageType.FrameworkModule;

                    switch (typeName)
                    {
                    case "fm":
                        packageType = PackageType.FrameworkModule;
                        break;

                    case "s":
                        packageType = PackageType.Shader;
                        break;

                    case "agt":
                        packageType = PackageType.AppOrGameDemoOrTemplate;
                        break;

                    case "p":
                        packageType = PackageType.Plugin;
                        break;
                    }

                    var accessRight = PackageAccessRight.Public;

                    switch (accessRightName)
                    {
                    case "public":
                        accessRight = PackageAccessRight.Public;
                        break;

                    case "private":
                        accessRight = PackageAccessRight.Private;
                        break;
                    }

                    package.PackageVersions.Add(new PackageVersion()
                    {
                        Version     = version,
                        DownloadUrl = url,
                        InstallPath = installPath,
                        Type        = packageType,
                        AccessRight = accessRight,
                        Readme      = releaseItem,
                    });

                    package.readme.AddReleaseNote(releaseItem);
                }

                packageDatas.ForEach(packageData =>
                {
                    packageData.PackageVersions.Sort((a, b) =>
                                                     GetVersionNumber(b.Version) - GetVersionNumber(a.Version));
                    packageData.readme.items.Sort((a, b) =>
                                                  GetVersionNumber(b.version) - GetVersionNumber(a.version));
                });

                mOnGet.InvokeGracefully(packageDatas);

                new PackageInfosRequestCache()
                {
                    PackageDatas = packageDatas
                }.Save();

                Finished = true;
            }, e =>
            {
                mOnGet.InvokeGracefully(null);
                Log.E(e);
            });
        }
        protected override void OnBegin()
        {
            ObservableWWW.Get("http://liangxiegame.com/framework_package/get_all_package_info").Subscribe(response =>
            {
                var responseJson        = JObject.Parse(response);
                JArray packageInfosJson = responseJson ["all_package_info"] as JArray;

                var packageDatas = new List <PackageData> ();
                foreach (var demoInfo in packageInfosJson)
                {
                    var name = demoInfo ["name"].Value <string> ();

                    var package = packageDatas.Find(packageData => packageData.Name == name);

                    if (package == null)
                    {
                        package = new PackageData()
                        {
                            Name = name,
                        };

                        packageDatas.Add(package);
                    }

                    var version      = demoInfo ["version"].Value <string> ();
                    var url          = demoInfo ["download_url"].Value <string> ();
                    var installPath  = demoInfo ["install_path"].Value <string> ();
                    var release_note = demoInfo["release_note"].Value <string>();

                    var releaseItem = new ReleaseItem(version, release_note, "liangxie", "now");

                    package.PackageVersions.Add(new PackageVersion()
                    {
                        Version     = version,
                        DownloadUrl = url,
                        InstallPath = installPath,
                        Readme      = releaseItem
                    });

                    package.readme.AddReleaseNote(releaseItem);
                }

                packageDatas.ForEach(packageData =>
                {
                    packageData.PackageVersions.Sort((a, b) =>
                                                     GetVersionNumber(b.Version) - GetVersionNumber(a.Version));
                    packageData.readme.items.Sort((a, b) =>
                                                  GetVersionNumber(b.version) - GetVersionNumber(a.version));
                });

                mOnGet.InvokeGracefully(packageDatas);

                new PackageInfosRequestCache()
                {
                    PackageDatas = packageDatas
                }.Save();

                Finished = true;
            }, e =>
            {
                mOnGet.InvokeGracefully(null);
                Log.E(e);
            });
        }